-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArtifactoryActionBaseEditor.cs
100 lines (88 loc) · 3.55 KB
/
ArtifactoryActionBaseEditor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using Inedo.BuildMaster.Extensibility.Actions;
using Inedo.BuildMaster.Web.Controls;
using Inedo.BuildMaster.Web.Controls.Extensions;
using Inedo.Web.Controls;
namespace Inedo.BuildMasterExtensions.Artifactory
{
public abstract class ArtifactoryActionBaseEditor : ActionEditorBase
{
protected ValidatingTextBox txtUserName;
protected ValidatingTextBox txtPassword;
protected ValidatingTextBox txtServer;
protected ValidatingTextBox txtRepository;
protected ArtifactoryActionBase extensionInstance;
public ArtifactoryActionBaseEditor()
{
this.txtUserName = new ValidatingTextBox() { Width = 300};
this.txtPassword = new ValidatingTextBox() { Width = 300 };
this.txtServer = new ValidatingTextBox() { Width = 300 };
this.txtRepository = new ValidatingTextBox() { Width = 300 };
}
protected virtual ArtifactoryActionBase PopulateProperties(ArtifactoryActionBase Value)
{
if (Value.UsesRepositoryKey)
Value.RepositoryKey = txtRepository.Text;
if (!string.IsNullOrEmpty(this.txtUserName.Text))
{
Value.ActionUsername = this.txtUserName.Text;
Value.ActionPassword = this.txtPassword.Text;
}
else
{
Value.ActionUsername = null;
Value.ActionPassword = null;
}
if (!string.IsNullOrEmpty(this.txtServer.Text))
Value.ActionServer = this.txtServer.Text;
return Value;
}
public override void BindToForm(ActionBase extension)
{
this.EnsureChildControls();
var action = (ArtifactoryActionBase)extension;
this.txtServer.Text = action.ActionServer;
this.txtRepository.Text = action.RepositoryKey;
if (!string.IsNullOrEmpty(action.ActionUsername))
{
this.txtUserName.Text = action.ActionUsername;
this.txtPassword.Text = action.ActionPassword;
}
}
protected override void CreateChildControls()
{
AddActionAuthentication();
AddServerInformation();
AddRepositoryInformation();
}
private void AddActionAuthentication()
{
this.Controls.Add(new FormFieldGroup("Custom Authentication",
"Authentication used for this action. If not populated then the credentials defined for the Artifactory extension will be used.",
false,
new StandardFormField("Username:", txtUserName),
new StandardFormField("Password:",txtPassword)
)
);
}
private void AddServerInformation()
{
var ff = new FormFieldGroup("Server", "Server used for this action. If not populated then the server defined for the Artifactory extension will be used.", false);
ff.FormFields.Add(new StandardFormField("Server:",txtServer));
this.Controls.Add(ff);
}
private void AddRepositoryInformation()
{
if (extensionInstance.UsesRepositoryKey)
{
this.Controls.Add(new FormFieldGroup("Repository", "The repository used as the source for this action.",false,
new StandardFormField("Repository:", txtRepository))
);
}
}
}
}