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

Commit 120a2b7

Browse files
Adding a SummaryAnnotationLevel and styles to change the color
1 parent e8e8d14 commit 120a2b7

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

src/GitHub.InlineReviews/Tags/InlineCommentTagger.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,21 @@ public IEnumerable<ITagSpan<InlineCommentTag>> GetTags(NormalizedSnapshotSpanCol
127127
{
128128
linesWithTags[line - startLine] = true;
129129

130+
CheckAnnotationLevel? summaryAnnotationLevel = null;
131+
if (annotations != null)
132+
{
133+
var hasFailure = annotations.Any(model => model.AnnotationLevel == CheckAnnotationLevel.Failure);
134+
var hasWarning = !hasFailure && annotations.Any(model => model.AnnotationLevel == CheckAnnotationLevel.Warning);
135+
136+
summaryAnnotationLevel = hasFailure ? CheckAnnotationLevel.Failure :
137+
hasWarning ? CheckAnnotationLevel.Warning : CheckAnnotationLevel.Notice;
138+
}
139+
130140
var showInlineTag = new ShowInlineCommentTag(currentSession, line, thread?.DiffLineType ?? DiffChangeType.Add)
131141
{
132142
Thread = thread,
133-
Annotations = annotations
143+
Annotations = annotations,
144+
SummaryAnnotationLevel = summaryAnnotationLevel,
134145
};
135146

136147
result.Add(new TagSpan<ShowInlineCommentTag>(

src/GitHub.InlineReviews/Tags/ShowInlineAnnotationGlyph.xaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:cache="clr-namespace:GitHub.UI.Helpers;assembly=GitHub.UI"
7+
xmlns:models="clr-namespace:GitHub.Models;assembly=GitHub.Exports"
78
mc:Ignorable="d">
89

910
<Grid>
@@ -21,14 +22,28 @@
2122
Height="7"
2223
Canvas.Top="3"
2324
Canvas.Left="2.5"
24-
Fill="#2b91af"
2525
Stroke="White"
2626
StrokeThickness="1">
2727
<Rectangle.LayoutTransform>
2828
<TransformGroup>
2929
<RotateTransform Angle="-45" />
3030
</TransformGroup>
3131
</Rectangle.LayoutTransform>
32+
<Rectangle.Style>
33+
<Style TargetType="Rectangle">
34+
<Setter Property="Fill" Value="#2b91af"/>
35+
<Style.Triggers>
36+
<DataTrigger Binding="{Binding SummaryAnnotationLevel}"
37+
Value="Failure">
38+
<Setter Property="Fill" Value="Red"/>
39+
</DataTrigger>
40+
<DataTrigger Binding="{Binding SummaryAnnotationLevel}"
41+
Value="Warning">
42+
<Setter Property="Fill" Value="Yellow"/>
43+
</DataTrigger>
44+
</Style.Triggers>
45+
</Style>
46+
</Rectangle.Style>
3247
</Rectangle>
3348
</Canvas>
3449
</Viewbox>

src/GitHub.InlineReviews/Tags/ShowInlineCommentAnnotationGlyph.xaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:cache="clr-namespace:GitHub.UI.Helpers;assembly=GitHub.UI"
7+
xmlns:models="clr-namespace:GitHub.Models;assembly=GitHub.Exports"
78
mc:Ignorable="d">
89

910
<Grid>
@@ -29,14 +30,28 @@
2930
Height="7"
3031
Canvas.Top="3.5"
3132
Canvas.Left="1"
32-
Fill="#2b91af"
3333
Stroke="White"
3434
StrokeThickness="1">
3535
<Rectangle.LayoutTransform>
3636
<TransformGroup>
3737
<RotateTransform Angle="-45" />
3838
</TransformGroup>
3939
</Rectangle.LayoutTransform>
40+
<Rectangle.Style>
41+
<Style TargetType="Rectangle">
42+
<Setter Property="Fill" Value="#2b91af"/>
43+
<Style.Triggers>
44+
<DataTrigger Binding="{Binding SummaryAnnotationLevel}"
45+
Value="{x:Static models:CheckAnnotationLevel.Failure}">
46+
<Setter Property="Fill" Value="Red"/>
47+
</DataTrigger>
48+
<DataTrigger Binding="{Binding SummaryAnnotationLevel}"
49+
Value="{x:Static models:CheckAnnotationLevel.Warning}">
50+
<Setter Property="Fill" Value="Yellow"/>
51+
</DataTrigger>
52+
</Style.Triggers>
53+
</Style>
54+
</Rectangle.Style>
4055
</Rectangle>
4156
</Canvas>
4257
</Viewbox>

src/GitHub.InlineReviews/Tags/ShowInlineCommentTag.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,10 @@ public ShowInlineCommentTag(IPullRequestSession session, int lineNumber, DiffCha
3131
/// Gets a list of models holding details of the annotations at the tagged line.
3232
/// </summary>
3333
public IReadOnlyList<InlineAnnotationModel> Annotations { get; set; }
34+
35+
/// <summary>
36+
/// Gets a summary annotation level is Annotations are present
37+
/// </summary>
38+
public CheckAnnotationLevel? SummaryAnnotationLevel { get; set; }
3439
}
3540
}

0 commit comments

Comments
 (0)