Skip to content

Commit 8921150

Browse files
committed
Merge branch 'main' into add-resource-server-proto
2 parents 32185ca + 1f56e60 commit 8921150

23 files changed

+570
-721
lines changed

src/Aspire.Dashboard/Components/Pages/ConsoleLogs.razor.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,12 @@ private async Task HandleSelectedOptionChangedAsync()
187187
NavigationManager.NavigateTo($"/ConsoleLogs/{_selectedOption?.Value}");
188188
}
189189

190-
private async Task OnResourceListChangedAsync(ObjectChangeType changeType, ResourceViewModel resourceViewModel)
190+
private async Task OnResourceListChangedAsync(ResourceChangeType changeType, ResourceViewModel resourceViewModel)
191191
{
192-
if (changeType == ObjectChangeType.Added)
193-
{
194-
_resourceNameMapping[resourceViewModel.Name] = resourceViewModel;
195-
}
196-
else if (changeType == ObjectChangeType.Modified)
192+
if (changeType == ResourceChangeType.Upsert)
197193
{
198194
_resourceNameMapping[resourceViewModel.Name] = resourceViewModel;
195+
199196
if (string.Equals(_selectedResource?.Name, resourceViewModel.Name, StringComparison.Ordinal))
200197
{
201198
_selectedResource = resourceViewModel;
@@ -210,9 +207,10 @@ private async Task OnResourceListChangedAsync(ObjectChangeType changeType, Resou
210207
}
211208
}
212209
}
213-
else if (changeType == ObjectChangeType.Deleted)
210+
else if (changeType == ResourceChangeType.Deleted)
214211
{
215212
_resourceNameMapping.Remove(resourceViewModel.Name);
213+
216214
if (string.Equals(_selectedResource?.Name, resourceViewModel.Name, StringComparison.Ordinal))
217215
{
218216
_selectedOption = _noSelection;

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private int GetUnviewedErrorCount(ResourceViewModel resource)
130130

131131
private void ShowEnvironmentVariables(ResourceViewModel resource)
132132
{
133-
if (SelectedEnvironmentVariables == resource.Environment)
133+
if (SelectedResource == resource)
134134
{
135135
ClearSelectedResource();
136136
}
@@ -147,19 +147,15 @@ private void ClearSelectedResource()
147147
SelectedResource = null;
148148
}
149149

150-
private async Task OnResourceListChanged(ObjectChangeType objectChangeType, ResourceViewModel resource)
150+
private async Task OnResourceListChanged(ResourceChangeType changeType, ResourceViewModel resource)
151151
{
152-
switch (objectChangeType)
152+
switch (changeType)
153153
{
154-
case ObjectChangeType.Added:
155-
_resourcesMap.Add(resource.Name, resource);
156-
break;
157-
158-
case ObjectChangeType.Modified:
154+
case ResourceChangeType.Upsert:
159155
_resourcesMap[resource.Name] = resource;
160156
break;
161157

162-
case ObjectChangeType.Deleted:
158+
case ResourceChangeType.Deleted:
163159
_resourcesMap.Remove(resource.Name);
164160
break;
165161
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<FluentStack Orientation="Orientation.Vertical">
44
@* If we have no endpoints, and the app isn't running anymore or we're not expecting any, then just say None *@
5-
@if (Resource.Endpoints.Count == 0 && (Resource.State == FinishedState || Resource.ExpectedEndpointsCount == 0))
5+
@if (Resource.Endpoints.Length == 0 && (Resource.State == FinishedState || Resource.ExpectedEndpointsCount == 0))
66
{
77
<span class="long-inner-content">None</span>
88
}
@@ -15,7 +15,7 @@
1515
}
1616
@* If we're expecting more, say Starting..., unless the app isn't running anymore *@
1717
if (Resource.State != FinishedState
18-
&& (Resource.ExpectedEndpointsCount is null || Resource.ExpectedEndpointsCount > Resource.Endpoints.Count))
18+
&& (Resource.ExpectedEndpointsCount is null || Resource.ExpectedEndpointsCount > Resource.Endpoints.Length))
1919
{
2020
<span class="long-inner-content">Starting...</span>
2121
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22

33
<FluentStack Orientation="Orientation.Horizontal" VerticalAlignment="VerticalAlignment.Center">
44
<span><FluentHighlighter HighlightedText="@FilterText" Text="@FormatName(Resource)" /></span>
5-
@if (Resource is ProjectViewModel projectViewModel)
6-
{
7-
var title = $"Process ID: {projectViewModel.ProcessId}";
8-
<span class="subtext" title="@title" aria-label="@title">@projectViewModel.ProcessId</span>
9-
}
10-
else if (Resource is ContainerViewModel containerViewModel)
5+
@if (Resource is ContainerViewModel containerViewModel)
116
{
127
<div class="subtext">
138
<GridValue Value="@containerViewModel.ContainerId"
@@ -19,6 +14,7 @@
1914
}
2015
else if (Resource is ExecutableViewModel executableViewModel)
2116
{
17+
// NOTE projects are also executables, so this will handle both
2218
var title = $"Process ID: {executableViewModel.ProcessId}";
2319
<span class="subtext" title="@title" aria-label="@title">@executableViewModel.ProcessId</span>
2420
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
@if (Resource is ProjectViewModel projectViewModel)
55
{
6+
// NOTE projects are also executables, so we have to check for projects first
67
<span title="@projectViewModel.ProjectPath" aria-label="@projectViewModel.ProjectPath">@Path.GetFileName(projectViewModel.ProjectPath)</span>
78
}
89
else if (Resource is ExecutableViewModel executableViewModel)
@@ -18,9 +19,9 @@ else if (Resource is ContainerViewModel containerViewModel)
1819
var ports = string.Join("; ", containerViewModel.Ports);
1920
<FluentStack Orientation="Orientation.Horizontal">
2021
<span title="@containerViewModel.Image"><FluentHighlighter HighlightedText="@FilterText" Text="@containerViewModel.Image" /></span>
21-
@if (containerViewModel.Ports.Count > 0)
22+
@if (containerViewModel.Ports.Length > 0)
2223
{
23-
var title = $"Port{(containerViewModel.Ports.Count > 1 ? "s" : string.Empty)}: {ports}";
24+
var title = $"Port{(containerViewModel.Ports.Length > 1 ? "s" : string.Empty)}: {ports}";
2425
<span class="subtext" title="@title" aria-label="@title">@ports</span>
2526
}
2627
</FluentStack>

src/Aspire.Dashboard/Model/ContainerViewModel.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Collections.Immutable;
45
using Aspire.Dashboard.Extensions;
56

67
namespace Aspire.Dashboard.Model;
78

9+
/// <summary>
10+
/// Immutable snapshot of container state at a point in time.
11+
/// </summary>
812
public class ContainerViewModel : ResourceViewModel
913
{
1014
public override string ResourceType => "Container";
11-
public string? ContainerId { get; init; }
15+
16+
public required string? ContainerId { get; init; }
1217
public required string Image { get; init; }
13-
public List<int> Ports { get; } = new();
14-
public string? Command { get; init; }
15-
public List<string>? Args { get; init; }
18+
public required ImmutableArray<int> Ports { get; init; }
19+
public required string? Command { get; init; }
20+
public required ImmutableArray<string>? Args { get; init; }
1621

1722
internal override bool MatchesFilter(string filter)
1823
{
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Collections.Immutable;
5+
46
namespace Aspire.Dashboard.Model;
57

8+
/// <summary>
9+
/// Immutable snapshot of executable state at a point in time.
10+
/// </summary>
611
public class ExecutableViewModel : ResourceViewModel
712
{
813
public override string ResourceType => "Executable";
9-
public int? ProcessId { get; init; }
10-
public string? ExecutablePath { get; set; }
11-
public string? WorkingDirectory { get; set; }
12-
public List<string>? Arguments { get; set; }
14+
15+
public required int? ProcessId { get; init; }
16+
public required string? ExecutablePath { get; init; }
17+
public required string? WorkingDirectory { get; init; }
18+
public required ImmutableArray<string>? Arguments { get; init; }
1319
}
1420

src/Aspire.Dashboard/Model/ObjectChangeType.cs

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

src/Aspire.Dashboard/Model/ProjectViewModel.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33

44
namespace Aspire.Dashboard.Model;
55

6-
public class ProjectViewModel : ResourceViewModel
6+
/// <summary>
7+
/// Immutable snapshot of project state at a point in time.
8+
/// </summary>
9+
public class ProjectViewModel : ExecutableViewModel
710
{
811
public override string ResourceType => "Project";
9-
public int? ProcessId { get; init; }
12+
1013
public required string ProjectPath { get; init; }
1114
}

src/Aspire.Dashboard/Model/ResourceChange.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
namespace Aspire.Dashboard.Model;
55

6-
public sealed record ResourceChange(ObjectChangeType ObjectChangeType, ResourceViewModel Resource);
6+
public sealed record ResourceChange(ResourceChangeType ChangeType, ResourceViewModel Resource);

0 commit comments

Comments
 (0)