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
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
10 changes: 10 additions & 0 deletions src/GitHub.App/ViewModels/Documents/PullRequestPageViewModel.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,6 +23,7 @@ public class PullRequestPageViewModel : PullRequestViewModelBase, IPullRequestPa
readonly IPullRequestService service;
readonly IPullRequestSessionManager sessionManager;
readonly ITeamExplorerServices teServices;
readonly IVisualStudioBrowser visualStudioBrowser;
readonly IUsageTracker usageTracker;
ActorModel currentUserModel;
ReactiveList<IViewModel> timeline = new ReactiveList<IViewModel>();
Expand All@@ -37,22 +38,26 @@ public PullRequestPageViewModel(
IPullRequestService service,
IPullRequestSessionManager sessionManager,
ITeamExplorerServices teServices,
IVisualStudioBrowser visualStudioBrowser,
IUsageTracker usageTracker)
{
Guard.ArgumentNotNull(factory, nameof(factory));
Guard.ArgumentNotNull(service, nameof(service));
Guard.ArgumentNotNull(sessionManager, nameof(sessionManager));
Guard.ArgumentNotNull(visualStudioBrowser, nameof(visualStudioBrowser));
Guard.ArgumentNotNull(teServices, nameof(teServices));

this.factory = factory;
this.service = service;
this.sessionManager = sessionManager;
this.teServices = teServices;
this.visualStudioBrowser = visualStudioBrowser;
this.usageTracker = usageTracker;

timeline.ItemsRemoved.Subscribe(TimelineItemRemoved);

ShowCommit = ReactiveCommand.CreateFromTask<string>(DoShowCommit);
OpenOnGitHub = ReactiveCommand.Create(DoOpenOnGitHub);
}

/// <inheritdoc/>
Expand DownExpand Up@@ -198,6 +203,11 @@ async Task DoShowCommit(string oid)
teServices.ShowCommitDetails(oid);
}

void DoOpenOnGitHub()
{
visualStudioBrowser.OpenUrl(WebUrl);
}

void TimelineItemRemoved(IViewModel item)
{
(item as IDisposable)?.Dispose();
Expand Down
4 changes: 2 additions & 2 deletions src/GitHub.App/ViewModels/IssueishViewModel.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,11 +63,11 @@ public string Title
public Uri WebUrl
{
get { return webUrl; }
private set { this.RaiseAndSetIfChanged(ref webUrl, value); }
protected set { this.RaiseAndSetIfChanged(ref webUrl, value); }
}

/// <inheritdoc/>
public ReactiveCommand<Unit, Unit> OpenOnGitHub { get; }
public ReactiveCommand<Unit, Unit> OpenOnGitHub { get; protected set; }

protected Task InitializeAsync(
RemoteRepositoryModel repository,
Expand Down
2 changes: 2 additions & 0 deletions src/GitHub.App/ViewModels/PullRequestViewModelBase.cs
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
using System;
using System.ComponentModel.Composition;
using System.Threading.Tasks;
using GitHub.Extensions;
using GitHub.Logging;
using GitHub.Models;
using ReactiveUI;
Expand DownExpand Up@@ -59,6 +60,7 @@ protected virtual async Task InitializeAsync(
State = model.State;
SourceBranchDisplayName = GetBranchDisplayName(fork, model.HeadRepositoryOwner, model.HeadRefName);
TargetBranchDisplayName = GetBranchDisplayName(fork, model.BaseRepositoryOwner, model.BaseRefName);
WebUrl = localRepository.CloneUrl.ToRepositoryUrl().Append("pull/" + Number);
}

static string GetBranchDisplayName(bool isFromFork, string owner, string label)
Expand Down
7 changes: 6 additions & 1 deletion src/GitHub.Exports/Models/IssueishDetailModel.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,10 +37,15 @@ public class IssueishDetailModel
/// Gets or sets the date/time at which the issue or pull request was last updated.
/// </summary>
public DateTimeOffset UpdatedAt { get; set; }

/// <summary>
/// Gets or sets the comments on the issue or pull request.
/// </summary>
public IReadOnlyList<CommentModel> Comments { get; set; }

/// <summary>
/// Gets or sets the number of comments on the issue or pull request.
/// </summary>
public int CommentCount { get; set; }
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -313,6 +313,7 @@ public virtual async Task<PullRequestDetailModel> ReadPullRequestDetail(HostAddr
HeadRepositoryOwner = pr.HeadRepositoryOwner != null ? pr.HeadRepositoryOwner.Login : null,
State = pr.State.FromGraphQl(),
UpdatedAt = pr.UpdatedAt,
CommentCount = pr.Comments(0, null, null, null).TotalCount,
Comments = pr.Comments(null, null, null, null).AllPages().Select(comment => new CommentModel
{
Id = comment.Id.Value,
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,7 @@
<d:DesignData.DataContext>
<ghfvs:PullRequestPageViewModelDesigner/>
</d:DesignData.DataContext>

<Control.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand DownExpand Up@@ -42,6 +42,7 @@

<TextBlock Margin="0 8"
Foreground="{DynamicResource VsBrush.WindowText}"
TextWrapping="Wrap"
Style="{DynamicResource {x:Static vsui:VsResourceKeys.TextBlockEnvironment200PercentFontSizeStyleKey}}">
<Run Text="{Binding Title, Mode=OneWay}"/>
<Hyperlink Command="{Binding OpenOnGitHub}">
Expand DownExpand Up@@ -113,7 +114,7 @@
CornerRadius="3"
Padding="2 1"
Visibility="{Binding IsPending, Converter={ui:BooleanToVisibilityConverter}, FallbackValue=Collapsed}">
<TextBlock FontSize="10" Text="{x:Static ghfvs:Resources.Pending}" />
<TextBlock FontSize="10" Text="{x:Static ghfvs:Resources.Pending}" />
</Border>
</StackPanel>
</Border>
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,7 +66,7 @@
<StackPanel DockPanel.Dock="Top"
Orientation="Vertical"
Margin="8 0 0 0">

<!-- Title -->
<TextBlock Style="{DynamicResource {x:Static vsui:VsResourceKeys.TextBlockEnvironment122PercentFontSizeStyleKey}}"
TextWrapping="Wrap"
Expand DownExpand Up@@ -99,12 +99,19 @@
<StackPanel Orientation="Horizontal"
Margin="0 0 0 -4"
ghfvs:ScrollingVerticalStackPanel.IsFixed="true">
<ghfvs:GitHubActionLink Margin="0 6" Command="{Binding OpenConversation}">
View Conversation
<ghfvs:GitHubActionLink Margin="0 6" Command="{Binding OpenOnGitHub}">
View on GitHub
</ghfvs:GitHubActionLink>

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

<StackPanel Orientation="Horizontal">
<ghfvs:OcticonImage Margin="0 2 4 0" Foreground="{DynamicResource VsBrush.GrayText}" Width="12" Height="12" Icon="comment"/>
<ghfvs:GitHubActionLink Margin="0 6" Command="{Binding OpenConversation}" Content="{Binding Model.CommentCount}" />
</StackPanel>

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

<!-- Checkout pull request button -->
<ghfvs:GitHubActionLink Command="{Binding Checkout}"
Content="{Binding CheckoutState.Caption}"
Expand DownExpand Up@@ -186,6 +193,31 @@
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<ghfvs:ScrollingVerticalStackPanel>
<!-- Author and open time -->
<ghfvs:SectionControl Name="descriptionSection"
HeaderText="{x:Static ghfvs:Resources.Description}"
Margin="0 4 0 0"
IsExpanded="False"
ghfvs:ScrollingVerticalStackPanel.IsFixed="true">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal" Margin="0 4 0 0">
<v:ActorAvatarView ViewModel="{Binding Author}"
VerticalAlignment="Bottom"
Width="16"
Height="16"
Margin="0,0,0,1"/>

<TextBlock VerticalAlignment="Center" Margin="4 0" TextWrapping="Wrap">
<Run FontWeight="SemiBold" Text="{Binding Model.Author.Login, Mode=OneWay}" />
<Run Text="{x:Static ghfvs:Resources.Wrote}" />
</TextBlock>
</StackPanel>
<!-- PR Body -->
<markdig:MarkdownViewer Name="bodyMarkdown"
Margin="2 4 10 6"
Markdown="{Binding Body}"/>
</StackPanel>
</ghfvs:SectionControl>

<ghfvs:SectionControl Name="reviewsSection"
HeaderText="{x:Static ghfvs:Resources.Reviewers}"
Expand DownExpand Up@@ -223,7 +255,7 @@
HeaderText="{Binding Files.ChangedFilesCount, StringFormat={x:Static ghfvs:Resources.ChangesCountFormat}}"
Margin="0 8 10 0"
ghfvs:ScrollingVerticalStackPanel.IsFixed="true"/>

<!-- Put the changes tree outside its expander, so it can scroll horizontally
while the header remains fixed -->
<local:PullRequestFilesView DataContext="{Binding Files}"
Expand Down