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

Commit 08bfdc9

Browse files
committed
Merge branch 'donokuda/pr-pane' into feature/pr-conversation
2 parents b1b49a3 + 84dd7ff commit 08bfdc9

File tree

10 files changed

+113
-138
lines changed

10 files changed

+113
-138
lines changed

src/GitHub.App/SampleData/PullRequestDetailViewModelDesigner.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public PullRequestDetailViewModelDesigner()
124124
public ReactiveCommand<Unit, Unit> Pull { get; }
125125
public ReactiveCommand<Unit, Unit> Push { get; }
126126
public ReactiveCommand<Unit, Unit> SyncSubmodules { get; }
127+
public ReactiveCommand<Unit, Unit> OpenConversation { get; }
127128
public ReactiveCommand<Unit, Unit> OpenOnGitHub { get; }
128129
public ReactiveCommand<IPullRequestReviewSummaryViewModel, Unit> ShowReview { get; }
129130
public ReactiveCommand<IPullRequestCheckViewModel, Unit> ShowAnnotations { get; }

src/GitHub.App/ViewModels/GitHubPane/PullRequestDetailViewModel.cs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using Serilog;
2525
using static System.FormattableString;
2626
using ReactiveCommand = ReactiveUI.ReactiveCommand;
27+
using GitHub.Primitives;
2728

2829
namespace GitHub.ViewModels.GitHubPane
2930
{
@@ -42,6 +43,7 @@ public sealed class PullRequestDetailViewModel : PanePageViewModelBase, IPullReq
4243
readonly ISyncSubmodulesCommand syncSubmodulesCommand;
4344
readonly IViewViewModelFactory viewViewModelFactory;
4445
readonly IGitService gitService;
46+
readonly IOpenIssueishDocumentCommand openDocumentCommand;
4547

4648
IModelService modelService;
4749
PullRequestDetailModel model;
@@ -82,7 +84,8 @@ public PullRequestDetailViewModel(
8284
IPullRequestFilesViewModel files,
8385
ISyncSubmodulesCommand syncSubmodulesCommand,
8486
IViewViewModelFactory viewViewModelFactory,
85-
IGitService gitService)
87+
IGitService gitService,
88+
IOpenIssueishDocumentCommand openDocumentCommand)
8689
{
8790
Guard.ArgumentNotNull(pullRequestsService, nameof(pullRequestsService));
8891
Guard.ArgumentNotNull(sessionManager, nameof(sessionManager));
@@ -92,6 +95,7 @@ public PullRequestDetailViewModel(
9295
Guard.ArgumentNotNull(syncSubmodulesCommand, nameof(syncSubmodulesCommand));
9396
Guard.ArgumentNotNull(viewViewModelFactory, nameof(viewViewModelFactory));
9497
Guard.ArgumentNotNull(gitService, nameof(gitService));
98+
Guard.ArgumentNotNull(openDocumentCommand, nameof(openDocumentCommand));
9599

96100
this.pullRequestsService = pullRequestsService;
97101
this.sessionManager = sessionManager;
@@ -101,6 +105,7 @@ public PullRequestDetailViewModel(
101105
this.syncSubmodulesCommand = syncSubmodulesCommand;
102106
this.viewViewModelFactory = viewViewModelFactory;
103107
this.gitService = gitService;
108+
this.openDocumentCommand = openDocumentCommand;
104109

105110
Files = files;
106111

@@ -134,6 +139,8 @@ public PullRequestDetailViewModel(
134139
SyncSubmodules.Subscribe(_ => Refresh().ToObservable());
135140
SubscribeOperationError(SyncSubmodules);
136141

142+
OpenConversation = ReactiveCommand.Create(DoOpenConversation);
143+
137144
OpenOnGitHub = ReactiveCommand.Create(DoOpenDetailsUrl);
138145

139146
ShowReview = ReactiveCommand.Create<IPullRequestReviewSummaryViewModel>(DoShowReview);
@@ -144,11 +151,6 @@ public PullRequestDetailViewModel(
144151
[Import(AllowDefault = true)]
145152
private IStaticReviewFileMapManager StaticReviewFileMapManager { get; set; }
146153

147-
private void DoOpenDetailsUrl()
148-
{
149-
usageTracker.IncrementCounter(measuresModel => measuresModel.NumberOfPRDetailsOpenInGitHub).Forget();
150-
}
151-
152154
/// <inheritdoc/>
153155
public PullRequestDetailModel Model
154156
{
@@ -273,6 +275,9 @@ public Uri WebUrl
273275
/// <inheritdoc/>
274276
public ReactiveCommand<Unit, Unit> SyncSubmodules { get; }
275277

278+
/// <inheritdoc/>
279+
public ReactiveCommand<Unit, Unit> OpenConversation { get; }
280+
276281
/// <inheritdoc/>
277282
public ReactiveCommand<Unit, Unit> OpenOnGitHub { get; }
278283

@@ -650,6 +655,21 @@ async Task DoSyncSubmodules()
650655
}
651656
}
652657

658+
void DoOpenConversation()
659+
{
660+
var p = new OpenIssueishParams(
661+
HostAddress.Create(LocalRepository.CloneUrl),
662+
RemoteRepositoryOwner,
663+
LocalRepository.Name,
664+
Number);
665+
openDocumentCommand.Execute(p);
666+
}
667+
668+
void DoOpenDetailsUrl()
669+
{
670+
usageTracker.IncrementCounter(measuresModel => measuresModel.NumberOfPRDetailsOpenInGitHub).Forget();
671+
}
672+
653673
void DoShowReview(IPullRequestReviewSummaryViewModel review)
654674
{
655675
if (review.State == PullRequestReviewState.Pending)

src/GitHub.App/ViewModels/GitHubPane/PullRequestListViewModel.cs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public class PullRequestListViewModel : IssueListViewModelBase, IPullRequestList
2727
readonly IPullRequestSessionManager sessionManager;
2828
readonly IPullRequestService service;
2929
readonly IDisposable subscription;
30-
readonly IOpenIssueishDocumentCommand openDocumentCommand;
3130
ObservableAsPropertyHelper<Uri> webUrl;
3231

3332
/// <summary>
@@ -40,24 +39,20 @@ public class PullRequestListViewModel : IssueListViewModelBase, IPullRequestList
4039
public PullRequestListViewModel(
4140
IPullRequestSessionManager sessionManager,
4241
IRepositoryService repositoryService,
43-
IPullRequestService service,
44-
IOpenIssueishDocumentCommand openDocumentCommand)
42+
IPullRequestService service)
4543
: base(repositoryService)
4644
{
4745
Guard.ArgumentNotNull(sessionManager, nameof(sessionManager));
4846
Guard.ArgumentNotNull(service, nameof(service));
49-
Guard.ArgumentNotNull(openDocumentCommand, nameof(openDocumentCommand));
5047

5148
this.sessionManager = sessionManager;
5249
this.service = service;
53-
this.openDocumentCommand = openDocumentCommand;
5450

5551
subscription = sessionManager.WhenAnyValue(x => x.CurrentSession.PullRequest.Number).Subscribe(UpdateCurrent);
5652
webUrl = this.WhenAnyValue(x => x.RemoteRepository)
5753
.Select(x => x?.CloneUrl?.ToRepositoryUrl().Append("pulls"))
5854
.ToProperty(this, x => x.WebUrl);
5955
CreatePullRequest = ReactiveCommand.Create(() => NavigateTo("pull/new"));
60-
OpenConversation = ReactiveCommand.Create<IPullRequestListItemViewModel>(DoOpenConversation);
6156
OpenItemInBrowser = ReactiveCommand.Create<IPullRequestListItemViewModel, IPullRequestListItemViewModel>(x => x);
6257
}
6358

@@ -70,9 +65,6 @@ public PullRequestListViewModel(
7065
/// <inheritdoc/>
7166
public ReactiveCommand<Unit, Unit> CreatePullRequest { get; }
7267

73-
/// <inheritdoc/>
74-
public ReactiveCommand<IPullRequestListItemViewModel, Unit> OpenConversation { get; }
75-
7668
/// <inheritdoc/>
7769
public ReactiveCommand<IPullRequestListItemViewModel, IPullRequestListItemViewModel> OpenItemInBrowser { get; }
7870

@@ -100,16 +92,6 @@ protected override Task<Page<ActorModel>> LoadAuthors(string after)
10092
after);
10193
}
10294

103-
void DoOpenConversation(IIssueListItemViewModelBase item)
104-
{
105-
var p = new OpenIssueishParams(
106-
HostAddress.Create(LocalRepository.CloneUrl),
107-
RemoteRepository.Owner,
108-
RemoteRepository.Name,
109-
item.Number);
110-
openDocumentCommand.Execute(p);
111-
}
112-
11395
void UpdateCurrent(int number)
11496
{
11597
if (Items != null)

src/GitHub.Exports.Reactive/ViewModels/GitHubPane/IPullRequestDetailViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ public interface IPullRequestDetailViewModel : IPanePageViewModel, IOpenInBrowse
171171
/// </summary>
172172
ReactiveCommand<Unit, Unit> SyncSubmodules { get; }
173173

174+
/// <summary>
175+
/// Gets a command that opens the pull request conversation in a document pane.
176+
/// </summary>
177+
ReactiveCommand<Unit, Unit> OpenConversation { get; }
178+
174179
/// <summary>
175180
/// Gets a command that opens the pull request on GitHub.
176181
/// </summary>

src/GitHub.Exports.Reactive/ViewModels/GitHubPane/IPullRequestListViewModel.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ public interface IPullRequestListViewModel : IIssueListViewModelBase, IOpenInBro
1414
/// </summary>
1515
ReactiveCommand<Unit, Unit> CreatePullRequest { get; }
1616

17-
/// <summary>
18-
/// Gets a command that opens the pull request conversation in a document pane.
19-
/// </summary>
20-
ReactiveCommand<IPullRequestListItemViewModel, Unit> OpenConversation { get; }
21-
2217
/// <summary>
2318
/// Gets a command that opens the pull request item on GitHub.
2419
/// </summary>

0 commit comments

Comments
 (0)