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

Commit 0db9892

Browse files
Backporting some fixes
1 parent cf37806 commit 0db9892

File tree

15 files changed

+122
-44
lines changed

15 files changed

+122
-44
lines changed

src/GitHub.App/SampleData/PullRequestAnnotationsViewModelDesigner.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public sealed class PullRequestAnnotationsViewModelDesigner : PanePageViewModelB
2525
AnnotationLevel = CheckAnnotationLevel.Notice,
2626
StartLine = 3,
2727
EndLine = 4,
28-
Filename = "asdf/asdf.cs",
28+
Path = "asdf/asdf.cs",
2929
Message = "; is expected",
3030
Title = "CS 12345"
3131
}),
@@ -34,7 +34,7 @@ public sealed class PullRequestAnnotationsViewModelDesigner : PanePageViewModelB
3434
AnnotationLevel = CheckAnnotationLevel.Warning,
3535
StartLine = 3,
3636
EndLine = 4,
37-
Filename = "asdf/asdf.cs",
37+
Path = "asdf/asdf.cs",
3838
Message = "; is expected",
3939
Title = "CS 12345"
4040
}),
@@ -43,7 +43,7 @@ public sealed class PullRequestAnnotationsViewModelDesigner : PanePageViewModelB
4343
AnnotationLevel = CheckAnnotationLevel.Failure,
4444
StartLine = 3,
4545
EndLine = 4,
46-
Filename = "blah.cs",
46+
Path = "blah.cs",
4747
Message = "; is expected",
4848
Title = "CS 12345"
4949
})

src/GitHub.App/ViewModels/GitHubPane/PullRequestAnnotationItemViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ public class PullRequestAnnotationItemViewModel : ViewModelBase, IPullRequestAnn
99
{
1010
bool isExpanded;
1111

12-
public PullRequestAnnotationItemViewModel(CheckRunAnnotationModel model)
12+
public PullRequestAnnotationItemViewModel(CheckRunAnnotationModel annotation)
1313
{
14-
this.Model = model;
14+
this.Annotation = annotation;
1515
}
1616

17-
public CheckRunAnnotationModel Model { get; }
17+
public CheckRunAnnotationModel Annotation { get; }
1818

19-
public string LineDescription => $"{Model.StartLine}:{Model.EndLine}";
19+
public string LineDescription => $"{Annotation.StartLine}:{Annotation.EndLine}";
2020

2121
public bool IsExpanded
2222
{

src/GitHub.App/ViewModels/GitHubPane/PullRequestFileNode.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ namespace GitHub.ViewModels.GitHubPane
1313
public class PullRequestFileNode : ReactiveObject, IPullRequestFileNode
1414
{
1515
int commentCount;
16+
int annotationNoticeCount;
1617
int annotationWarningCount;
17-
int annotationErrorCount;
18+
int _annotationFailureCount;
1819

1920
/// <summary>
2021
/// Initializes a new instance of the <see cref="PullRequestFileNode"/> class.
@@ -102,6 +103,15 @@ public int CommentCount
102103
set { this.RaiseAndSetIfChanged(ref commentCount, value); }
103104
}
104105

106+
/// <summary>
107+
/// Gets or sets the number of annotation notices on the file.
108+
/// </summary>
109+
public int AnnotationNoticeCount
110+
{
111+
get { return annotationNoticeCount; }
112+
set { this.RaiseAndSetIfChanged(ref annotationNoticeCount, value); }
113+
}
114+
105115
/// <summary>
106116
/// Gets or sets the number of annotation errors on the file.
107117
/// </summary>
@@ -112,12 +122,12 @@ public int AnnotationWarningCount
112122
}
113123

114124
/// <summary>
115-
/// Gets or sets the number of annotation errors on the file.
125+
/// Gets or sets the number of annotation failures on the file.
116126
/// </summary>
117-
public int AnnotationErrorCount
127+
public int AnnotationFailureCount
118128
{
119-
get { return annotationErrorCount; }
120-
set { this.RaiseAndSetIfChanged(ref annotationErrorCount, value); }
129+
get { return _annotationFailureCount; }
130+
set { this.RaiseAndSetIfChanged(ref _annotationFailureCount, value); }
121131
}
122132
}
123133
}

src/GitHub.App/ViewModels/GitHubPane/PullRequestFilesViewModel.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,18 @@ public async Task InitializeAsync(
123123
{
124124
subscriptions.Add(file.WhenAnyValue(x => x.InlineCommentThreads)
125125
.Subscribe(x => node.CommentCount = CountComments(x, filter)));
126+
127+
subscriptions.Add(file.WhenAnyValue(x => x.InlineAnnotations)
128+
.Subscribe(x =>
129+
{
130+
var noticeCount = x.Count(model => model.AnnotationLevel == CheckAnnotationLevel.Notice);
131+
var warningCount = x.Count(model => model.AnnotationLevel == CheckAnnotationLevel.Warning);
132+
var failureCount = x.Count(model => model.AnnotationLevel == CheckAnnotationLevel.Failure);
133+
134+
node.AnnotationNoticeCount = noticeCount;
135+
node.AnnotationWarningCount = warningCount;
136+
node.AnnotationFailureCount = failureCount;
137+
}));
126138
}
127139

128140
var dir = GetDirectory(Path.GetDirectoryName(node.RelativePath), dirs);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ public interface IPullRequestSessionFile : INotifyPropertyChanged
5454
/// </summary>
5555
IReadOnlyList<IInlineCommentThreadModel> InlineCommentThreads { get; }
5656

57+
/// <summary>
58+
/// Gets the inline annotations for the file.
59+
/// </summary>
60+
IReadOnlyList<IInlineAnnotationModel> InlineAnnotations { get; }
61+
5762
/// <summary>
5863
/// Gets an observable that is raised with a collection of 0-based line numbers when the
5964
/// review comments on the file are changed.

src/GitHub.Exports.Reactive/ViewModels/GitHubPane/IPullRequestAnnotationItemViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace GitHub.ViewModels.GitHubPane
44
{
55
public interface IPullRequestAnnotationItemViewModel
66
{
7-
CheckRunAnnotationModel Model { get; }
7+
CheckRunAnnotationModel Annotation { get; }
88
bool IsExpanded { get; set; }
99
string LineDescription { get; }
1010
}

src/GitHub.Exports.Reactive/ViewModels/GitHubPane/IPullRequestFileNode.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,20 @@ public interface IPullRequestFileNode : IPullRequestChangeNode
3333
/// Gets the number of review comments on the file.
3434
/// </summary>
3535
int CommentCount { get; }
36+
37+
/// <summary>
38+
/// Gets or sets the number of annotation notices on the file.
39+
/// </summary>
40+
int AnnotationNoticeCount { get; }
41+
42+
/// <summary>
43+
/// Gets or sets the number of annotation errors on the file.
44+
/// </summary>
45+
int AnnotationWarningCount { get; }
46+
47+
/// <summary>
48+
/// Gets or sets the number of annotation failures on the file.
49+
/// </summary>
50+
int AnnotationFailureCount { get; }
3651
}
3752
}

src/GitHub.Exports/Models/AnnotationModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class CheckRunAnnotationModel
1818
/// <summary>
1919
/// The path that this annotation was made on.
2020
/// </summary>
21-
public string Filename { get; set; }
21+
public string Path { get; set; }
2222

2323
/// <summary>
2424
/// The annotation's message.

src/GitHub.InlineReviews/Models/PullRequestSessionFile.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class PullRequestSessionFile : ReactiveObject, IPullRequestSessionFile
2525
IReadOnlyList<DiffChunk> diff;
2626
string commitSha;
2727
IReadOnlyList<IInlineCommentThreadModel> inlineCommentThreads;
28+
IReadOnlyList<IInlineAnnotationModel> inlineAnnotations;
2829

2930
/// <summary>
3031
/// Initializes a new instance of the <see cref="PullRequestSessionFile"/> class.
@@ -99,6 +100,29 @@ public IReadOnlyList<IInlineCommentThreadModel> InlineCommentThreads
99100
/// <inheritdoc/>
100101
public IObservable<IReadOnlyList<Tuple<int, DiffSide>>> LinesChanged => linesChanged;
101102

103+
/// <inheritdoc/>
104+
public IReadOnlyList<IInlineAnnotationModel> InlineAnnotations
105+
{
106+
get
107+
{
108+
return inlineAnnotations;
109+
}
110+
set
111+
{
112+
var lines = (inlineAnnotations ?? Enumerable.Empty<IInlineAnnotationModel>())?
113+
.Concat(value ?? Enumerable.Empty<IInlineAnnotationModel>())
114+
.Select(x => Tuple.Create(x.StartLine, DiffSide.Right))
115+
.Where(x => x.Item1 >= 0)
116+
.Distinct()
117+
.ToList();
118+
119+
this.RaisePropertyChanging();
120+
inlineAnnotations = value;
121+
this.RaisePropertyChanged();
122+
NotifyLinesChanged(lines);
123+
}
124+
}
125+
102126
/// <summary>
103127
/// Raises the <see cref="LinesChanged"/> signal.
104128
/// </summary>

src/GitHub.InlineReviews/Services/IPullRequestSessionService.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ Task<IReadOnlyList<DiffChunk>> Diff(
4444
string relativePath,
4545
byte[] contents);
4646

47+
48+
49+
/// <summary>
50+
/// Builds a set of annotation models for a file based on a pull request model
51+
/// </summary>
52+
/// <param name="pullRequest">The pull request session.</param>
53+
/// <param name="relativePath">The relative path to the file.</param>
54+
/// <returns>
55+
/// A collection of <see cref="IInlineAnnotationModel"/> objects.
56+
/// </returns>
57+
IReadOnlyList<IInlineAnnotationModel> BuildAnnotations(
58+
PullRequestDetailModel pullRequest,
59+
string relativePath);
60+
4761
/// <summary>
4862
/// Builds a set of comment thread models for a file based on a pull request model and a diff.
4963
/// </summary>

0 commit comments

Comments
 (0)