Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
d1d60ff
Attempting to query all Check Suites with Pull Requests
StanleyGoldman Jul 12, 2018
bfd6bfb
Trying to get a Check and Status summary
StanleyGoldman Jul 13, 2018
8622f21
Experimenting with ways to get the data via GraphQL
StanleyGoldman Jul 17, 2018
518c8c0
Updating nuget package
StanleyGoldman Jul 17, 2018
c3d3b1c
Adding models
StanleyGoldman Jul 17, 2018
047ba1a
Adding pull request summary state to the list
StanleyGoldman Jul 19, 2018
ae00f33
Merge branch 'master' into stanley/check-suites-pull-request-model-1
StanleyGoldman Jul 19, 2018
c6cd36f
We're three columns now
donokuda Jul 20, 2018
eb575e6
Move comment count and status into its own column
donokuda Jul 20, 2018
756e733
Set a minimum width
donokuda Jul 20, 2018
389d49a
Right align pull request status and comment count
donokuda Jul 20, 2018
9c60db1
Functionality to display Checks on PullRequestDetailView
StanleyGoldman Jul 23, 2018
2405755
Restrain the size of the CheckRun display until it gets proper designs
StanleyGoldman Jul 24, 2018
42bb263
Adding a Hyperlink
StanleyGoldman Jul 24, 2018
533506f
Merge branch 'master' into stanley/check-suites-pull-request-model-1
StanleyGoldman Jul 24, 2018
42fbab6
Separating models
StanleyGoldman Jul 24, 2018
b086078
Removing functionality to read CheckSuites
StanleyGoldman Jul 24, 2018
bade798
Code cleanup
StanleyGoldman Jul 24, 2018
6d4c4ca
Add a bit of spacing
donokuda Jul 25, 2018
e7e26d9
Attempting to open up a browser link
StanleyGoldman Jul 25, 2018
2f3e739
Merge pull request #1793 from github/donokuda/check-suites-polish
StanleyGoldman Jul 25, 2018
2236973
Changing column order
StanleyGoldman Jul 25, 2018
10b1fdd
Correcting functionality to open the browser
StanleyGoldman Jul 25, 2018
7107bdc
Merge branch 'master' into stanley/check-suites-pull-request-model-1
StanleyGoldman Jul 25, 2018
4074fea
Add missing argument
StanleyGoldman Jul 26, 2018
5a7775c
Adjust some row/column definitions
donokuda Jul 26, 2018
9c6c5da
make the avatar smaller
donokuda Jul 26, 2018
276549b
Hide this description
donokuda Jul 26, 2018
5c2c0f7
Use the primitive dot octicon for pending checks
donokuda Jul 26, 2018
5edce94
Add a lil' bit of right margin
donokuda Jul 26, 2018
af979f2
Merge branch 'master' into stanley/check-suites-pull-request-model-1
StanleyGoldman Jul 26, 2018
9db38a9
Try out a GridView
donokuda Jul 30, 2018
d279d06
Use IsSharedSizeScope so that Grid Rendering works
donokuda Jul 30, 2018
86b3942
Remove extra line
donokuda Jul 30, 2018
b0cdcf0
Fix text color for dark theme
donokuda Jul 30, 2018
7ced79b
Merge pull request #1813 from github/donokuda/polish-check-details
StanleyGoldman Jul 31, 2018
967e91d
Adding metrics to the UsageTracker
StanleyGoldman Jul 31, 2018
e890055
Hiding Status Avatars until we get a way to query them through the Gr…
StanleyGoldman Aug 1, 2018
0974944
Merge branch 'master' into stanley/check-suites-pull-request-model-1
StanleyGoldman Aug 1, 2018
b45bcc8
Attempting to use the view locator correctly
StanleyGoldman Jul 26, 2018
5c2b93c
Merge pull request #1808 from github/view-locator-tears
StanleyGoldman Aug 2, 2018
035915d
Merge branch 'master' into stanley/check-suites-pull-request-model-1
StanleyGoldman Aug 6, 2018
ee83908
Merge branch 'master' into stanley/check-suites-pull-request-model-1
grokys Aug 7, 2018
2b8cee3
Removing Checks from PullRequestModel
StanleyGoldman Aug 7, 2018
f964972
Making StatusSummaryModel an inner class
StanleyGoldman Aug 7, 2018
14d5eca
Merge branch 'master' into stanley/check-suites-pull-request-model-1
StanleyGoldman Aug 7, 2018
a026bab
Making properties of PullRequestCheckViewModel read only
StanleyGoldman Aug 7, 2018
6a6c565
Making member readonly
StanleyGoldman Aug 7, 2018
cfa7c20
Renaming PullRequestCheckStatusEnum
StanleyGoldman Aug 7, 2018
35ba4b2
Renaming PullRequestChecksEnum
StanleyGoldman Aug 7, 2018
e6bf1bf
Inlining variable
StanleyGoldman Aug 7, 2018
d5d633e
Renaming StatusStateEnum
StanleyGoldman Aug 7, 2018
f9f8d9a
Formatting code
StanleyGoldman Aug 7, 2018
3639807
Creating a PullRequestCheckViewModelDesigner
StanleyGoldman Aug 7, 2018
48f180d
Removing viewLocator
StanleyGoldman Aug 7, 2018
e55e47a
Removing designer usage
StanleyGoldman Aug 7, 2018
d6a95f7
Making several properties read only
StanleyGoldman Aug 7, 2018
1fe4822
Merge remote-tracking branch 'origin/master' into stanley/check-suite…
StanleyGoldman Aug 7, 2018
86df2bc
Final nitpicks
StanleyGoldman Aug 8, 2018
01efca2
Cleanup view imports
StanleyGoldman Aug 8, 2018
57b4f31
Adding some xmlcomments
StanleyGoldman Aug 8, 2018
923ad51
More xmldocs
StanleyGoldman Aug 8, 2018
f4d59bb
Formatting and xmldocs
StanleyGoldman Aug 8, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/GitHub.App/GitHub.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
<Compile Include="ViewModels\GitHubPane\LoggedOutViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\NavigationViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\GitHubPaneViewModel.cs" />
<Compile Include="SampleData\PullRequestCheckViewModelDesigner.cs" />
<Compile Include="ViewModels\GitHubPane\PullRequestFilesViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\PullRequestListItemViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\PullRequestListViewModel.cs" />
Expand All @@ -267,6 +268,7 @@
<Compile Include="ViewModels\GitHubPane\NotAGitRepositoryViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\PullRequestReviewAuthoringViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\PullRequestReviewCommentViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\PullRequestCheckViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\PullRequestReviewSummaryViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\PullRequestReviewViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\PullRequestUserReviewsViewModel.cs" />
Expand Down
25 changes: 25 additions & 0 deletions src/GitHub.App/SampleData/PullRequestCheckViewModelDesigner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Windows.Media.Imaging;
using GitHub.ViewModels;
using GitHub.ViewModels.GitHubPane;
using ReactiveUI;

namespace GitHub.SampleData
{
public sealed class PullRequestCheckViewModelDesigner : ViewModelBase, IPullRequestCheckViewModel
{
public string Title { get; set; } = "continuous-integration/appveyor/pr";

public string Description { get; set; } = "AppVeyor build failed";

public PullRequestCheckStatus Status { get; set; } = PullRequestCheckStatus.Failure;

public Uri DetailsUrl { get; set; } = new Uri("http://github.com");

public string AvatarUrl { get; set; } = "https://avatars1.githubusercontent.com/u/417571?s=88&v=4";

public BitmapImage Avatar { get; set; } = null;

public ReactiveCommand<object> OpenDetailsUrl { get; set; } = null;
}
}
16 changes: 10 additions & 6 deletions src/GitHub.App/SampleData/PullRequestDetailViewModelDesigner.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Reactive;
using System.Text;
using System.Threading.Tasks;
using GitHub.Models;
using GitHub.Services;
using GitHub.ViewModels;
using GitHub.ViewModels.GitHubPane;
using ReactiveUI;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Reactive;
using System.Threading.Tasks;
using GitHub.SampleData;

namespace GitHub.SampleData
{
Expand Down Expand Up @@ -95,6 +95,8 @@ public PullRequestDetailViewModelDesigner()
};

Files = new PullRequestFilesViewModelDesigner();

Checks = new PullRequestCheckViewModelDesigner[0];
}

public PullRequestDetailModel Model { get; }
Expand Down Expand Up @@ -123,6 +125,8 @@ public PullRequestDetailViewModelDesigner()
public ReactiveCommand<object> OpenOnGitHub { get; }
public ReactiveCommand<object> ShowReview { get; }

public IReadOnlyList<IPullRequestCheckViewModel> Checks { get; }

public Task InitializeAsync(ILocalRepositoryModel localRepository, IConnection connection, string owner, string repo, int number) => Task.CompletedTask;

public string GetLocalFilePath(IPullRequestFileNode file)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using GitHub.Models;
using GitHub.ViewModels;
using GitHub.ViewModels.GitHubPane;

Expand All @@ -16,5 +17,6 @@ public class PullRequestListItemViewModelDesigner : ViewModelBase, IPullRequestL
public int Number { get; set; }
public string Title { get; set; }
public DateTimeOffset UpdatedAt { get; set; }
public PullRequestChecksState Checks { get; set; }
}
}
62 changes: 61 additions & 1 deletion src/GitHub.App/Services/PullRequestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Rothko;
using static System.FormattableString;
using static Octokit.GraphQL.Variable;
using StatusState = GitHub.Models.StatusState;

namespace GitHub.Services
{
Expand Down Expand Up @@ -93,6 +94,17 @@ public async Task<Page<PullRequestListItemModel>> ReadPullRequests(
Items = page.Nodes.Select(pr => new ListItemAdapter
{
Id = pr.Id.Value,
LastCommit = pr.Commits(null, null, 1, null).Nodes.Select(commit =>
new LastCommitSummaryModel
{
Statuses = commit.Commit.Status
.Select(context =>
context.Contexts.Select(statusContext => new StatusSummaryModel
{
State = (StatusState)statusContext.State,
}).ToList()
).SingleOrDefault()
}).ToList().FirstOrDefault(),
Author = new ActorModel
{
Login = pr.Author.Login,
Expand Down Expand Up @@ -123,10 +135,46 @@ public async Task<Page<PullRequestListItemModel>> ReadPullRequests(

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

foreach (ListItemAdapter item in result.Items)
foreach (var item in result.Items.Cast<ListItemAdapter>())
{
item.CommentCount += item.Reviews.Sum(x => x.Count);
item.Reviews = null;

var hasStatuses = item.LastCommit.Statuses != null
&& item.LastCommit.Statuses.Any();

if (!hasStatuses)
{
item.Checks = PullRequestChecksState.None;
}
else
{
var statusHasFailure = item.LastCommit
.Statuses
.Any(status => status.State == StatusState.Failure);

var statusHasCompleteSuccess = true;
if (!statusHasFailure)
{
statusHasCompleteSuccess =
item.LastCommit.Statuses.All(status => status.State == StatusState.Success);
}

if (statusHasFailure)
{
item.Checks = PullRequestChecksState.Failure;
}
else if (statusHasCompleteSuccess)
{
item.Checks = PullRequestChecksState.Success;
}
else
{
item.Checks = PullRequestChecksState.Pending;
}
}

item.LastCommit = null;
}

return result;
Expand Down Expand Up @@ -840,6 +888,8 @@ static Tuple<string, int> ParseGHfVSConfigKeyValue(string value)
class ListItemAdapter : PullRequestListItemModel
{
public IList<ReviewAdapter> Reviews { get; set; }

public LastCommitSummaryModel LastCommit { get; set; }
}

class ReviewAdapter
Expand All @@ -848,5 +898,15 @@ class ReviewAdapter
public int CommentCount { get; set; }
public int Count => CommentCount + (!string.IsNullOrWhiteSpace(Body) ? 1 : 0);
}

class StatusSummaryModel
{
public StatusState State { get; set; }
}

class LastCommitSummaryModel
{
public List<StatusSummaryModel> Statuses { get; set; }
}
}
}
86 changes: 86 additions & 0 deletions src/GitHub.App/ViewModels/GitHubPane/PullRequestCheckViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using System.Windows.Media.Imaging;
using GitHub.Extensions;
using GitHub.Factories;
using GitHub.Models;
using GitHub.Services;
using ReactiveUI;

namespace GitHub.ViewModels.GitHubPane
{
[Export(typeof(IPullRequestCheckViewModel))]
[PartCreationPolicy(CreationPolicy.NonShared)]
public class PullRequestCheckViewModel: ViewModelBase, IPullRequestCheckViewModel
{
private readonly IUsageTracker usageTracker;
const string DefaultAvatar = "pack://application:,,,/GitHub.App;component/Images/default_user_avatar.png";

public static IEnumerable<IPullRequestCheckViewModel> Build(IViewViewModelFactory viewViewModelFactory, PullRequestDetailModel pullRequest)
{
return pullRequest.Statuses?.Select(model =>
{
PullRequestCheckStatus checkStatus;
switch (model.State)
{
case StatusState.Expected:
case StatusState.Error:
case StatusState.Failure:
checkStatus = PullRequestCheckStatus.Failure;
break;
case StatusState.Pending:
checkStatus = PullRequestCheckStatus.Pending;
break;
case StatusState.Success:
checkStatus = PullRequestCheckStatus.Success;
break;
default:
throw new InvalidOperationException("Unkown PullRequestCheckStatusEnum");
}

var pullRequestCheckViewModel = (PullRequestCheckViewModel) viewViewModelFactory.CreateViewModel<IPullRequestCheckViewModel>();
pullRequestCheckViewModel.Title = model.Context;
pullRequestCheckViewModel.Description = model.Description;
pullRequestCheckViewModel.Status = checkStatus;
pullRequestCheckViewModel.DetailsUrl = new Uri(model.TargetUrl);
pullRequestCheckViewModel.AvatarUrl = model.AvatarUrl ?? DefaultAvatar;
pullRequestCheckViewModel.Avatar = model.AvatarUrl != null
? new BitmapImage(new Uri(model.AvatarUrl))
: AvatarProvider.CreateBitmapImage(DefaultAvatar);

return pullRequestCheckViewModel;

}) ?? new PullRequestCheckViewModel[0];
}

[ImportingConstructor]
public PullRequestCheckViewModel(IUsageTracker usageTracker)
{
this.usageTracker = usageTracker;
OpenDetailsUrl = ReactiveCommand.Create().OnExecuteCompleted(DoOpenDetailsUrl);
}

private void DoOpenDetailsUrl(object obj)
{
usageTracker.IncrementCounter(x => x.NumberOfPRCheckStatusesOpenInGitHub).Forget();
}

public string Title { get; private set; }

public string Description { get; private set; }

public PullRequestCheckStatus Status{ get; private set; }

public Uri DetailsUrl { get; private set; }

public string AvatarUrl { get; private set; }

public BitmapImage Avatar { get; private set; }

public ReactiveCommand<object> OpenDetailsUrl { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public sealed class PullRequestDetailViewModel : PanePageViewModelBase, IPullReq
readonly IUsageTracker usageTracker;
readonly ITeamExplorerContext teamExplorerContext;
readonly ISyncSubmodulesCommand syncSubmodulesCommand;
readonly IViewViewModelFactory viewViewModelFactory;
IModelService modelService;
PullRequestDetailModel model;
IActorViewModel author;
Expand All @@ -55,6 +56,7 @@ public sealed class PullRequestDetailViewModel : PanePageViewModelBase, IPullReq
bool refreshOnActivate;
Uri webUrl;
IDisposable sessionSubscription;
IReadOnlyList<IPullRequestCheckViewModel> checks;

/// <summary>
/// Initializes a new instance of the <see cref="PullRequestDetailViewModel"/> class.
Expand All @@ -73,21 +75,24 @@ public PullRequestDetailViewModel(
IUsageTracker usageTracker,
ITeamExplorerContext teamExplorerContext,
IPullRequestFilesViewModel files,
ISyncSubmodulesCommand syncSubmodulesCommand)
ISyncSubmodulesCommand syncSubmodulesCommand,
IViewViewModelFactory viewViewModelFactory)
{
Guard.ArgumentNotNull(pullRequestsService, nameof(pullRequestsService));
Guard.ArgumentNotNull(sessionManager, nameof(sessionManager));
Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory));
Guard.ArgumentNotNull(usageTracker, nameof(usageTracker));
Guard.ArgumentNotNull(teamExplorerContext, nameof(teamExplorerContext));
Guard.ArgumentNotNull(syncSubmodulesCommand, nameof(syncSubmodulesCommand));
Guard.ArgumentNotNull(viewViewModelFactory, nameof(viewViewModelFactory));

this.pullRequestsService = pullRequestsService;
this.sessionManager = sessionManager;
this.modelServiceFactory = modelServiceFactory;
this.usageTracker = usageTracker;
this.teamExplorerContext = teamExplorerContext;
this.syncSubmodulesCommand = syncSubmodulesCommand;
this.viewViewModelFactory = viewViewModelFactory;
Files = files;

Checkout = ReactiveCommand.CreateAsyncObservable(
Expand Down Expand Up @@ -302,6 +307,12 @@ public Uri WebUrl
/// </summary>
public ReactiveCommand<object> ShowReview { get; }

public IReadOnlyList<IPullRequestCheckViewModel> Checks
{
get { return checks; }
private set { this.RaiseAndSetIfChanged(ref checks, value); }
}

/// <summary>
/// Initializes the view model.
/// </summary>
Expand Down Expand Up @@ -377,6 +388,8 @@ public async Task Load(PullRequestDetailModel pullRequest)
Body = !string.IsNullOrWhiteSpace(pullRequest.Body) ? pullRequest.Body : Resources.NoDescriptionProvidedMarkdown;
Reviews = PullRequestReviewSummaryViewModel.BuildByUser(Session.User, pullRequest).ToList();

Checks = PullRequestCheckViewModel.Build(viewViewModelFactory, pullRequest)?.ToList();

await Files.InitializeAsync(Session);

var localBranches = await pullRequestsService.GetLocalBranches(LocalRepository, pullRequest).ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,24 @@ public PullRequestListItemViewModel(PullRequestListItemModel model)
{
Id = model.Id;
Author = new ActorViewModel(model.Author);
Checks = model.Checks;
CommentCount = model.CommentCount;
Number = model.Number;
Title = model.Title;
UpdatedAt = model.UpdatedAt;
}

/// <inheritdoc/>
public string Id { get; protected set; }
public string Id { get; }

/// <inheritdoc/>
public IActorViewModel Author { get; protected set; }
public IActorViewModel Author { get; }

/// <inheritdoc/>
public int CommentCount { get; protected set; }
public PullRequestChecksState Checks { get; }

/// <inheritdoc/>
public int CommentCount { get; }

/// <inheritdoc/>
public bool IsCurrent
Expand All @@ -42,12 +46,12 @@ public bool IsCurrent
}

/// <inheritdoc/>
public int Number { get; protected set; }
public int Number { get; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing these :D


/// <inheritdoc/>
public string Title { get; protected set; }
public string Title { get; }

/// <inheritdoc/>
public DateTimeOffset UpdatedAt { get; protected set; }
public DateTimeOffset UpdatedAt { get; }
}
}
1 change: 1 addition & 0 deletions src/GitHub.Exports.Reactive/GitHub.Exports.Reactive.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
<Compile Include="ViewModels\GitHubPane\ILoggedOutViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\INavigationViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\IPanePageViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\IPullRequestCheckViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\IPullRequestFilesViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\IPullRequestListItemViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\IPullRequestListViewModel.cs" />
Expand Down
Loading