Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 9a74b7f

Browse files
authored
Merge branch 'master' into fixes/1812-VisualStudio-Threading-15.0
2 parents 84f8903 + d3641f4 commit 9a74b7f

File tree

44 files changed

+907
-77
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+907
-77
lines changed

src/GitHub.App/GitHub.App.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
<HintPath>..\..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
198198
</Reference>
199199
<Reference Include="System.Web" />
200+
<Reference Include="System.Windows.Forms" />
200201
<Reference Include="System.Xaml" />
201202
<Reference Include="System.Xml.Linq" />
202203
<Reference Include="System.Data.DataSetExtensions" />
@@ -257,6 +258,7 @@
257258
<Compile Include="ViewModels\GitHubPane\LoggedOutViewModel.cs" />
258259
<Compile Include="ViewModels\GitHubPane\NavigationViewModel.cs" />
259260
<Compile Include="ViewModels\GitHubPane\GitHubPaneViewModel.cs" />
261+
<Compile Include="SampleData\PullRequestCheckViewModelDesigner.cs" />
260262
<Compile Include="ViewModels\GitHubPane\PullRequestFilesViewModel.cs" />
261263
<Compile Include="ViewModels\GitHubPane\PullRequestListItemViewModel.cs" />
262264
<Compile Include="ViewModels\GitHubPane\PullRequestListViewModel.cs" />
@@ -267,6 +269,7 @@
267269
<Compile Include="ViewModels\GitHubPane\NotAGitRepositoryViewModel.cs" />
268270
<Compile Include="ViewModels\GitHubPane\PullRequestReviewAuthoringViewModel.cs" />
269271
<Compile Include="ViewModels\GitHubPane\PullRequestReviewCommentViewModel.cs" />
272+
<Compile Include="ViewModels\GitHubPane\PullRequestCheckViewModel.cs" />
270273
<Compile Include="ViewModels\GitHubPane\PullRequestReviewSummaryViewModel.cs" />
271274
<Compile Include="ViewModels\GitHubPane\PullRequestReviewViewModel.cs" />
272275
<Compile Include="ViewModels\GitHubPane\PullRequestUserReviewsViewModel.cs" />

src/GitHub.App/Resources.Designer.cs

Lines changed: 21 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/GitHub.App/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,4 +321,10 @@ https://git-scm.com/download/win</value>
321321
<data name="SwitchOriginTitle" xml:space="preserve">
322322
<value>Switch Origin</value>
323323
</data>
324+
<data name="CancelPendingReviewConfirmation" xml:space="preserve">
325+
<value>Are you sure you want to cancel this review? You will lose all your pending comments.</value>
326+
</data>
327+
<data name="CancelPendingReviewConfirmationCaption" xml:space="preserve">
328+
<value>Cancel Review</value>
329+
</data>
324330
</root>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Windows.Media.Imaging;
3+
using GitHub.ViewModels;
4+
using GitHub.ViewModels.GitHubPane;
5+
using ReactiveUI;
6+
7+
namespace GitHub.SampleData
8+
{
9+
public sealed class PullRequestCheckViewModelDesigner : ViewModelBase, IPullRequestCheckViewModel
10+
{
11+
public string Title { get; set; } = "continuous-integration/appveyor/pr";
12+
13+
public string Description { get; set; } = "AppVeyor build failed";
14+
15+
public PullRequestCheckStatus Status { get; set; } = PullRequestCheckStatus.Failure;
16+
17+
public Uri DetailsUrl { get; set; } = new Uri("http://github.com");
18+
19+
public string AvatarUrl { get; set; } = "https://avatars1.githubusercontent.com/u/417571?s=88&v=4";
20+
21+
public BitmapImage Avatar { get; set; } = null;
22+
23+
public ReactiveCommand<object> OpenDetailsUrl { get; set; } = null;
24+
}
25+
}

src/GitHub.App/SampleData/PullRequestDetailViewModelDesigner.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Diagnostics.CodeAnalysis;
4-
using System.Reactive;
5-
using System.Text;
6-
using System.Threading.Tasks;
71
using GitHub.Models;
82
using GitHub.Services;
93
using GitHub.ViewModels;
104
using GitHub.ViewModels.GitHubPane;
115
using ReactiveUI;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.Diagnostics.CodeAnalysis;
9+
using System.Reactive;
10+
using System.Threading.Tasks;
11+
using GitHub.SampleData;
1212

1313
namespace GitHub.SampleData
1414
{
@@ -95,6 +95,8 @@ public PullRequestDetailViewModelDesigner()
9595
};
9696

9797
Files = new PullRequestFilesViewModelDesigner();
98+
99+
Checks = new PullRequestCheckViewModelDesigner[0];
98100
}
99101

100102
public PullRequestDetailModel Model { get; }
@@ -123,6 +125,8 @@ public PullRequestDetailViewModelDesigner()
123125
public ReactiveCommand<object> OpenOnGitHub { get; }
124126
public ReactiveCommand<object> ShowReview { get; }
125127

128+
public IReadOnlyList<IPullRequestCheckViewModel> Checks { get; }
129+
126130
public Task InitializeAsync(ILocalRepositoryModel localRepository, IConnection connection, string owner, string repo, int number) => Task.CompletedTask;
127131

128132
public string GetLocalFilePath(IPullRequestFileNode file)

src/GitHub.App/SampleData/PullRequestListItemViewModelDesigner.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Diagnostics.CodeAnalysis;
4+
using GitHub.Models;
45
using GitHub.ViewModels;
56
using GitHub.ViewModels.GitHubPane;
67

@@ -16,5 +17,6 @@ public class PullRequestListItemViewModelDesigner : ViewModelBase, IPullRequestL
1617
public int Number { get; set; }
1718
public string Title { get; set; }
1819
public DateTimeOffset UpdatedAt { get; set; }
20+
public PullRequestChecksState Checks { get; set; }
1921
}
2022
}

src/GitHub.App/Services/DialogService.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,19 @@ public async Task<string> ShowReCloneDialog(IRepositoryModel repository)
5151
return (string)await showDialog.ShowWithFirstConnection(viewModel);
5252
}
5353

54-
public async Task ShowCreateGist()
54+
public async Task ShowCreateGist(IConnection connection)
5555
{
5656
var viewModel = factory.CreateViewModel<IGistCreationViewModel>();
57-
await showDialog.ShowWithFirstConnection(viewModel);
57+
58+
if (connection != null)
59+
{
60+
await viewModel.InitializeAsync(connection);
61+
await showDialog.Show(viewModel);
62+
}
63+
else
64+
{
65+
await showDialog.ShowWithFirstConnection(viewModel);
66+
}
5867
}
5968

6069
public async Task ShowCreateRepositoryDialog(IConnection connection)

src/GitHub.App/Services/PullRequestService.cs

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Text;
1212
using System.Text.RegularExpressions;
1313
using System.Threading.Tasks;
14+
using System.Windows.Forms;
1415
using GitHub.Api;
1516
using GitHub.Extensions;
1617
using GitHub.Logging;
@@ -22,6 +23,7 @@
2223
using Rothko;
2324
using static System.FormattableString;
2425
using static Octokit.GraphQL.Variable;
26+
using StatusState = GitHub.Models.StatusState;
2527

2628
namespace GitHub.Services
2729
{
@@ -93,6 +95,17 @@ public async Task<Page<PullRequestListItemModel>> ReadPullRequests(
9395
Items = page.Nodes.Select(pr => new ListItemAdapter
9496
{
9597
Id = pr.Id.Value,
98+
LastCommit = pr.Commits(null, null, 1, null).Nodes.Select(commit =>
99+
new LastCommitSummaryModel
100+
{
101+
Statuses = commit.Commit.Status
102+
.Select(context =>
103+
context.Contexts.Select(statusContext => new StatusSummaryModel
104+
{
105+
State = (StatusState)statusContext.State,
106+
}).ToList()
107+
).SingleOrDefault()
108+
}).ToList().FirstOrDefault(),
96109
Author = new ActorModel
97110
{
98111
Login = pr.Author.Login,
@@ -123,10 +136,46 @@ public async Task<Page<PullRequestListItemModel>> ReadPullRequests(
123136

124137
var result = await graphql.Run(readPullRequests, vars);
125138

126-
foreach (ListItemAdapter item in result.Items)
139+
foreach (var item in result.Items.Cast<ListItemAdapter>())
127140
{
128141
item.CommentCount += item.Reviews.Sum(x => x.Count);
129142
item.Reviews = null;
143+
144+
var hasStatuses = item.LastCommit.Statuses != null
145+
&& item.LastCommit.Statuses.Any();
146+
147+
if (!hasStatuses)
148+
{
149+
item.Checks = PullRequestChecksState.None;
150+
}
151+
else
152+
{
153+
var statusHasFailure = item.LastCommit
154+
.Statuses
155+
.Any(status => status.State == StatusState.Failure);
156+
157+
var statusHasCompleteSuccess = true;
158+
if (!statusHasFailure)
159+
{
160+
statusHasCompleteSuccess =
161+
item.LastCommit.Statuses.All(status => status.State == StatusState.Success);
162+
}
163+
164+
if (statusHasFailure)
165+
{
166+
item.Checks = PullRequestChecksState.Failure;
167+
}
168+
else if (statusHasCompleteSuccess)
169+
{
170+
item.Checks = PullRequestChecksState.Success;
171+
}
172+
else
173+
{
174+
item.Checks = PullRequestChecksState.Pending;
175+
}
176+
}
177+
178+
item.LastCommit = null;
130179
}
131180

132181
return result;
@@ -666,6 +715,16 @@ public IObservable<Unit> RemoveUnusedRemotes(ILocalRepositoryModel repository)
666715
});
667716
}
668717

718+
/// <inheritdoc />
719+
public bool ConfirmCancelPendingReview()
720+
{
721+
return MessageBox.Show(
722+
GitHub.App.Resources.CancelPendingReviewConfirmation,
723+
GitHub.App.Resources.CancelPendingReviewConfirmationCaption,
724+
MessageBoxButtons.YesNo,
725+
MessageBoxIcon.Question) == DialogResult.Yes;
726+
}
727+
669728
async Task<string> CreateRemote(IRepository repo, UriString cloneUri)
670729
{
671730
foreach (var remote in repo.Network.Remotes)
@@ -840,6 +899,8 @@ static Tuple<string, int> ParseGHfVSConfigKeyValue(string value)
840899
class ListItemAdapter : PullRequestListItemModel
841900
{
842901
public IList<ReviewAdapter> Reviews { get; set; }
902+
903+
public LastCommitSummaryModel LastCommit { get; set; }
843904
}
844905

845906
class ReviewAdapter
@@ -848,5 +909,15 @@ class ReviewAdapter
848909
public int CommentCount { get; set; }
849910
public int Count => CommentCount + (!string.IsNullOrWhiteSpace(Body) ? 1 : 0);
850911
}
912+
913+
class StatusSummaryModel
914+
{
915+
public StatusState State { get; set; }
916+
}
917+
918+
class LastCommitSummaryModel
919+
{
920+
public List<StatusSummaryModel> Statuses { get; set; }
921+
}
851922
}
852923
}

0 commit comments

Comments
 (0)