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

Commit 17f3f93

Browse files
committed
Set the pull request WebUrl and OpenOnGitHub
Make hash-link at top pull request page open on GitHub.
1 parent ae6935a commit 17f3f93

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/GitHub.App/ViewModels/Documents/PullRequestPageViewModel.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class PullRequestPageViewModel : PullRequestViewModelBase, IPullRequestPa
2323
readonly IPullRequestService service;
2424
readonly IPullRequestSessionManager sessionManager;
2525
readonly ITeamExplorerServices teServices;
26+
readonly IVisualStudioBrowser visualStudioBrowser;
2627
readonly IUsageTracker usageTracker;
2728
ActorModel currentUserModel;
2829
ReactiveList<IViewModel> timeline = new ReactiveList<IViewModel>();
@@ -37,22 +38,26 @@ public PullRequestPageViewModel(
3738
IPullRequestService service,
3839
IPullRequestSessionManager sessionManager,
3940
ITeamExplorerServices teServices,
41+
IVisualStudioBrowser visualStudioBrowser,
4042
IUsageTracker usageTracker)
4143
{
4244
Guard.ArgumentNotNull(factory, nameof(factory));
4345
Guard.ArgumentNotNull(service, nameof(service));
4446
Guard.ArgumentNotNull(sessionManager, nameof(sessionManager));
47+
Guard.ArgumentNotNull(visualStudioBrowser, nameof(visualStudioBrowser));
4548
Guard.ArgumentNotNull(teServices, nameof(teServices));
4649

4750
this.factory = factory;
4851
this.service = service;
4952
this.sessionManager = sessionManager;
5053
this.teServices = teServices;
54+
this.visualStudioBrowser = visualStudioBrowser;
5155
this.usageTracker = usageTracker;
5256

5357
timeline.ItemsRemoved.Subscribe(TimelineItemRemoved);
5458

5559
ShowCommit = ReactiveCommand.CreateFromTask<string>(DoShowCommit);
60+
OpenOnGitHub = ReactiveCommand.Create(DoOpenOnGitHub);
5661
}
5762

5863
/// <inheritdoc/>
@@ -198,6 +203,11 @@ async Task DoShowCommit(string oid)
198203
teServices.ShowCommitDetails(oid);
199204
}
200205

206+
void DoOpenOnGitHub()
207+
{
208+
visualStudioBrowser.OpenUrl(WebUrl);
209+
}
210+
201211
void TimelineItemRemoved(IViewModel item)
202212
{
203213
(item as IDisposable)?.Dispose();

src/GitHub.App/ViewModels/IssueishViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ public string Title
6363
public Uri WebUrl
6464
{
6565
get { return webUrl; }
66-
private set { this.RaiseAndSetIfChanged(ref webUrl, value); }
66+
protected set { this.RaiseAndSetIfChanged(ref webUrl, value); }
6767
}
6868

6969
/// <inheritdoc/>
70-
public ReactiveCommand<Unit, Unit> OpenOnGitHub { get; }
70+
public ReactiveCommand<Unit, Unit> OpenOnGitHub { get; protected set; }
7171

7272
protected Task InitializeAsync(
7373
RemoteRepositoryModel repository,

src/GitHub.App/ViewModels/PullRequestViewModelBase.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.ComponentModel.Composition;
33
using System.Threading.Tasks;
4+
using GitHub.Extensions;
45
using GitHub.Logging;
56
using GitHub.Models;
67
using ReactiveUI;
@@ -59,6 +60,7 @@ protected virtual async Task InitializeAsync(
5960
State = model.State;
6061
SourceBranchDisplayName = GetBranchDisplayName(fork, model.HeadRepositoryOwner, model.HeadRefName);
6162
TargetBranchDisplayName = GetBranchDisplayName(fork, model.BaseRepositoryOwner, model.BaseRefName);
63+
WebUrl = localRepository.CloneUrl.ToRepositoryUrl().Append("pull/" + Number);
6264
}
6365

6466
static string GetBranchDisplayName(bool isFromFork, string owner, string label)

0 commit comments

Comments
 (0)