Skip to content

Commit 142badb

Browse files
adamintAdam Ratzman
andauthored
Revert state column badge changes (#1957)
* revert state column badge changes * Slightly darken error in dark theme * Remove spurious VS-added itemgroups * Auto-close empty element --------- Co-authored-by: Adam Ratzman <[email protected]>
1 parent e3d1279 commit 142badb

24 files changed

+219
-97
lines changed

src/Aspire.Dashboard/Aspire.Dashboard.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<!-- This list of runtimes needs to match the set of runtimes specified in eng/workloads/workloads.csproj -->
@@ -174,5 +174,4 @@
174174
<Compile Include="..\Aspire.Hosting\Utils\KnownResourceNames.cs" Link="Utils\KnownResourceNames.cs" />
175175
<Compile Include="$(SharedDir)KnownFormats.cs" Link="Utils\KnownFormats.cs" />
176176
</ItemGroup>
177-
178177
</Project>

src/Aspire.Dashboard/Components/Pages/Resources.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@
4848
OnDismiss="() => ClearSelectedResource()"
4949
ViewKey="ResourcesList">
5050
<Summary>
51-
<FluentDataGrid Items="@FilteredResources" ResizableColumns="true" GridTemplateColumns="1fr 2fr 1fr 2fr 2.5fr 2fr 1fr 1fr" RowClass="GetRowClass">
51+
<FluentDataGrid Items="@FilteredResources" ResizableColumns="true" GridTemplateColumns="1fr 2fr 1.25fr 2fr 2.5fr 2fr 1fr 1fr" RowClass="GetRowClass">
5252
<ChildContent>
5353
<PropertyColumn Title="@Loc[nameof(Dashboard.Resources.Resources.ResourcesTypeColumnHeader)]" Property="@(c => c.ResourceType)" Sortable="true" />
5454
<TemplateColumn Title="@ControlsStringsLoc[nameof(ControlsStrings.NameColumnHeader)]" Sortable="true" SortBy="@_nameSort">
55-
<ResourceNameDisplay Resource="context" FilterText="@_filter" FormatName="GetResourceName" UnviewedErrorCounts="@_applicationUnviewedErrorCounts" />
55+
<ResourceNameDisplay Resource="context" FilterText="@_filter" FormatName="GetResourceName" />
5656
</TemplateColumn>
5757
<TemplateColumn Title="@Loc[nameof(Dashboard.Resources.Resources.ResourcesStateColumnHeader)]" Sortable="true" SortBy="@_stateSort">
58-
<StateColumnDisplay Resource="@context"/>
58+
<StateColumnDisplay Resource="@context" UnviewedErrorCounts ="@_applicationUnviewedErrorCounts" />
5959
</TemplateColumn>
6060
<PropertyColumn Property="@(c => c.CreationTimeStamp)" Title="@Loc[nameof(Dashboard.Resources.Resources.ResourcesStartTimeColumnHeader)]" Sortable="true" Tooltip="true" />
6161
<TemplateColumn Title="@Loc[nameof(Dashboard.Resources.Resources.ResourcesSourceColumnHeader)]">

src/Aspire.Dashboard/Components/Pages/Resources.razor.css

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@
77
padding-left: calc(var(--design-unit) * 1px);
88
}
99

10+
::deep .unread-logs-errors-link {
11+
vertical-align: middle;
12+
--unread-logs-badge-color: #ffffff;
13+
}
14+
1015
::deep .unread-logs-errors-link::part(control) {
11-
padding-left: 0;
12-
padding-right: 0;
13-
margin-left: 3px;
16+
margin-left: 5px;
17+
padding: 0;
18+
flex-grow: 0;
19+
color: #ffffff;
1420
}
1521

1622
::deep .error-counter-badge {

src/Aspire.Dashboard/Components/ResourcesGridColumns/ResourceNameDisplay.razor

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,7 @@
55
@using Aspire.Dashboard.Resources
66
@inject IStringLocalizer<Columns> Loc
77

8-
@{
9-
var unviewedErrorCount = GetUnviewedErrorCount(Resource);
10-
}
11-
12-
@if (unviewedErrorCount > 0)
13-
{
14-
<FluentCounterBadge Class="error-counter-badge" Max="9" BackgroundColor="@Color.Error" Color="Color.Fill" Appearance="Appearance.Lightweight" Count="@unviewedErrorCount" HorizontalPosition="100">
15-
<span title="@FormatName(Resource)"><FluentHighlighter HighlightedText="@FilterText" Text="@FormatName(Resource)"/></span>
16-
</FluentCounterBadge>
17-
}
18-
else
19-
{
20-
<span title="@FormatName(Resource)"><FluentHighlighter HighlightedText="@FilterText" Text="@FormatName(Resource)"/></span>
21-
}
8+
<span title="@FormatName(Resource)"><FluentHighlighter HighlightedText="@FilterText" Text="@FormatName(Resource)"/></span>
229

2310
@code {
2411
[Parameter, EditorRequired]
@@ -29,7 +16,4 @@ else
2916

3017
[Parameter, EditorRequired]
3118
public required string FilterText { get; set; }
32-
33-
[Parameter, EditorRequired]
34-
public required Dictionary<OtlpApplication, int>? UnviewedErrorCounts { get; set; }
3519
}

src/Aspire.Dashboard/Components/ResourcesGridColumns/ResourceNameDisplay.razor.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/Aspire.Dashboard/Components/ResourcesGridColumns/StateColumnDisplay.razor

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@using Aspire.Dashboard.Model
22
@using Aspire.Dashboard.Otlp.Model
33
@using Aspire.Dashboard.Resources
4+
45
@inject IStringLocalizer<Columns> Loc
56

67
@if (Resource is { State: ResourceStates.ExitedState /* containers */ or ResourceStates.FinishedState /* executables */ or ResourceStates.FailedToStartState })
@@ -36,8 +37,13 @@ else
3637
}
3738

3839
@Resource.State
40+
<UnreadLogErrorsBadge UnviewedErrorCounts="UnviewedErrorCounts" Resource="@Resource" />
3941

4042
@code {
4143
[Parameter, EditorRequired]
4244
public required ResourceViewModel Resource { get; set; }
45+
46+
47+
[Parameter, EditorRequired]
48+
public required Dictionary<OtlpApplication, int>? UnviewedErrorCounts { get; set; }
4349
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@using Aspire.Dashboard.Resources
2+
@using Aspire.Dashboard.Model
3+
@namespace Aspire.Dashboard.Components
4+
@inject IStringLocalizer<Columns> Loc
5+
6+
@if (_unviewedCount > 0)
7+
{
8+
<FluentAnchor aria-label="@(_unviewedCount == 1 ? nameof(Columns.UnreadLogErrorsBadgeOneErrorLog) : string.Format(Loc[nameof(Columns.UnreadLogErrorsBadgeErrorLogs)], _unviewedCount))"
9+
Href="@GetResourceErrorStructuredLogsUrl(Resource)"
10+
Appearance="Appearance.Stealth"
11+
Class="unread-logs-errors-link">
12+
<FluentBadge
13+
Appearance="Appearance.Accent"
14+
Circular="true"
15+
Fill="error"
16+
Color="var(--unread-logs-badge-color)">
17+
@(_unviewedCount > 9 ? "9+" : _unviewedCount.ToString())
18+
</FluentBadge>
19+
</FluentAnchor>
20+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Aspire.Dashboard.Model;
5+
using Aspire.Dashboard.Otlp.Model;
6+
using Aspire.Dashboard.Otlp.Storage;
7+
using Microsoft.AspNetCore.Components;
8+
9+
namespace Aspire.Dashboard.Components;
10+
11+
public partial class UnreadLogErrorsBadge
12+
{
13+
private int _unviewedCount;
14+
15+
[Parameter, EditorRequired]
16+
public required ResourceViewModel Resource { get; set; }
17+
[Parameter, EditorRequired]
18+
public required Dictionary<OtlpApplication, int>? UnviewedErrorCounts { get; set; }
19+
20+
[Inject]
21+
public required TelemetryRepository TelemetryRepository { get; init; }
22+
[Inject]
23+
public required NavigationManager NavigationManager { get; init; }
24+
25+
protected override void OnParametersSet()
26+
{
27+
_unviewedCount = GetUnviewedErrorCount(Resource);
28+
}
29+
30+
private int GetUnviewedErrorCount(ResourceViewModel resource)
31+
{
32+
if (UnviewedErrorCounts is null)
33+
{
34+
return 0;
35+
}
36+
37+
var application = TelemetryRepository.GetApplication(resource.Uid);
38+
if (application is null)
39+
{
40+
return 0;
41+
}
42+
43+
if (!UnviewedErrorCounts.TryGetValue(application, out var count))
44+
{
45+
return 0;
46+
}
47+
48+
return count;
49+
}
50+
51+
private static string GetResourceErrorStructuredLogsUrl(ResourceViewModel resource)
52+
{
53+
return $"/StructuredLogs/{resource.Uid}?level=error";
54+
}
55+
}

src/Aspire.Dashboard/Resources/Columns.Designer.cs

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Aspire.Dashboard/Resources/Columns.resx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,6 @@
142142
<data name="SourceColumnSourceCopyContainerToClipboard" xml:space="preserve">
143143
<value>Copy image name and tag to clipboard</value>
144144
</data>
145-
<data name="UnreadLogErrors" xml:space="preserve">
146-
<value>{0} errors</value>
147-
<comment>{0} is a number</comment>
148-
</data>
149145
<data name="StateColumnResourceExitedUnexpectedly" xml:space="preserve">
150146
<value>{0} exited unexpectedly with exit code {1}</value>
151147
<comment>{0} is a resource type, {1} is a number</comment>
@@ -157,4 +153,11 @@
157153
<data name="SourceColumnDisplayCopyCommandToClipboard" xml:space="preserve">
158154
<value>Copy full command to clipboard</value>
159155
</data>
156+
<data name="UnreadLogErrorsBadgeOneErrorLog" xml:space="preserve">
157+
<value>1 error log</value>
158+
</data>
159+
<data name="UnreadLogErrorsBadgeErrorLogs" xml:space="preserve">
160+
<value>{0} error logs</value>
161+
<comment>{0} is a number</comment>
162+
</data>
160163
</root>

0 commit comments

Comments
 (0)