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

Commit 7cf4eba

Browse files
Displaing inline annotations
1 parent 657292e commit 7cf4eba

17 files changed

+187
-38
lines changed

src/GitHub.Exports.Reactive/Models/IInlineAnnotationModel.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ public interface IInlineAnnotationModel
77
{
88
int StartLine { get; }
99
int EndLine { get; }
10+
string Title { get; }
1011
CheckAnnotationLevel AnnotationLevel { get; }
12+
string Message { get; }
13+
string FileName { get; }
14+
string LineDescription { get; }
1115
}
1216
}

src/GitHub.Exports.Reactive/Models/InlineAnnotationModel.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,31 @@ namespace GitHub.Models
44
{
55
public class InlineAnnotationModel: IInlineAnnotationModel
66
{
7-
private CheckRunModel checkRun;
8-
private CheckRunAnnotationModel annotation;
7+
readonly CheckRunModel checkRun;
8+
readonly CheckRunAnnotationModel annotation;
99

1010
public InlineAnnotationModel(CheckRunModel checkRun, CheckRunAnnotationModel annotation)
1111
{
12+
Guard.ArgumentNotNull(checkRun, nameof(checkRun));
13+
Guard.ArgumentNotNull(annotation, nameof(annotation));
1214
Guard.ArgumentNotNull(annotation.AnnotationLevel, nameof(annotation.AnnotationLevel));
1315

1416
this.checkRun = checkRun;
1517
this.annotation = annotation;
1618
}
1719

20+
public string FileName => annotation.Filename;
21+
1822
public int StartLine => annotation.StartLine;
1923

2024
public int EndLine => annotation.EndLine;
2125

26+
public string Title => annotation.Title;
27+
2228
public CheckAnnotationLevel AnnotationLevel => annotation.AnnotationLevel.Value;
29+
30+
public string Message => annotation.Message;
31+
32+
public string LineDescription => $"{StartLine}:{EndLine}";
2333
}
2434
}

src/GitHub.InlineReviews/GitHub.InlineReviews.csproj

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
<Compile Include="Margins\InlineCommentMargin.cs" />
8585
<Compile Include="Margins\InlineCommentMarginVisible.cs" />
8686
<Compile Include="Margins\InlineCommentMarginEnabled.cs" />
87+
<Compile Include="SampleData\InlineAnnotationViewModelDesigner.cs" />
8788
<Compile Include="Services\CommentService.cs" />
8889
<Compile Include="Services\ICommentService.cs" />
8990
<Compile Include="PullRequestStatusBarPackage.cs" />
@@ -116,6 +117,8 @@
116117
<Compile Include="Tags\ShowInlineCommentAnnotationGlyph.xaml.cs">
117118
<DependentUpon>ShowInlineCommentAnnotationGlyph.xaml</DependentUpon>
118119
</Compile>
120+
<Compile Include="ViewModels\IInlineAnnotationViewModel.cs" />
121+
<Compile Include="ViewModels\InlineAnnotationViewModel.cs" />
119122
<Compile Include="ViewModels\PullRequestFileMarginViewModel.cs" />
120123
<Compile Include="ViewModels\CommentViewModel.cs" />
121124
<Compile Include="ViewModels\IInlineReviewViewModel.cs" />
@@ -125,14 +128,17 @@
125128
<Compile Include="ViewModels\NewCommentThreadInlineReviewViewModel.cs" />
126129
<Compile Include="ViewModels\PullRequestReviewCommentViewModel.cs" />
127130
<Compile Include="ViewModels\PullRequestStatusViewModel.cs" />
131+
<Compile Include="Views\InlineAnnotationView.xaml.cs">
132+
<DependentUpon>InlineAnnotationView.xaml</DependentUpon>
133+
</Compile>
128134
<Compile Include="Views\PullRequestFileMarginView.xaml.cs">
129135
<DependentUpon>PullRequestFileMarginView.xaml</DependentUpon>
130136
</Compile>
131137
<Compile Include="Views\GlyphMarginGrid.xaml.cs">
132138
<DependentUpon>GlyphMarginGrid.xaml</DependentUpon>
133139
</Compile>
134-
<Compile Include="Views\InlineCommentPeekView.xaml.cs">
135-
<DependentUpon>InlineCommentPeekView.xaml</DependentUpon>
140+
<Compile Include="Views\InlineReviewPeekView.xaml.cs">
141+
<DependentUpon>InlineReviewPeekView.xaml</DependentUpon>
136142
</Compile>
137143
<Compile Include="SampleData\CommentViewModelDesigner.cs" />
138144
<Compile Include="Services\DiffService.cs" />
@@ -151,8 +157,8 @@
151157
<Compile Include="Tags\InlineCommentTaggerProvider.cs" />
152158
<Compile Include="ViewModels\CommentThreadInlineReviewViewModel.cs" />
153159
<Compile Include="ViewModels\ICommentViewModel.cs" />
154-
<Compile Include="Views\CommentThreadView.xaml.cs">
155-
<DependentUpon>CommentThreadView.xaml</DependentUpon>
160+
<Compile Include="Views\InlineReviewView.xaml.cs">
161+
<DependentUpon>InlineReviewView.xaml</DependentUpon>
156162
</Compile>
157163
<Compile Include="Views\CommentView.xaml.cs">
158164
<DependentUpon>CommentView.xaml</DependentUpon>
@@ -449,6 +455,10 @@
449455
<Generator>MSBuild:Compile</Generator>
450456
<SubType>Designer</SubType>
451457
</Page>
458+
<Page Include="Views\InlineAnnotationView.xaml">
459+
<Generator>MSBuild:Compile</Generator>
460+
<SubType>Designer</SubType>
461+
</Page>
452462
<Page Include="Views\PullRequestFileMarginView.xaml">
453463
<SubType>Designer</SubType>
454464
<Generator>MSBuild:Compile</Generator>
@@ -457,7 +467,7 @@
457467
<SubType>Designer</SubType>
458468
<Generator>MSBuild:Compile</Generator>
459469
</Page>
460-
<Page Include="Views\InlineCommentPeekView.xaml">
470+
<Page Include="Views\InlineReviewPeekView.xaml">
461471
<SubType>Designer</SubType>
462472
<Generator>MSBuild:Compile</Generator>
463473
</Page>
@@ -469,7 +479,7 @@
469479
<Generator>MSBuild:Compile</Generator>
470480
<SubType>Designer</SubType>
471481
</Page>
472-
<Page Include="Views\CommentThreadView.xaml">
482+
<Page Include="Views\InlineReviewView.xaml">
473483
<Generator>MSBuild:Compile</Generator>
474484
<SubType>Designer</SubType>
475485
</Page>

src/GitHub.InlineReviews/Peek/InlineCommentPeekResultPresentation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class InlineCommentPeekResultPresentation : IPeekResultPresentation, IDesiredHei
1010
{
1111
const double PeekBorders = 28.0;
1212
readonly InlineReviewPeekViewModel viewModel;
13-
InlineCommentPeekView view;
13+
InlineReviewPeekView view;
1414
double desiredHeight;
1515

1616
public bool IsDirty => false;
@@ -72,7 +72,7 @@ public void Close()
7272

7373
public UIElement Create(IPeekSession session, IPeekResultScrollState scrollState)
7474
{
75-
view = new InlineCommentPeekView();
75+
view = new InlineReviewPeekView();
7676
view.DataContext = viewModel;
7777

7878
// Report the desired size back to the peek view. Unfortunately the peek view
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Collections.Generic;
2+
using GitHub.InlineReviews.ViewModels;
3+
using GitHub.Models;
4+
5+
namespace GitHub.InlineReviews.SampleData
6+
{
7+
public class InlineAnnotationViewModelDesigner : IInlineAnnotationViewModel
8+
{
9+
public InlineAnnotationViewModelDesigner()
10+
{
11+
var checkRunAnnotationModel = new CheckRunAnnotationModel
12+
{
13+
AnnotationLevel = CheckAnnotationLevel.Failure,
14+
Filename = "SomeFile.cs",
15+
EndLine = 12,
16+
StartLine = 12,
17+
Message = "Some Error Message",
18+
Title = "CS12345"
19+
};
20+
21+
var checkRunModel =
22+
new CheckRunModel
23+
{
24+
Annotations = new List<CheckRunAnnotationModel> {checkRunAnnotationModel},
25+
Name = "Fake Check Run"
26+
};
27+
28+
Model= new InlineAnnotationModel(checkRunModel, checkRunAnnotationModel);
29+
}
30+
31+
public IInlineAnnotationModel Model { get; }
32+
}
33+
}

src/GitHub.InlineReviews/SampleData/InlineReviewViewModelDesigner.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Collections.ObjectModel;
34
using System.Diagnostics.CodeAnalysis;
45
using System.Reactive;
@@ -12,9 +13,24 @@ namespace GitHub.InlineReviews.SampleData
1213
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")]
1314
class InlineReviewViewModelDesigner : IInlineReviewViewModel
1415
{
16+
public InlineReviewViewModelDesigner()
17+
{
18+
var checkRunModel = new CheckRunModel()
19+
{
20+
21+
};
22+
23+
Annotations = new[]
24+
{
25+
new InlineAnnotationViewModel(new InlineAnnotationModel(checkRunModel, new CheckRunAnnotationModel{ }))
26+
};
27+
}
28+
1529
public ObservableCollection<ICommentViewModel> Comments { get; }
1630
= new ObservableCollection<ICommentViewModel>();
1731

32+
public IReadOnlyList<IInlineAnnotationViewModel> Annotations { get; }
33+
1834
public IActorViewModel CurrentUser { get; set; }
1935
= new ActorViewModel { Login = "shana" };
2036

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using GitHub.Models;
2+
3+
namespace GitHub.InlineReviews.ViewModels
4+
{
5+
public interface IInlineAnnotationViewModel
6+
{
7+
IInlineAnnotationModel Model { get; }
8+
}
9+
}

src/GitHub.InlineReviews/ViewModels/IInlineReviewViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Collections.ObjectModel;
34
using System.Reactive;
45
using GitHub.Models;
@@ -36,5 +37,7 @@ public interface IInlineReviewViewModel
3637
/// Called by a comment in the thread to send a delete of the comment to the API.
3738
/// </summary>
3839
ReactiveCommand<Unit> DeleteComment { get; }
40+
41+
IReadOnlyList<IInlineAnnotationViewModel> Annotations { get; }
3942
}
4043
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using GitHub.Models;
2+
3+
namespace GitHub.InlineReviews.ViewModels
4+
{
5+
public class InlineAnnotationViewModel: IInlineAnnotationViewModel
6+
{
7+
public IInlineAnnotationModel Model { get; }
8+
9+
public InlineAnnotationViewModel(IInlineAnnotationModel model)
10+
{
11+
Model = model;
12+
}
13+
}
14+
}

src/GitHub.InlineReviews/ViewModels/InlineReviewPeekViewModel.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,4 @@ string GetPlaceholderBodyToPreserve()
235235
return null;
236236
}
237237
}
238-
239-
public class InlineAnnotationViewModel
240-
{
241-
readonly IInlineAnnotationModel model;
242-
243-
public InlineAnnotationViewModel(IInlineAnnotationModel model)
244-
{
245-
this.model = model;
246-
}
247-
}
248238
}

0 commit comments

Comments
 (0)