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

Commit adfada0

Browse files
committed
Merge branch 'features/check-suite-annotations-inline' of https://github.com/github/VisualStudio into features/check-suite-annotations-inline
2 parents cf78034 + 88d9af7 commit adfada0

File tree

11 files changed

+47
-108
lines changed

11 files changed

+47
-108
lines changed

src/GitHub.App/SampleData/CommentThreadViewModelDesigner.cs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -12,58 +12,6 @@ public class CommentThreadViewModelDesigner : ViewModelBase, ICommentThreadViewM
1212
{
1313
public CommentThreadViewModelDesigner()
1414
{
15-
16-
var checkRunAnnotationModel1 = new CheckRunAnnotationModel
17-
{
18-
AnnotationLevel = CheckAnnotationLevel.Failure,
19-
Path = "SomeFile.cs",
20-
EndLine = 12,
21-
StartLine = 12,
22-
Message = "CS12345: ; expected",
23-
Title = "CS12345"
24-
};
25-
26-
var checkRunAnnotationModel2 = new CheckRunAnnotationModel
27-
{
28-
AnnotationLevel = CheckAnnotationLevel.Warning,
29-
Path = "SomeFile.cs",
30-
EndLine = 12,
31-
StartLine = 12,
32-
Message = "CS12345: ; expected",
33-
Title = "CS12345"
34-
};
35-
36-
var checkRunAnnotationModel3 = new CheckRunAnnotationModel
37-
{
38-
AnnotationLevel = CheckAnnotationLevel.Notice,
39-
Path = "SomeFile.cs",
40-
EndLine = 12,
41-
StartLine = 12,
42-
Message = "CS12345: ; expected",
43-
Title = "CS12345"
44-
};
45-
46-
var checkRunModel =
47-
new CheckRunModel
48-
{
49-
Annotations = new List<CheckRunAnnotationModel> { checkRunAnnotationModel1, checkRunAnnotationModel2 },
50-
Name = "MSBuildLog Analyzer"
51-
};
52-
53-
var checkSuiteModel = new CheckSuiteModel()
54-
{
55-
HeadSha = "ed6198c37b13638e902716252b0a17d54bd59e4a",
56-
CheckRuns = new List<CheckRunModel> { checkRunModel },
57-
ApplicationName = "My Awesome Check Suite"
58-
};
59-
60-
Annotations = new[]
61-
{
62-
new InlineAnnotationViewModel(new InlineAnnotationModel(checkSuiteModel, checkRunModel, checkRunAnnotationModel1)),
63-
new InlineAnnotationViewModel(new InlineAnnotationModel(checkSuiteModel, checkRunModel, checkRunAnnotationModel2)),
64-
new InlineAnnotationViewModel(new InlineAnnotationModel(checkSuiteModel, checkRunModel, checkRunAnnotationModel3)),
65-
};
66-
6715
Comments = new ReactiveList<ICommentViewModel>(){new CommentViewModelDesigner()
6816
{
6917
Author = new ActorViewModel{ Login = "shana"},
@@ -75,8 +23,6 @@ public CommentThreadViewModelDesigner()
7523
public IReadOnlyReactiveList<ICommentViewModel> Comments { get; }
7624
= new ReactiveList<ICommentViewModel>();
7725

78-
public IReadOnlyList<IInlineAnnotationViewModel> Annotations { get; }
79-
8026
public IActorViewModel CurrentUser { get; set; }
8127
= new ActorViewModel { Login = "shana" };
8228

src/GitHub.App/ViewModels/CommentThreadViewModel.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ public CommentThreadViewModel(
5757
/// <inheritdoc/>
5858
public IActorViewModel CurrentUser { get; private set; }
5959

60-
/// <inheritdoc/>
61-
public IReadOnlyList<IInlineAnnotationViewModel> Annotations { get; private set; }
62-
6360
/// <inheritdoc/>
6461
IReadOnlyReactiveList<ICommentViewModel> ICommentThreadViewModel.Comments => comments;
6562

@@ -95,10 +92,8 @@ protected IDisposable AddPlaceholder(ICommentViewModel placeholder)
9592
/// Intializes a new instance of the <see cref="CommentThreadViewModel"/> class.
9693
/// </summary>
9794
/// <param name="currentUser">The current user.</param>
98-
/// <param name="annotations"></param>
99-
protected Task InitializeAsync(ActorModel currentUser, IReadOnlyList<IInlineAnnotationViewModel> annotations)
95+
protected Task InitializeAsync(ActorModel currentUser)
10096
{
101-
Annotations = annotations;
10297
Guard.ArgumentNotNull(currentUser, nameof(currentUser));
10398
CurrentUser = new ActorViewModel(currentUser);
10499
return Task.CompletedTask;

src/GitHub.App/ViewModels/PullRequestReviewCommentThreadViewModel.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,13 @@ public bool IsNewThread
7777

7878
/// <inheritdoc/>
7979
public async Task InitializeAsync(IPullRequestSession session,
80-
IReadOnlyList<IInlineAnnotationViewModel> annotations,
8180
IPullRequestSessionFile file,
8281
IInlineCommentThreadModel thread,
8382
bool addPlaceholder)
8483
{
8584
Guard.ArgumentNotNull(session, nameof(session));
8685

87-
await base.InitializeAsync(session.User, annotations).ConfigureAwait(true);
86+
await base.InitializeAsync(session.User).ConfigureAwait(true);
8887

8988
Session = session;
9089
File = file;
@@ -129,15 +128,14 @@ await vm.InitializeAsPlaceholderAsync(
129128
/// <inheritdoc/>
130129
public async Task InitializeNewAsync(
131130
IPullRequestSession session,
132-
IInlineAnnotationViewModel[] annotations,
133131
IPullRequestSessionFile file,
134132
int lineNumber,
135133
DiffSide side,
136134
bool isEditing)
137135
{
138136
Guard.ArgumentNotNull(session, nameof(session));
139137

140-
await base.InitializeAsync(session.User, annotations).ConfigureAwait(false);
138+
await base.InitializeAsync(session.User).ConfigureAwait(false);
141139

142140
Session = session;
143141
File = file;

src/GitHub.Exports.Reactive/ViewModels/ICommentThreadViewModel.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Threading.Tasks;
43
using ReactiveUI;
54

@@ -37,10 +36,5 @@ public interface ICommentThreadViewModel : IViewModel
3736
/// </summary>
3837
/// <param name="comment">The comment to delete.</param>
3938
Task DeleteComment(ICommentViewModel comment);
40-
41-
/// <summary>
42-
/// Gets the annotations displayed.
43-
/// </summary>
44-
IReadOnlyList<IInlineAnnotationViewModel> Annotations { get; }
4539
}
4640
}

src/GitHub.Exports.Reactive/ViewModels/IPullRequestReviewCommentThreadViewModel.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@ public interface IPullRequestReviewCommentThreadViewModel : ICommentThreadViewMo
4646
/// Initializes the view model with data.
4747
/// </summary>
4848
/// <param name="session">The pull request session.</param>
49-
/// <param name="annotations"></param>
5049
/// <param name="file">The file that the comment is on.</param>
5150
/// <param name="thread">The thread.</param>
5251
/// <param name="addPlaceholder">
5352
/// Whether to add a placeholder comment at the end of the thread.
5453
/// </param>
5554
Task InitializeAsync(IPullRequestSession session,
56-
IReadOnlyList<IInlineAnnotationViewModel> annotations,
5755
IPullRequestSessionFile file,
5856
IInlineCommentThreadModel thread,
5957
bool addPlaceholder);
@@ -66,9 +64,7 @@ Task InitializeAsync(IPullRequestSession session,
6664
/// <param name="lineNumber">The 0-based line number of the thread.</param>
6765
/// <param name="side">The side of the diff.</param>
6866
/// <param name="isEditing">Whether to start the placeholder in edit state.</param>
69-
Task InitializeNewAsync(
70-
IPullRequestSession session,
71-
IInlineAnnotationViewModel[] annotations,
67+
Task InitializeNewAsync(IPullRequestSession session,
7268
IPullRequestSessionFile file,
7369
int lineNumber,
7470
DiffSide side,

src/GitHub.InlineReviews/ViewModels/InlineCommentPeekViewModel.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public sealed class InlineCommentPeekViewModel : ReactiveObject, IDisposable
3333
IPullRequestSession session;
3434
IPullRequestSessionFile file;
3535
IPullRequestReviewCommentThreadViewModel thread;
36+
IReadOnlyList<IInlineAnnotationViewModel> annotations;
3637
IDisposable fileSubscription;
3738
IDisposable sessionSubscription;
3839
IDisposable threadSubscription;
@@ -86,6 +87,15 @@ public InlineCommentPeekViewModel(IInlineCommentPeekService peekService,
8687
Observable.Return(previousCommentCommand.Enabled));
8788
}
8889

90+
/// <summary>
91+
/// Gets the annotations displayed.
92+
/// </summary>
93+
public IReadOnlyList<IInlineAnnotationViewModel> Annotations
94+
{
95+
get { return annotations; }
96+
private set { this.RaiseAndSetIfChanged(ref annotations, value); }
97+
}
98+
8999
/// <summary>
90100
/// Gets the thread of comments to display.
91101
/// </summary>
@@ -168,6 +178,8 @@ async Task UpdateThread()
168178
Thread = null;
169179
threadSubscription?.Dispose();
170180

181+
Annotations = null;
182+
171183
if (file == null)
172184
return;
173185

@@ -178,22 +190,22 @@ async Task UpdateThread()
178190
x.LineNumber == lineNumber &&
179191
((leftBuffer && x.DiffLineType == DiffChangeType.Delete) || (!leftBuffer && x.DiffLineType != DiffChangeType.Delete)));
180192

181-
var annotationModels = file.InlineAnnotations?.Where(model => model.EndLine - 1 == lineNumber)
193+
Annotations = file.InlineAnnotations?.Where(model => model.EndLine - 1 == lineNumber)
182194
.Select(model => new InlineAnnotationViewModel(model))
183195
.ToArray();
184196

185-
var vm = factory.CreateViewModel<IPullRequestReviewCommentThreadViewModel>();
197+
var threadModel = factory.CreateViewModel<IPullRequestReviewCommentThreadViewModel>();
186198

187199
if (thread?.Comments.Count > 0)
188200
{
189-
await vm.InitializeAsync(session, annotationModels, file, thread, true);
201+
await threadModel.InitializeAsync(session, file, thread, true);
190202
}
191203
else
192204
{
193-
await vm.InitializeNewAsync(session, annotationModels, file, lineNumber, side, true);
205+
await threadModel.InitializeNewAsync(session, file, lineNumber, side, true);
194206
}
195207

196-
Thread = vm;
208+
Thread = threadModel;
197209
}
198210

199211
async Task SessionChanged(IPullRequestSession pullRequestSession)

src/GitHub.InlineReviews/Views/InlineCommentPeekView.xaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,17 @@
104104
<ScrollViewer Name="threadScroller"
105105
VerticalScrollBarVisibility="Auto"
106106
Background="{DynamicResource GitHubPeekViewBackground}">
107-
<ghfvs:CommentThreadView x:Name="threadView" DataContext="{Binding Thread}"/>
107+
<StackPanel Orientation="Vertical" Margin="0 0 0 4">
108+
<ItemsControl x:Name="annotationsView" ItemsSource="{Binding Annotations}">
109+
<ItemsControl.ItemTemplate>
110+
<DataTemplate>
111+
<ghfvs:InlineAnnotationView />
112+
</DataTemplate>
113+
</ItemsControl.ItemTemplate>
114+
</ItemsControl>
115+
116+
<ghfvs:CommentThreadView x:Name="threadView" DataContext="{Binding Thread}"/>
117+
</StackPanel>
108118
</ScrollViewer>
109119
</DockPanel>
110120
</UserControl>

src/GitHub.InlineReviews/Views/InlineCommentPeekView.xaml.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@ public InlineCommentPeekView()
1515
InitializeComponent();
1616

1717
desiredHeight = new Subject<double>();
18-
threadView.LayoutUpdated += ThreadViewLayoutUpdated;
18+
threadView.LayoutUpdated += ChildLayoutUpdated;
19+
annotationsView.LayoutUpdated += ChildLayoutUpdated;
1920
threadScroller.PreviewMouseWheel += ScrollViewerUtilities.FixMouseWheelScroll;
2021
}
2122

2223
public IObservable<double> DesiredHeight => desiredHeight;
2324

24-
void ThreadViewLayoutUpdated(object sender, EventArgs e)
25+
void ChildLayoutUpdated(object sender, EventArgs e)
2526
{
2627
var otherControlsHeight = ActualHeight - threadScroller.ActualHeight;
2728
var threadViewHeight = threadView.DesiredSize.Height + threadView.Margin.Top + threadView.Margin.Bottom;
28-
desiredHeight.OnNext(threadViewHeight + otherControlsHeight);
29+
var annotationsViewHeight = annotationsView.DesiredSize.Height + annotationsView.Margin.Top + annotationsView.Margin.Bottom;
30+
desiredHeight.OnNext(threadViewHeight + annotationsViewHeight + otherControlsHeight);
2931
}
3032
}
3133
}

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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,12 @@
1010
<sampleData:CommentThreadViewModelDesigner />
1111
</d:DesignProperties.DataContext>
1212

13-
<StackPanel Orientation="Vertical" Margin="0 0 0 4">
14-
<ItemsControl ItemsSource="{Binding Annotations}">
15-
<ItemsControl.ItemTemplate>
16-
<DataTemplate>
17-
<local:InlineAnnotationView />
18-
</DataTemplate>
19-
</ItemsControl.ItemTemplate>
20-
</ItemsControl>
21-
22-
<ItemsControl ItemsSource="{Binding Comments}">
23-
<ItemsControl.ItemTemplate>
24-
<DataTemplate>
25-
<local:CommentView Margin="0"/>
26-
</DataTemplate>
27-
</ItemsControl.ItemTemplate>
28-
</ItemsControl>
29-
</StackPanel>
13+
<ItemsControl ItemsSource="{Binding Comments}">
14+
<ItemsControl.ItemTemplate>
15+
<DataTemplate>
16+
<local:CommentView />
17+
</DataTemplate>
18+
</ItemsControl.ItemTemplate>
19+
</ItemsControl>
3020
</UserControl>
3121

src/GitHub.VisualStudio.UI/Views/CommentThreadView.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public partial class CommentThreadView : UserControl
99
public CommentThreadView()
1010
{
1111
InitializeComponent();
12-
PreviewMouseWheel += ScrollViewerUtilities.FixMouseWheelScroll;
1312
}
1413
}
1514
}

0 commit comments

Comments
 (0)