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

Commit abce76d

Browse files
authored
Merge pull request #2229 from github/donokuda/moving-some-cheese
Add pull request comment count link and add back in description section
2 parents d8cf315 + 3f43625 commit abce76d

File tree

7 files changed

+60
-9
lines changed

7 files changed

+60
-9
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)

src/GitHub.Exports/Models/IssueishDetailModel.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,15 @@ public class IssueishDetailModel
3737
/// Gets or sets the date/time at which the issue or pull request was last updated.
3838
/// </summary>
3939
public DateTimeOffset UpdatedAt { get; set; }
40-
40+
4141
/// <summary>
4242
/// Gets or sets the comments on the issue or pull request.
4343
/// </summary>
4444
public IReadOnlyList<CommentModel> Comments { get; set; }
45+
46+
/// <summary>
47+
/// Gets or sets the number of comments on the issue or pull request.
48+
/// </summary>
49+
public int CommentCount { get; set; }
4550
}
4651
}

src/GitHub.InlineReviews/Services/PullRequestSessionService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ public virtual async Task<PullRequestDetailModel> ReadPullRequestDetail(HostAddr
313313
HeadRepositoryOwner = pr.HeadRepositoryOwner != null ? pr.HeadRepositoryOwner.Login : null,
314314
State = pr.State.FromGraphQl(),
315315
UpdatedAt = pr.UpdatedAt,
316+
CommentCount = pr.Comments(0, null, null, null).TotalCount,
316317
Comments = pr.Comments(null, null, null, null).AllPages().Select(comment => new CommentModel
317318
{
318319
Id = comment.Id.Value,

src/GitHub.VisualStudio.UI/Views/Documents/PullRequestPageView.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<d:DesignData.DataContext>
1515
<ghfvs:PullRequestPageViewModelDesigner/>
1616
</d:DesignData.DataContext>
17-
17+
1818
<Control.Resources>
1919
<ResourceDictionary>
2020
<ResourceDictionary.MergedDictionaries>
@@ -42,6 +42,7 @@
4242

4343
<TextBlock Margin="0 8"
4444
Foreground="{DynamicResource VsBrush.WindowText}"
45+
TextWrapping="Wrap"
4546
Style="{DynamicResource {x:Static vsui:VsResourceKeys.TextBlockEnvironment200PercentFontSizeStyleKey}}">
4647
<Run Text="{Binding Title, Mode=OneWay}"/>
4748
<Hyperlink Command="{Binding OpenOnGitHub}">
@@ -113,7 +114,7 @@
113114
CornerRadius="3"
114115
Padding="2 1"
115116
Visibility="{Binding IsPending, Converter={ui:BooleanToVisibilityConverter}, FallbackValue=Collapsed}">
116-
<TextBlock FontSize="10" Text="{x:Static ghfvs:Resources.Pending}" />
117+
<TextBlock FontSize="10" Text="{x:Static ghfvs:Resources.Pending}" />
117118
</Border>
118119
</StackPanel>
119120
</Border>

src/GitHub.VisualStudio.UI/Views/GitHubPane/PullRequestDetailView.xaml

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<StackPanel DockPanel.Dock="Top"
6767
Orientation="Vertical"
6868
Margin="8 0 0 0">
69-
69+
7070
<!-- Title -->
7171
<TextBlock Style="{DynamicResource {x:Static vsui:VsResourceKeys.TextBlockEnvironment122PercentFontSizeStyleKey}}"
7272
TextWrapping="Wrap"
@@ -99,12 +99,19 @@
9999
<StackPanel Orientation="Horizontal"
100100
Margin="0 0 0 -4"
101101
ghfvs:ScrollingVerticalStackPanel.IsFixed="true">
102-
<ghfvs:GitHubActionLink Margin="0 6" Command="{Binding OpenConversation}">
103-
View Conversation
102+
<ghfvs:GitHubActionLink Margin="0 6" Command="{Binding OpenOnGitHub}">
103+
View on GitHub
104104
</ghfvs:GitHubActionLink>
105105

106106
<Rectangle Margin="5 0" Width="1" Height="12" VerticalAlignment="Center" Style="{DynamicResource Separator}" />
107107

108+
<StackPanel Orientation="Horizontal">
109+
<ghfvs:OcticonImage Margin="0 2 4 0" Foreground="{DynamicResource VsBrush.GrayText}" Width="12" Height="12" Icon="comment"/>
110+
<ghfvs:GitHubActionLink Margin="0 6" Command="{Binding OpenConversation}" Content="{Binding Model.CommentCount}" />
111+
</StackPanel>
112+
113+
<Rectangle Margin="5 0" Width="1" Height="12" VerticalAlignment="Center" Style="{DynamicResource Separator}" />
114+
108115
<!-- Checkout pull request button -->
109116
<ghfvs:GitHubActionLink Command="{Binding Checkout}"
110117
Content="{Binding CheckoutState.Caption}"
@@ -186,6 +193,31 @@
186193
HorizontalScrollBarVisibility="Auto"
187194
VerticalScrollBarVisibility="Auto">
188195
<ghfvs:ScrollingVerticalStackPanel>
196+
<!-- Author and open time -->
197+
<ghfvs:SectionControl Name="descriptionSection"
198+
HeaderText="{x:Static ghfvs:Resources.Description}"
199+
Margin="0 4 0 0"
200+
IsExpanded="False"
201+
ghfvs:ScrollingVerticalStackPanel.IsFixed="true">
202+
<StackPanel Orientation="Vertical">
203+
<StackPanel Orientation="Horizontal" Margin="0 4 0 0">
204+
<v:ActorAvatarView ViewModel="{Binding Author}"
205+
VerticalAlignment="Bottom"
206+
Width="16"
207+
Height="16"
208+
Margin="0,0,0,1"/>
209+
210+
<TextBlock VerticalAlignment="Center" Margin="4 0" TextWrapping="Wrap">
211+
<Run FontWeight="SemiBold" Text="{Binding Model.Author.Login, Mode=OneWay}" />
212+
<Run Text="{x:Static ghfvs:Resources.Wrote}" />
213+
</TextBlock>
214+
</StackPanel>
215+
<!-- PR Body -->
216+
<markdig:MarkdownViewer Name="bodyMarkdown"
217+
Margin="2 4 10 6"
218+
Markdown="{Binding Body}"/>
219+
</StackPanel>
220+
</ghfvs:SectionControl>
189221

190222
<ghfvs:SectionControl Name="reviewsSection"
191223
HeaderText="{x:Static ghfvs:Resources.Reviewers}"
@@ -223,7 +255,7 @@
223255
HeaderText="{Binding Files.ChangedFilesCount, StringFormat={x:Static ghfvs:Resources.ChangesCountFormat}}"
224256
Margin="0 8 10 0"
225257
ghfvs:ScrollingVerticalStackPanel.IsFixed="true"/>
226-
258+
227259
<!-- Put the changes tree outside its expander, so it can scroll horizontally
228260
while the header remains fixed -->
229261
<local:PullRequestFilesView DataContext="{Binding Files}"

0 commit comments

Comments
 (0)