Skip to content

Commit

Permalink
Show people who committed to current build in GUI.
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikgolda committed May 31, 2019
1 parent 1a84b02 commit 5a7b224
Show file tree
Hide file tree
Showing 11 changed files with 156 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<buildServer:BuildInformationIconControl.ToolTip>
<StackPanel>
<local:CCProgressBarTooltipControl DataContext="{Binding}" />
<buildServer:CulpritsControl DataContext="{Binding}" />
<buildServer:CulpritsControl Caption="Changes by:" CulpritsProp="{Binding DataContext.Culprits, RelativeSource={RelativeSource AncestorType=StackPanel}}" />
</StackPanel>
</buildServer:BuildInformationIconControl.ToolTip>
</buildServer:BuildInformationIconControl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<buildServer:HistoryBuildControl.ToolTip>
<StackPanel>
<buildServer:HistoryBuildTooltipControl DataContext="{Binding}" />
<buildServer:CulpritsControl DataContext="{Binding}" />
<buildServer:CulpritsControl Caption="Changes by:" CulpritsProp="{Binding DataContext.Culprits, RelativeSource={RelativeSource AncestorType=StackPanel}}" />
</StackPanel>
</buildServer:HistoryBuildControl.ToolTip>
</buildServer:HistoryBuildControl>
Expand All @@ -40,7 +40,7 @@
<buildServer:BuildInformationIconControl.ToolTip>
<StackPanel>
<buildServer:ProgressBarTooltipControl DataContext="{Binding}" />
<buildServer:CulpritsControl DataContext="{Binding}" />
<buildServer:CulpritsControl Caption="Changes by:" CulpritsProp="{Binding DataContext.Culprits, RelativeSource={RelativeSource AncestorType=StackPanel}}" />
</StackPanel>
</buildServer:BuildInformationIconControl.ToolTip>
</buildServer:BuildInformationIconControl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Soloplan.WhatsON.GUI.Common.BuildServer"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DataContext="{d:DesignInstance local:BuildStatusViewModel}"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<UserControl.Resources>
<local:CountToVisibilityConvrter x:Key="CountToVisibility" />
</UserControl.Resources>

<StackPanel Visibility="{Binding Culprits, Mode=OneWay, Converter={StaticResource CountToVisibility}}">
<StackPanel Visibility="{Binding CulpritsProp, Mode=OneWay, Converter={StaticResource CountToVisibility}}">
<TextBlock Text="---------------------------" />
<TextBlock Text="Changes by:" />
<ItemsControl ItemsSource="{Binding Culprits}">
<TextBlock Text="{Binding Caption}" />
<ItemsControl ItemsSource="{Binding CulpritsProp}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Soloplan.WhatsON.GUI.Common.BuildServer
{
using System.Collections;
using System.Windows;
using System.Windows.Controls;

Expand All @@ -15,11 +16,44 @@ namespace Soloplan.WhatsON.GUI.Common.BuildServer
/// </summary>
public partial class CulpritsControl : UserControl
{
/// <summary>
/// Dependency property for <see cref="CulpritsProp"/>.
/// </summary>
public static readonly DependencyProperty CulpritsPropProperty = DependencyProperty.Register(nameof(CulpritsProp), typeof(IList), typeof(CulpritsControl));

/// <summary>
/// Dependency property for <see cref="CulpritsProp"/>.
/// </summary>
public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register(nameof(Caption), typeof(string), typeof(CulpritsControl));

public CulpritsControl()
{
this.InitializeComponent();
var converter = this.Resources["CountToVisibility"] as CountToVisibilityConvrter;
converter.ValueForFalse = Visibility.Collapsed;
this.DataContext = this;
}

public IList CulpritsProp
{
get => (IList)this.GetValue(CulpritsPropProperty);
set => this.SetValue(CulpritsPropProperty, value);
}

public string Caption
{
get => (string)this.GetValue(CaptionProperty);
set => this.SetValue(CaptionProperty, value);
}

protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
if(e.Property.Name == nameof(this.CulpritsProp))
{

}

base.OnPropertyChanged(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public SubjectViewModel CreateViewModel()

public XmlReader GetDataTempletXaml()
{
return null;
return XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes(Properties.Resources.JenkinsProjectDataTemplate)));
}
}
}
58 changes: 58 additions & 0 deletions src/Soloplan.WhatsON.Jenkins.GUI/JenkinsProjectDataTemplate.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:buildServer="clr-namespace:Soloplan.WhatsON.GUI.Common.BuildServer;assembly=Soloplan.WhatsON.GUI.Common"
xmlns:gui="clr-namespace:Soloplan.WhatsON.Jenkins.GUI;assembly=Soloplan.WhatsON.Jenkins.GUI"
xmlns:subjectTreeView="clr-namespace:Soloplan.WhatsON.GUI.Common.SubjectTreeView;assembly=Soloplan.WhatsON.GUI.Common">

<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
<subjectTreeView:StatusToColorConverter x:Key="StatusToColorConverter" />
<subjectTreeView:TimeToAproximateTimeConverter x:Key="TimeToAproximateTimeConverter" />
<!-- ToDo DGO: this should be separate control for displaying status. This way it will be easier to reuse. -->

<ContextMenu x:Key="BuildServerProjectContextMenu">
<!-- CommandParameter must be declared before Command or else value from previous opening of context menu will be passed. WTF?! -->
<MenuItem Header="Open project web page"
CommandParameter="{Binding OpenWebPageParam}"
Command="{Binding OpenWebPage}" />
<MenuItem Header="Open current build page"
Visibility="{Binding CurrentStatus.Building, Converter={StaticResource BoolToVisibility}}"
CommandParameter="{Binding CurrentStatus.OpenBuildPageCommandData}"
Command="{Binding CurrentStatus.OpenBuildPage}" />

</ContextMenu>
<DataTemplate DataType="{x:Type gui:JenkinsStatusViewModel}">
<buildServer:HistoryBuildControl DataContext="{Binding}">
<buildServer:HistoryBuildControl.ToolTip>
<StackPanel>
<buildServer:HistoryBuildTooltipControl DataContext="{Binding}" />
<StackPanel Visibility="{Binding CulpritsAndLastCommittedDifferent, Converter={StaticResource BoolToVisibility}}">
<buildServer:CulpritsControl Caption="Commits by:" CulpritsProp="{Binding DataContext.CommittedToThisBuild, RelativeSource={RelativeSource AncestorType=StackPanel}}" />
</StackPanel>
<buildServer:CulpritsControl Caption="All culprits for this build:" CulpritsProp="{Binding DataContext.Culprits, RelativeSource={RelativeSource AncestorType=StackPanel}}" />
</StackPanel>
</buildServer:HistoryBuildControl.ToolTip>
</buildServer:HistoryBuildControl>
</DataTemplate>

<DataTemplate DataType="{x:Type gui:JenkinsProjectViewModel}">
<StackPanel ContextMenu="{StaticResource BuildServerProjectContextMenu}" Orientation="Horizontal">
<buildServer:BuildInformationIconControl DataContext="{Binding CurrentStatus}">
<buildServer:BuildInformationIconControl.ToolTip>
<StackPanel>
<buildServer:ProgressBarTooltipControl DataContext="{Binding}" />
<StackPanel Visibility="{Binding CulpritsAndLastCommittedDifferent, Converter={StaticResource BoolToVisibility}}">
<buildServer:CulpritsControl Caption="Commits by:" CulpritsProp="{Binding DataContext.CommittedToThisBuild, RelativeSource={RelativeSource AncestorType=StackPanel}}" />
</StackPanel>
<buildServer:CulpritsControl Caption="All culprits for this build:" CulpritsProp="{Binding DataContext.Culprits, RelativeSource={RelativeSource AncestorType=StackPanel}}" />
</StackPanel>
</buildServer:BuildInformationIconControl.ToolTip>
</buildServer:BuildInformationIconControl>
<TextBlock Text=" " />
<TextBlock Text="{Binding Name}" />
<TextBlock Text=" #" />
<TextBlock Text="{Binding CurrentStatus.BuildNumber}" />
<TextBlock Text=" " />
<buildServer:HistoryBuildList DataContext="{Binding SubjectSnapshots, Mode=OneWay}" />
</StackPanel>
</DataTemplate>
</ResourceDictionary>
35 changes: 33 additions & 2 deletions src/Soloplan.WhatsON.Jenkins.GUI/JenkinsStatusViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@
namespace Soloplan.WhatsON.Jenkins.GUI
{
using System;
using System.Collections.ObjectModel;
using System.Linq;
using Soloplan.WhatsON.GUI.Common.BuildServer;
using Soloplan.WhatsON.Jenkins.Model;

class JenkinsStatusViewModel : BuildStatusViewModel
public class JenkinsStatusViewModel : BuildStatusViewModel
{
private OpenJenkinsWebPageCommandData parentCommandData;

private ObservableCollection<JenkinsCulpritViewModel> committedToThisBuild;

private bool culpritsAndLastCommittedDifferent;

public JenkinsStatusViewModel(JenkinsProjectViewModel model)
: base(model)
{
Expand All @@ -36,6 +43,21 @@ public override OpenWebPageCommandData OpenBuildPageCommandData
}
}

public bool CulpritsAndLastCommittedDifferent
{
get => this.culpritsAndLastCommittedDifferent;
set
{
if (this.culpritsAndLastCommittedDifferent != value)
{
this.culpritsAndLastCommittedDifferent = value;
this.OnPropertyChanged();
}
}
}

public ObservableCollection<JenkinsCulpritViewModel> CommittedToThisBuild => this.committedToThisBuild ?? (this.committedToThisBuild = new ObservableCollection<JenkinsCulpritViewModel>());

public override void Update(Status newStatus)
{
base.Update(newStatus);
Expand All @@ -62,14 +84,23 @@ public override void Update(Status newStatus)
this.RawProgres = 0;
}

this.Culprits.Clear();
this.CommittedToThisBuild.Clear();
foreach (var culprit in jenkinsStatus.Culprits)
{
var culpritModle = new JenkinsCulpritViewModel();
culpritModle.Init(culprit);
this.Culprits.Add(culpritModle);
}

foreach (var culprit in jenkinsStatus.CommittedToThisBuild ?? Enumerable.Empty<Culprit>())
{
var culpritModle = new JenkinsCulpritViewModel();
culpritModle.Init(culprit);
this.CommittedToThisBuild.Add(culpritModle);
}

this.CulpritsAndLastCommittedDifferent = this.Culprits.Count != this.CommittedToThisBuild.Count || this.Culprits.Any(culprit => this.CommittedToThisBuild.All(committer => committer.FullName != culprit.FullName));

this.UpdateCalculatedFields();
}

Expand Down
14 changes: 14 additions & 0 deletions src/Soloplan.WhatsON.Jenkins.GUI/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Soloplan.WhatsON.Jenkins.GUI/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="JenkinsProjectDataTemplate" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\jenkinsprojectdatatemplate.xaml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@
<Version>4.6.2</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Resource Include="JenkinsProjectDataTemplate.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Resource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\config\Soloplan.WhatsON.targets" />
<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Soloplan.WhatsON.Jenkins/JenkinsProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private static JenkinsStatus CreateStatus(JenkinsBuild latestBuild)
newStatus.EstimatedDurationInMs = latestBuild.EstimatedDuration;
newStatus.Culprits = latestBuild.Culprits;

newStatus.CommittedToThisBuild = latestBuild.ChangeSets.SelectMany(p => p.ChangeSetItems)
newStatus.CommittedToThisBuild = latestBuild.ChangeSets?.SelectMany(p => p.ChangeSetItems)
.Select(p => p.Author)
.GroupBy(p => p.FullName)
.Select(p => p.FirstOrDefault())
Expand Down

0 comments on commit 5a7b224

Please sign in to comment.