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

Commit 2b46a3c

Browse files
Merge pull request #2084 from github/features/check-suite-annotations-inline-markers
Using different inline comment & annotation markers
2 parents 6854c87 + 4978dc1 commit 2b46a3c

11 files changed

+198
-13
lines changed

src/GitHub.InlineReviews/GitHub.InlineReviews.csproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@
9090
<Compile Include="Services\PullRequestSessionManager.cs" />
9191
<Compile Include="Margins\InlineCommentMarginProvider.cs" />
9292
<Compile Include="Services\PullRequestSessionService.cs" />
93+
<Compile Include="Tags\ShowInlineAnnotationGlyph.xaml.cs">
94+
<DependentUpon>ShowInlineAnnotationGlyph.xaml</DependentUpon>
95+
</Compile>
96+
<Compile Include="Tags\ShowInlineCommentAnnotationGlyph.xaml.cs">
97+
<DependentUpon>ShowInlineCommentAnnotationGlyph.xaml</DependentUpon>
98+
</Compile>
9399
<Compile Include="ViewModels\PullRequestFileMarginViewModel.cs" />
94100
<Compile Include="ViewModels\InlineCommentPeekViewModel.cs" />
95101
<Compile Include="ViewModels\PullRequestStatusViewModel.cs" />
@@ -228,6 +234,14 @@
228234
<SubType>Designer</SubType>
229235
<ContainsDesignTimeResources>true</ContainsDesignTimeResources>
230236
</Page>
237+
<Page Include="Tags\ShowInlineAnnotationGlyph.xaml">
238+
<Generator>MSBuild:Compile</Generator>
239+
<SubType>Designer</SubType>
240+
</Page>
241+
<Page Include="Tags\ShowInlineCommentAnnotationGlyph.xaml">
242+
<Generator>MSBuild:Compile</Generator>
243+
<SubType>Designer</SubType>
244+
</Page>
231245
<Page Include="Views\PullRequestFileMarginView.xaml">
232246
<SubType>Designer</SubType>
233247
<Generator>MSBuild:Compile</Generator>

src/GitHub.InlineReviews/Tags/InlineCommentGlyphFactory.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,22 @@ static UserControl CreateGlyph(InlineCommentTag tag)
5959

6060
if (showTag != null)
6161
{
62-
return new ShowInlineCommentGlyph();
62+
if (showTag.Thread != null && showTag.Annotations != null)
63+
{
64+
return new ShowInlineCommentAnnotationGlyph();
65+
}
66+
67+
if (showTag.Thread != null)
68+
{
69+
return new ShowInlineCommentGlyph();
70+
}
71+
72+
if (showTag.Annotations != null)
73+
{
74+
return new ShowInlineAnnotationGlyph();
75+
}
76+
77+
throw new ArgumentException($"{nameof(showTag)} does not have a thread or annotations");
6378
}
6479

6580
throw new ArgumentException($"Unknown 'InlineCommentTag' type '{tag}'");

src/GitHub.InlineReviews/Tags/InlineCommentTagger.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,26 @@ 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+
if (hasFailure)
135+
{
136+
summaryAnnotationLevel = CheckAnnotationLevel.Failure;
137+
}
138+
else
139+
{
140+
var hasWarning = annotations.Any(model => model.AnnotationLevel == CheckAnnotationLevel.Warning);
141+
summaryAnnotationLevel = hasWarning ? CheckAnnotationLevel.Warning : CheckAnnotationLevel.Notice;
142+
}
143+
}
144+
130145
var showInlineTag = new ShowInlineCommentTag(currentSession, line, thread?.DiffLineType ?? DiffChangeType.Add)
131146
{
132147
Thread = thread,
133-
Annotations = annotations
148+
Annotations = annotations,
149+
SummaryAnnotationLevel = summaryAnnotationLevel,
134150
};
135151

136152
result.Add(new TagSpan<ShowInlineCommentTag>(
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<UserControl x:Class="GitHub.InlineReviews.Tags.ShowInlineAnnotationGlyph"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:cache="clr-namespace:GitHub.UI.Helpers;assembly=GitHub.UI"
7+
xmlns:models="clr-namespace:GitHub.Models;assembly=GitHub.Exports"
8+
mc:Ignorable="d">
9+
10+
<Grid>
11+
<Border Background="{DynamicResource GitHubGlyphMarginCommentableBackground}" BorderThickness="0,0,1,0" />
12+
<Viewbox HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,1,0,0">
13+
<Canvas Width="16" Height="16">
14+
<Canvas.Resources>
15+
<Style TargetType="Rectangle">
16+
<Setter Property="Fill" Value="{DynamicResource GitHubDiffGlyphFill.None}" />
17+
<Setter Property="Stroke" Value="{DynamicResource GitHubDiffGlyphFill.None}" />
18+
</Style>
19+
</Canvas.Resources>
20+
21+
<Rectangle Width="7"
22+
Height="7"
23+
Canvas.Top="3"
24+
Canvas.Left="2.5"
25+
Stroke="White"
26+
StrokeThickness="1">
27+
<Rectangle.LayoutTransform>
28+
<TransformGroup>
29+
<RotateTransform Angle="-45" />
30+
</TransformGroup>
31+
</Rectangle.LayoutTransform>
32+
<Rectangle.Style>
33+
<Style TargetType="Rectangle">
34+
<Setter Property="Fill" Value="{DynamicResource GitHubAnnotationMarkerInfoFill}"/>
35+
<Style.Triggers>
36+
<DataTrigger Binding="{Binding SummaryAnnotationLevel}"
37+
Value="Failure">
38+
<Setter Property="Fill" Value="{DynamicResource GitHubAnnotationMarkerFailureFill}"/>
39+
</DataTrigger>
40+
<DataTrigger Binding="{Binding SummaryAnnotationLevel}"
41+
Value="Warning">
42+
<Setter Property="Fill" Value="{DynamicResource GitHubAnnotationMarkerWarningFill}"/>
43+
</DataTrigger>
44+
</Style.Triggers>
45+
</Style>
46+
</Rectangle.Style>
47+
</Rectangle>
48+
</Canvas>
49+
</Viewbox>
50+
</Grid>
51+
</UserControl>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Windows.Controls;
3+
4+
namespace GitHub.InlineReviews.Tags
5+
{
6+
public partial class ShowInlineAnnotationGlyph : UserControl
7+
{
8+
public ShowInlineAnnotationGlyph()
9+
{
10+
InitializeComponent();
11+
}
12+
}
13+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<UserControl x:Class="GitHub.InlineReviews.Tags.ShowInlineCommentAnnotationGlyph"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:cache="clr-namespace:GitHub.UI.Helpers;assembly=GitHub.UI"
7+
xmlns:models="clr-namespace:GitHub.Models;assembly=GitHub.Exports"
8+
mc:Ignorable="d">
9+
10+
<Grid>
11+
<Border Background="{DynamicResource GitHubGlyphMarginCommentableBackground}" BorderThickness="0,0,1,0" />
12+
<Viewbox HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,1,0,0">
13+
<Canvas Width="16" Height="16">
14+
<Canvas.Resources>
15+
<Style TargetType="Path">
16+
<Setter Property="Fill" Value="{DynamicResource GitHubDiffGlyphFill.None}" />
17+
<Setter Property="Stroke" Value="{DynamicResource GitHubDiffGlyphFill.None}" />
18+
</Style>
19+
</Canvas.Resources>
20+
21+
<Ellipse Width="9"
22+
Height="9"
23+
Canvas.Top="4"
24+
Canvas.Left="6"
25+
Fill="#959DA5"
26+
Stroke="White"
27+
StrokeThickness="1" />
28+
29+
<Rectangle Width="7"
30+
Height="7"
31+
Canvas.Top="3.5"
32+
Canvas.Left="1"
33+
Stroke="White"
34+
StrokeThickness="1">
35+
<Rectangle.LayoutTransform>
36+
<TransformGroup>
37+
<RotateTransform Angle="-45" />
38+
</TransformGroup>
39+
</Rectangle.LayoutTransform>
40+
<Rectangle.Style>
41+
<Style TargetType="Rectangle">
42+
<Setter Property="Fill" Value="{DynamicResource GitHubAnnotationMarkerInfoFill}"/>
43+
<Style.Triggers>
44+
<DataTrigger Binding="{Binding SummaryAnnotationLevel}"
45+
Value="{x:Static models:CheckAnnotationLevel.Failure}">
46+
<Setter Property="Fill" Value="{DynamicResource GitHubAnnotationMarkerFailureFill}"/>
47+
</DataTrigger>
48+
<DataTrigger Binding="{Binding SummaryAnnotationLevel}"
49+
Value="{x:Static models:CheckAnnotationLevel.Warning}">
50+
<Setter Property="Fill" Value="{DynamicResource GitHubAnnotationMarkerWarningFill}"/>
51+
</DataTrigger>
52+
</Style.Triggers>
53+
</Style>
54+
</Rectangle.Style>
55+
</Rectangle>
56+
</Canvas>
57+
</Viewbox>
58+
</Grid>
59+
</UserControl>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Windows.Controls;
3+
4+
namespace GitHub.InlineReviews.Tags
5+
{
6+
public partial class ShowInlineCommentAnnotationGlyph : UserControl
7+
{
8+
public ShowInlineCommentAnnotationGlyph()
9+
{
10+
InitializeComponent();
11+
}
12+
}
13+
}

src/GitHub.InlineReviews/Tags/ShowInlineCommentGlyph.xaml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,13 @@
1717
</Style>
1818
</Canvas.Resources>
1919

20-
<Rectangle Width="8"
21-
Height="8"
22-
Canvas.Top="2.3"
23-
Canvas.Left="2.3"
24-
Fill="#959da5"
20+
<Ellipse Width="9"
21+
Height="9"
22+
Canvas.Top="3.5"
23+
Canvas.Left="3.5"
24+
Fill="#959DA5"
2525
Stroke="White"
26-
StrokeThickness="1">
27-
<Rectangle.LayoutTransform>
28-
<RotateTransform Angle="-45" />
29-
</Rectangle.LayoutTransform>
30-
</Rectangle>
26+
StrokeThickness="1" />
3127
</Canvas>
3228
</Viewbox>
3329
</Grid>

src/GitHub.InlineReviews/Tags/ShowInlineCommentGlyph.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ public ShowInlineCommentGlyph()
99
{
1010
InitializeComponent();
1111
}
12-
1312
}
1413
}

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)