Skip to content

Commit

Permalink
Merge pull request #43 from skowront/issue28
Browse files Browse the repository at this point in the history
Issue28
  • Loading branch information
krzysztof-lorenc authored May 12, 2020
2 parents b60fe57 + 70b79fb commit 4371fc9
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 14 deletions.
4 changes: 3 additions & 1 deletion src/Soloplan.WhatsON.CruiseControl/CruiseControlConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ namespace Soloplan.WhatsON.CruiseControl
using Soloplan.WhatsON.CruiseControl.Model;
using Soloplan.WhatsON.Model;

[ConnectorType(ConnectorName, Description = "Retrieve the current status of a Cruise Control project.")]
[ConnectorType(ConnectorName, ConnectorDisplayName, Description = "Retrieve the current status of a Cruise Control project.")]
[NotificationConfigurationItem(NotificationsVisbility, typeof(ConnectorNotificationConfiguration), SupportsUnstableNotify = false, Priority = 1600000000)]
public class CruiseControlConnector : Connector
{
public const string ConnectorName = "CruiseControl";

public const string ConnectorDisplayName = "Cruise Control.Net";

private static readonly Logger log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType?.ToString());

private TimeSpan estimatedDuration = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Height="28"
Margin="0,8,0,10"
Cursor="Hand"
DisplayMemberPath="Name"
DisplayMemberPath="DisplayName"
ItemsSource="{Binding Path=ConnectorPlugins, Source={x:Static whatsOn:PluginManager.Instance}}" />
<TextBox x:Name="uxEditConnectorName"
Margin="0,8,0,0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public string Name
}
}



/// <summary>
/// Gets the full name of this connector including the category (if set).
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
VerticalAlignment="Center"
Orientation="Vertical">
<ComboBox materialDesign:HintAssist.Hint="Type"
DisplayMemberPath="DisplayName"
ItemsSource="{Binding AvailableConnectorTypes}"
SelectedItem="{Binding SelectedConnectorType}"
Style="{StaticResource MaterialDesignFloatingHintComboBox}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class WizardController : INotifyPropertyChanged
/// </summary>
private bool isProposedAddressEmpty = true;

private string selectedConnectorType;
private ConnectorPlugin selectedConnectorType;

/// <summary>
/// The connector view model.
Expand Down Expand Up @@ -235,21 +235,22 @@ public List<string> AvailableServers
}

return this.config.ConnectorsConfiguration.Where(x =>
x.Type == this.SelectedConnectorType &&
x.Type == this.SelectedConnectorType.Name &&
x.GetConfigurationByKey(Connector.ServerAddress) != null &&
!string.IsNullOrEmpty(x.GetConfigurationByKey(Connector.ServerAddress).Value)).Select(x => new Uri(x.GetConfigurationByKey(Connector.ServerAddress).Value).AbsoluteUri).Distinct().ToList();
}
}

public List<string> AvailableConnectorTypes
public List<ConnectorPlugin> AvailableConnectorTypes
{
get
{
return PluginManager.Instance.ConnectorPlugins.Select(x => x.Name).OrderByDescending(x => this.config.ConnectorsConfiguration.Count(y => y.Type == x)).ToList();
return PluginManager.Instance.ConnectorPlugins.OrderByDescending(x => this.config.ConnectorsConfiguration.Count(y => y.Type == x.Name)).ToList();
}
}

public string SelectedConnectorType

public ConnectorPlugin SelectedConnectorType
{
get
{
Expand Down Expand Up @@ -546,7 +547,7 @@ private void GoToConnectionStep()
this.WizardFrame.Content = this.currentPage;
if (this.editedConnectorViewModel != null)
{
this.SelectedConnectorType = this.editedConnectorViewModel.SourceConnectorPlugin.Name;
this.SelectedConnectorType = this.editedConnectorViewModel.SourceConnectorPlugin;
}

this.OnPageChanged();
Expand All @@ -568,7 +569,7 @@ private void ProcessServerSubProjects(IList<Project> projects, ProjectViewModel
return false;
}

return x.Type == this.SelectedConnectorType
return x.Type == this.SelectedConnectorType.Name
&& new Uri(address).AbsoluteUri.Equals(this.ProposedServerAddress)
&& x.GetConfigurationByKey(Connector.ProjectName)?.Value == (!string.IsNullOrWhiteSpace(project.FullName) ? project.FullName : project.Name);
}).ToList();
Expand All @@ -593,7 +594,7 @@ private async Task PrepareProjectsList()
}
else
{
var plugin = PluginManager.Instance.ConnectorPlugins.FirstOrDefault(x => x.Name.Equals(this.SelectedConnectorType));
var plugin = PluginManager.Instance.ConnectorPlugins.FirstOrDefault(x => x.Name.Equals(this.SelectedConnectorType.Name));
pluginToQueryWithModel = new Tuple<ConnectorPlugin, ProjectViewModelList>(plugin, new ProjectViewModelList { MultiSelectionMode = this.MultiSelectionMode, PlugIn = plugin });
}

Expand Down
10 changes: 6 additions & 4 deletions src/Soloplan.WhatsON.Jenkins/JenkinsConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ namespace Soloplan.WhatsON.Jenkins
using Soloplan.WhatsON.Jenkins.Model;
using Soloplan.WhatsON.Model;

[ConnectorType(ConnectorName, Description = "Retrieve the current status of a Jenkins project.")]
[ConnectorType(ConnectorName, ConnectorDisplayName, Description = "Retrieve the current status of a Jenkins project.")]
[ConfigurationItem(RedirectPlugin, typeof(bool), Priority = 400)] // defines use of Display URL API Plugin https://wiki.jenkins.io/display/JENKINS/Display+URL+API+Plugin
[NotificationConfigurationItem(NotificationsVisbility, typeof(ConnectorNotificationConfiguration), Priority = 1600000000)]
public class JenkinsConnector : Connector
{
public const string ConnectorName = "Jenkins";

/// <summary>
/// The redirect plugin tag.
/// </summary>
public const string ConnectorDisplayName = "Jenkins";

/// <summary>
/// The redirect plugin tag.
/// </summary>
public const string RedirectPlugin = "RedirectPlugin";

private const long TicksInMillisecond = 10000;
Expand Down
3 changes: 3 additions & 0 deletions src/Soloplan.WhatsON/Composition/ConnectorPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ protected ConnectorPlugin(Type connectorType)
}

this.Name = connectorTypeAttribute.Name;
this.DisplayName = connectorTypeAttribute.DisplayName;
this.Description = connectorTypeAttribute.Description;
}

public Type ConnectorType { get; }

public string Name { get; }

public string DisplayName { get; }

public string Description { get; }

public abstract Connector CreateNew(ConnectorConfiguration configuration);
Expand Down
9 changes: 9 additions & 0 deletions src/Soloplan.WhatsON/Composition/ConnectorTypeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,17 @@ public ConnectorTypeAttribute(string name)
this.Name = name;
}


public ConnectorTypeAttribute(string name, string displayName)
{
this.Name = name;
this.DisplayName = displayName;
}

public string Name { get; }

public string DisplayName { get; }

public string Description { get; set; }
}
}

0 comments on commit 4371fc9

Please sign in to comment.