Skip to content

Commit

Permalink
PR: Add global count (#97)
Browse files Browse the repository at this point in the history
Let's allow for a global PR count like we do for work items.

This allows for easily checking the PRs that are assigned to you, needs action or whatever.
  • Loading branch information
supermem613 authored May 15, 2023
1 parent e34f31e commit f818e18
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn>467;618</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<NoWarn>467;618</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
Expand Down
28 changes: 14 additions & 14 deletions Source/TeamMate.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31410.357
# Visual Studio Version 17
VisualStudioVersion = 17.5.33627.172
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{04FA9F2B-E302-475F-B060-79D22E9C2D15}"
EndProject
Expand Down Expand Up @@ -57,16 +57,16 @@ Global
{01FCF244-D4B2-43DD-BB77-9D4946868299}.Release|x64.Build.0 = Release|x64
{01FCF244-D4B2-43DD-BB77-9D4946868299}.Release|x86.ActiveCfg = Release|Any CPU
{01FCF244-D4B2-43DD-BB77-9D4946868299}.Release|x86.Build.0 = Release|Any CPU
{1967369E-0368-4888-B743-B16ABAE28B1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1967369E-0368-4888-B743-B16ABAE28B1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1967369E-0368-4888-B743-B16ABAE28B1F}.Debug|Any CPU.ActiveCfg = Debug|x64
{1967369E-0368-4888-B743-B16ABAE28B1F}.Debug|Any CPU.Build.0 = Debug|x64
{1967369E-0368-4888-B743-B16ABAE28B1F}.Debug|ARM.ActiveCfg = Debug|Any CPU
{1967369E-0368-4888-B743-B16ABAE28B1F}.Debug|ARM.Build.0 = Debug|Any CPU
{1967369E-0368-4888-B743-B16ABAE28B1F}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{1967369E-0368-4888-B743-B16ABAE28B1F}.Debug|ARM64.Build.0 = Debug|Any CPU
{1967369E-0368-4888-B743-B16ABAE28B1F}.Debug|x64.ActiveCfg = Debug|x64
{1967369E-0368-4888-B743-B16ABAE28B1F}.Debug|x64.Build.0 = Debug|x64
{1967369E-0368-4888-B743-B16ABAE28B1F}.Debug|x86.ActiveCfg = Debug|Any CPU
{1967369E-0368-4888-B743-B16ABAE28B1F}.Debug|x86.Build.0 = Debug|Any CPU
{1967369E-0368-4888-B743-B16ABAE28B1F}.Debug|x86.ActiveCfg = Debug|x64
{1967369E-0368-4888-B743-B16ABAE28B1F}.Debug|x86.Build.0 = Debug|x64
{1967369E-0368-4888-B743-B16ABAE28B1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1967369E-0368-4888-B743-B16ABAE28B1F}.Release|Any CPU.Build.0 = Release|Any CPU
{1967369E-0368-4888-B743-B16ABAE28B1F}.Release|ARM.ActiveCfg = Release|Any CPU
Expand All @@ -77,16 +77,16 @@ Global
{1967369E-0368-4888-B743-B16ABAE28B1F}.Release|x64.Build.0 = Release|x64
{1967369E-0368-4888-B743-B16ABAE28B1F}.Release|x86.ActiveCfg = Release|Any CPU
{1967369E-0368-4888-B743-B16ABAE28B1F}.Release|x86.Build.0 = Release|Any CPU
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Debug|Any CPU.ActiveCfg = Debug|x64
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Debug|Any CPU.Build.0 = Debug|x64
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Debug|ARM.ActiveCfg = Debug|Any CPU
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Debug|ARM.Build.0 = Debug|Any CPU
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Debug|ARM64.Build.0 = Debug|Any CPU
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Debug|x64.ActiveCfg = Debug|x64
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Debug|x64.Build.0 = Debug|x64
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Debug|x86.ActiveCfg = Debug|Any CPU
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Debug|x86.Build.0 = Debug|Any CPU
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Debug|x86.ActiveCfg = Debug|x64
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Debug|x86.Build.0 = Debug|x64
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Release|Any CPU.Build.0 = Release|Any CPU
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Release|ARM.ActiveCfg = Release|Any CPU
Expand All @@ -97,16 +97,16 @@ Global
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Release|x64.Build.0 = Release|x64
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Release|x86.ActiveCfg = Release|Any CPU
{5BB3A276-4460-4C5F-B842-42E4618DD034}.Release|x86.Build.0 = Release|Any CPU
{888E7687-95F8-4049-94DF-9DD3398B5592}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{888E7687-95F8-4049-94DF-9DD3398B5592}.Debug|Any CPU.Build.0 = Debug|Any CPU
{888E7687-95F8-4049-94DF-9DD3398B5592}.Debug|Any CPU.ActiveCfg = Debug|x64
{888E7687-95F8-4049-94DF-9DD3398B5592}.Debug|Any CPU.Build.0 = Debug|x64
{888E7687-95F8-4049-94DF-9DD3398B5592}.Debug|ARM.ActiveCfg = Debug|Any CPU
{888E7687-95F8-4049-94DF-9DD3398B5592}.Debug|ARM.Build.0 = Debug|Any CPU
{888E7687-95F8-4049-94DF-9DD3398B5592}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{888E7687-95F8-4049-94DF-9DD3398B5592}.Debug|ARM64.Build.0 = Debug|Any CPU
{888E7687-95F8-4049-94DF-9DD3398B5592}.Debug|x64.ActiveCfg = Debug|x64
{888E7687-95F8-4049-94DF-9DD3398B5592}.Debug|x64.Build.0 = Debug|x64
{888E7687-95F8-4049-94DF-9DD3398B5592}.Debug|x86.ActiveCfg = Debug|Any CPU
{888E7687-95F8-4049-94DF-9DD3398B5592}.Debug|x86.Build.0 = Debug|Any CPU
{888E7687-95F8-4049-94DF-9DD3398B5592}.Debug|x86.ActiveCfg = Debug|x64
{888E7687-95F8-4049-94DF-9DD3398B5592}.Debug|x86.Build.0 = Debug|x64
{888E7687-95F8-4049-94DF-9DD3398B5592}.Release|Any CPU.ActiveCfg = Release|Any CPU
{888E7687-95F8-4049-94DF-9DD3398B5592}.Release|Any CPU.Build.0 = Release|Any CPU
{888E7687-95F8-4049-94DF-9DD3398B5592}.Release|ARM.ActiveCfg = Release|Any CPU
Expand Down
3 changes: 3 additions & 0 deletions Source/TeamMate/Controls/TileCollectionView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
<MenuItem Header="Show _Notifications"
IsCheckable="True"
IsChecked="{Binding ShowNotifications}" />
<MenuItem Header="_Include In Global Pull Request Count"
IsCheckable="True"
IsChecked="{Binding IncludeInItemCountSummary}" />
<Separator />
<MenuItem Header="Select _Background Color"
Command="{x:Static tmr:TeamMateCommands.SelectTileBackgroundColor}"
Expand Down
3 changes: 3 additions & 0 deletions Source/TeamMate/Model/ItemCountSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ public ItemCountSummary()
this.ResolvedCounter = new Counter();
this.ClosedCounter = new Counter();
this.UnknownCounter = new Counter();
this.PullRequestsCounter = new Counter();
}

public Counter GlobalCounter { get; private set; }
public Counter ActiveCounter { get; private set; }
public Counter ResolvedCounter { get; private set; }
public Counter ClosedCounter { get; private set; }
public Counter UnknownCounter { get; private set; }
public Counter PullRequestsCounter { get; private set; }

internal void Reset()
{
Expand All @@ -24,6 +26,7 @@ internal void Reset()
this.ResolvedCounter.Reset();
this.ClosedCounter.Reset();
this.UnknownCounter.Reset();
this.PullRequestsCounter.Reset();
}
}
}
Binary file added Source/TeamMate/Resources/Icons/Bugger/BlueGift.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions Source/TeamMate/Resources/SampleData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class SampleData
public static readonly Uri SampleProjectUri = new Uri("vstfs:///Classification/TeamProject/D31BE5FA-E206-4B4A-B0B8-667071942520");
public const string SampleQueryPath = @"My Queries\Sandbox Team - Sprint 1 - Backlog";

private static Random Random = new Random();
private static readonly Random Random = new Random();

private static WorkItemQueryTileViewModel workItemQueryTileViewModel;
private static MainWindowViewModel mainWindowViewModel;
Expand Down Expand Up @@ -51,8 +51,10 @@ public static SearchPageViewModel SearchPageViewModel
{
if (searchPageViewModel == null)
{
searchPageViewModel = new SearchPageViewModel();
searchPageViewModel.SearchText = "crashing bugs";
searchPageViewModel = new SearchPageViewModel()
{
SearchText = "crashing bugs"
};
}

return searchPageViewModel;
Expand Down Expand Up @@ -361,6 +363,7 @@ public static ItemCountSummary ItemCountSummary
itemCountSummary = new ItemCountSummary();
itemCountSummary.ActiveCounter.UpdateCount(11, true);
itemCountSummary.ResolvedCounter.UpdateCount(22, false);
itemCountSummary.PullRequestsCounter.UpdateCount(13, false);
}

return itemCountSummary;
Expand Down
3 changes: 2 additions & 1 deletion Source/TeamMate/TeamMate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons\Bugger\GreenGift.png" />
<Resource Include="Resources\Icons\Other\RedDelete_16.png" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -967,7 +968,6 @@
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons\Bugger\GrayGift.png" />
<Resource Include="Resources\Icons\Bugger\GreenGift.png" />
<Resource Include="Resources\Icons\Bugger\RedGift.png" />
<Resource Include="Resources\Icons\Bugger\YellowGift.png" />
<Resource Include="Resources\Icons\Office15\CheckmarkCompleted.16x16x32.png" />
Expand All @@ -984,6 +984,7 @@
<None Include="Resources\Xml\Samples\Discussion.xml" />
<None Include="Resources\Xml\Samples\WorkItemCollection.xml" />
<None Include="Resources\Fonts\Bowtie.readme.txt" />
<Resource Include="Resources\Icons\Bugger\BlueGift.png" />
<Content Include="TeamMate.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Microsoft.Tools.TeamMate.ViewModels
{
public class PullRequestQueryTileViewModel : TileViewModel
{
private PullRequestQueryViewModel QueryModel
public PullRequestQueryViewModel QueryModel
{
get { return this.Query as PullRequestQueryViewModel; }
}
Expand Down
45 changes: 34 additions & 11 deletions Source/TeamMate/ViewModels/TileCollectionViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,24 @@ private void InvalidateItemCountSummary()
{
lock (invalidateItemCountSummaryLock)
{
var allWorkItems = GetItemsTowardsCount();
var workItemsByState = allWorkItems.GroupBy(wi => wi.WorkItemState).ToDictionary(g => g.Key, g => g.ToArray());

var summary = this.ItemCountSummary;
UpdateCounter(summary.GlobalCounter, allWorkItems);
UpdateCounter(summary.ActiveCounter, workItemsByState.TryGetValueOrDefault(WorkItemState.Active));
UpdateCounter(summary.ResolvedCounter, workItemsByState.TryGetValueOrDefault(WorkItemState.Resolved));
UpdateCounter(summary.ClosedCounter, workItemsByState.TryGetValueOrDefault(WorkItemState.Closed));
UpdateCounter(summary.UnknownCounter, workItemsByState.TryGetValueOrDefault(WorkItemState.Unknown));
{
var allWorkItems = GetWorkItemsTowardsCount();
var workItemsByState = allWorkItems.GroupBy(wi => wi.WorkItemState).ToDictionary(g => g.Key, g => g.ToArray());

var summary = this.ItemCountSummary;
UpdateCounter(summary.GlobalCounter, allWorkItems);
UpdateCounter(summary.ActiveCounter, workItemsByState.TryGetValueOrDefault(WorkItemState.Active));
UpdateCounter(summary.ResolvedCounter, workItemsByState.TryGetValueOrDefault(WorkItemState.Resolved));
UpdateCounter(summary.ClosedCounter, workItemsByState.TryGetValueOrDefault(WorkItemState.Closed));
UpdateCounter(summary.UnknownCounter, workItemsByState.TryGetValueOrDefault(WorkItemState.Unknown));
}
{
var allPullRequests = GetPullRequestsTowardsCount();
var pullRequestsByState = allPullRequests.GroupBy(wi => wi.IsRead).ToDictionary(g => g.Key, g => g.ToArray());

var summary = this.ItemCountSummary;
UpdateCounter(summary.PullRequestsCounter, pullRequestsByState.TryGetValueOrDefault(false));
}
}
}
catch (Exception e)
Expand All @@ -181,15 +190,29 @@ private static void UpdateCounter(Counter counter, ICollection<WorkItemRowViewMo

counter.UpdateCount(count, isRead);
}
private static void UpdateCounter(Counter counter, ICollection<PullRequestRowViewModel> items)
{
// items can be null by design, it is an optimization if there are no items
int count = (items != null) ? items.Count : 0;
bool isRead = (items != null) ? !items.Any(wi => !wi.IsRead) : true;

counter.UpdateCount(count, isRead);
}

private IList<WorkItemRowViewModel> GetItemsTowardsCount()
private IList<WorkItemRowViewModel> GetWorkItemsTowardsCount()
{
// TODO: Get PullRequests too? How do these surface in the UI?
var allWorkItems = Tiles.OfType<WorkItemQueryTileViewModel>().Where(wiq => wiq.IncludeInItemCountSummary)
.Select(q => q.WorkItemQuery.WorkItems).Where(items => items != null).SelectMany(w => w).Distinct().ToArray();

return allWorkItems;
}
private IList<PullRequestRowViewModel> GetPullRequestsTowardsCount()
{
var allPullRequests = Tiles.OfType<PullRequestQueryTileViewModel>().Where(wiq => wiq.IncludeInItemCountSummary)
.Select(q => q.QueryModel.PullRequests).Where(items => items != null).SelectMany(w => w).Distinct().ToArray();

return allPullRequests;
}

private TileViewModel CreateTileViewModel(TileInfo tileInfo)
{
Expand Down
4 changes: 2 additions & 2 deletions Source/TeamMate/ViewModels/TileViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public TileInfo TileInfo

// On purpose not use the property as we don't want to fire an event here. Also, do this before creating
// the query!
this.showNotifications = (this.TileInfo != null) ? this.tileInfo.ShowNotifications : false;
this.includeInItemCountSummary = (this.TileInfo != null) ? this.tileInfo.IncludeInItemCountSummary : false;
this.showNotifications = this.TileInfo != null && this.tileInfo.ShowNotifications;
this.includeInItemCountSummary = this.TileInfo != null && this.tileInfo.IncludeInItemCountSummary;
this.backgroundColor = this.GetBackgroundColor();
this.isDefaultBackgroundColor = this.IsDefaultBackColor();
this.fontColor = this.GetFontColor();
Expand Down
6 changes: 6 additions & 0 deletions Source/TeamMate/Windows/OverviewWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
Image="/Resources/Icons/Bugger/GreenGift.png"
Visibility="{Binding HasCountGreaterThanZero,
Converter={x:Static fwc:Converters.Visibility}}" />
<tmc:ItemCountView Margin="0,1,1,1"
Brush="#00A2E8"
DataContext="{Binding PullRequestsCounter}"
Image="/Resources/Icons/Bugger/BlueGift.png"
Visibility="{Binding HasCountGreaterThanZero,
Converter={x:Static fwc:Converters.Visibility}}" />
<tmc:ItemCountView Margin="0,1,1,1"
Brush="#DFDFDF"
DataContext="{Binding UnknownCounter}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<NoWarn>467;618</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
Expand Down

0 comments on commit f818e18

Please sign in to comment.