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

Commit 02bc4ee

Browse files
committed
Display sample data in PR conversation page.
1 parent cfb1dd3 commit 02bc4ee

File tree

11 files changed

+131
-30
lines changed

11 files changed

+131
-30
lines changed

src/GitHub.App/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
[assembly: XmlnsDefinition("https://github.com/github/VisualStudio", "GitHub.ViewModels")]
77
[assembly: XmlnsDefinition("https://github.com/github/VisualStudio", "GitHub.ViewModels.Dialog")]
88
[assembly: XmlnsDefinition("https://github.com/github/VisualStudio", "GitHub.ViewModels.Dialog.Clone")]
9+
[assembly: XmlnsDefinition("https://github.com/github/VisualStudio", "GitHub.ViewModels.Documents")]
910
[assembly: XmlnsDefinition("https://github.com/github/VisualStudio", "GitHub.ViewModels.GitHubPane")]

src/GitHub.App/SampleData/CommentViewModelDesigner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public CommentViewModelDesigner()
3333
public ReactiveCommand<Unit, Unit> BeginEdit { get; }
3434
public ReactiveCommand<Unit, Unit> CancelEdit { get; }
3535
public ReactiveCommand<Unit, Unit> CommitEdit { get; }
36-
public ReactiveCommand<Unit, Unit> OpenOnGitHub { get; }
36+
public ReactiveCommand<Unit, Unit> OpenOnGitHub { get; } = ReactiveCommand.Create(() => { });
3737
public ReactiveCommand<Unit, Unit> Delete { get; }
3838

3939
public Task InitializeAsync(ICommentThreadViewModel thread, ActorModel currentUser, CommentModel comment, CommentEditState state)

src/GitHub.App/SampleData/Documents/PullRequestPageViewModelDesigner.cs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Reactive;
34
using System.Threading.Tasks;
45
using GitHub.Models;
@@ -53,10 +54,38 @@ public PullRequestPageViewModelDesigner()
5354
5455
Depends on #1993
5556
Fixes #1905";
57+
Timeline = new IViewModel[]
58+
{
59+
new CommitSummariesViewModel(
60+
new CommitSummaryViewModel(new CommitModel
61+
{
62+
Author = new ActorModel { Login = "grokys" },
63+
AbbreviatedOid = "c7c7d25",
64+
MessageHeadline = "Refactor comment view models."
65+
}),
66+
new CommitSummaryViewModel(new CommitModel
67+
{
68+
Author = new ActorModel { Login = "grokys" },
69+
AbbreviatedOid = "04e6a90",
70+
MessageHeadline = "Refactor comment view models.",
71+
})),
72+
new CommentViewModelDesigner
73+
{
74+
Author = new ActorViewModelDesigner("meaghanlewis"),
75+
Body = @"This is looking great! Really enjoying using this feature so far.
76+
77+
When leaving an inline comment, the comment posts successfully and then a new comment is drafted with the same text.",
78+
},
79+
new CommentViewModelDesigner
80+
{
81+
Author = new ActorViewModelDesigner("grokys"),
82+
Body = @"Oops, sorry about that @meaghanlewis - I was sure I tested those things, but must have got messed up again at some point. Should be fixed now.",
83+
},
84+
};
5685
}
5786

5887
public PullRequestState State { get; set; } = PullRequestState.Open;
59-
public IIssueishCommentThreadViewModel Thread { get; set; }
88+
public IReadOnlyList<IViewModel> Timeline { get; }
6089
public string SourceBranchDisplayName { get; set; } = "feature/save-drafts";
6190
public string TargetBranchDisplayName { get; set; } = "master";
6291
public IActorViewModel Author { get; set; } = new ActorViewModelDesigner("grokys");
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Collections.Generic;
2+
3+
namespace GitHub.ViewModels.Documents
4+
{
5+
public class CommitSummariesViewModel : ViewModelBase
6+
{
7+
public CommitSummariesViewModel(params CommitSummaryViewModel[] commits)
8+
{
9+
Commits = commits;
10+
}
11+
12+
public IReadOnlyList<CommitSummaryViewModel> Commits { get; }
13+
}
14+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using GitHub.Models;
33
using GitHub.ViewModels;
44

5-
namespace GitHub.App.ViewModels.Documents
5+
namespace GitHub.ViewModels.Documents
66
{
77
public class CommitSummaryViewModel : ViewModelBase
88
{

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

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.ComponentModel.Composition;
34
using System.Threading.Tasks;
45
using GitHub.Extensions;
56
using GitHub.Factories;
67
using GitHub.Models;
8+
using GitHub.SampleData;
79
using GitHub.Services;
10+
using ReactiveUI;
811

912
namespace GitHub.ViewModels.Documents
1013
{
@@ -35,7 +38,7 @@ public PullRequestPageViewModel(
3538
}
3639

3740
/// <inheritdoc/>
38-
public IIssueishCommentThreadViewModel Thread { get; private set; }
41+
public IReadOnlyList<IViewModel> Timeline { get; private set; }
3942

4043
/// <inheritdoc/>
4144
public async Task InitializeAsync(
@@ -44,12 +47,34 @@ public async Task InitializeAsync(
4447
{
4548
await base.InitializeAsync(model).ConfigureAwait(true);
4649

47-
var thread = factory.CreateViewModel<IIssueishCommentThreadViewModel>();
48-
await thread.InitializeAsync(
49-
currentUser,
50-
model,
51-
true).ConfigureAwait(true);
52-
Thread = thread;
50+
Timeline = new IViewModel[]
51+
{
52+
new CommitSummariesViewModel(
53+
new CommitSummaryViewModel(new CommitModel
54+
{
55+
Author = new ActorModel { Login = "grokys" },
56+
AbbreviatedOid = "c7c7d25",
57+
MessageHeadline = "Refactor comment view models."
58+
}),
59+
new CommitSummaryViewModel(new CommitModel
60+
{
61+
Author = new ActorModel { Login = "grokys" },
62+
AbbreviatedOid = "04e6a90",
63+
MessageHeadline = "Refactor comment view models.",
64+
})),
65+
new CommentViewModelDesigner
66+
{
67+
Author = new ActorViewModelDesigner("meaghanlewis"),
68+
Body = @"This is looking great! Really enjoying using this feature so far.
69+
70+
When leaving an inline comment, the comment posts successfully and then a new comment is drafted with the same text.",
71+
},
72+
new CommentViewModelDesigner
73+
{
74+
Author = new ActorViewModelDesigner("grokys"),
75+
Body = @"Oops, sorry about that @meaghanlewis - I was sure I tested those things, but must have got messed up again at some point. Should be fixed now.",
76+
},
77+
};
5378
}
5479
}
5580
}

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

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/GitHub.Exports.Reactive/ViewModels/Documents/IPullRequestPageViewModel.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Threading.Tasks;
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
23
using GitHub.Models;
34

45
namespace GitHub.ViewModels.Documents
@@ -9,9 +10,9 @@ namespace GitHub.ViewModels.Documents
910
public interface IPullRequestPageViewModel : IPullRequestViewModelBase
1011
{
1112
/// <summary>
12-
/// Gets the pull request's comment thread.
13+
/// Gets the pull request's timeline.
1314
/// </summary>
14-
IIssueishCommentThreadViewModel Thread { get; }
15+
IReadOnlyList<IViewModel> Timeline { get; }
1516

1617
/// <summary>
1718
/// Initializes the view model with data.

src/GitHub.Exports/Models/CommitModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ namespace GitHub.Models
77
/// </summary>
88
public class CommitModel
99
{
10+
/// <summary>
11+
/// Gets or sets the author of the commit.
12+
/// </summary>
13+
public ActorModel Author { get; set; }
14+
1015
/// <summary>
1116
/// Gets the abbreviated git object ID for the commit.
1217
/// </summary>

src/GitHub.VisualStudio.UI/Views/CommentView.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151

5252
<DockPanel>
5353
<StackPanel Orientation="Horizontal" DockPanel.Dock="Left" >
54-
<controls:AccountAvatar Width="16"
55-
Height="16"
56-
Account="{Binding Author}"/>
54+
<views:ActorAvatarView Width="16"
55+
Height="16"
56+
ViewModel="{Binding Author}"/>
5757

5858
<TextBlock Foreground="{DynamicResource GitHubVsToolWindowText}" FontWeight="Bold" Text="{Binding Author.Login}" Margin="4 0"/>
5959
<ui:GitHubActionLink Content="{Binding UpdatedAt, Converter={ui:DurationToStringConverter}}"

0 commit comments

Comments
 (0)