Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public static bool IsFinishedState(this ResourceViewModel resource)
return resource.KnownState is KnownResourceState.Finished;
}

public static bool IsExitedState(this ResourceViewModel resource)
{
return resource.KnownState is KnownResourceState.Exited;
}

public static bool IsStopped(this ResourceViewModel resource)
{
return resource.KnownState is KnownResourceState.Exited or KnownResourceState.Finished or KnownResourceState.FailedToStart;
Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Dashboard/Model/ResourceStateViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private static (Icon icon, Color color) GetStateIcon(ResourceViewModel resource)
icon = new Icons.Filled.Size16.ErrorCircle();
color = Color.Error;
}
else if (resource.IsFinishedState())
else if (resource.TryGetExitCode(out _) && (resource.IsFinishedState() || resource.IsExitedState()))
Copy link
Member

@JamesNK JamesNK Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is TryGetExitCode here for? Are you making it so there must be a known 0 exit code and if there isn't then show warning?

The concept of exit codes is specific to executable/containers. Other resource types could go into a finished/exited state without specifying one and then show a warning.

Please test these changes with resource types other than executables/containers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example,

image

{
// Process completed successfully.
icon = new Icons.Regular.Size16.RecordStop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public class ResourceStateViewModelTests
[InlineData(
/* state */ KnownResourceState.Exited, 3, null, null,
/* expected output */ $"Localized:{nameof(Columns.StateColumnResourceExitedUnexpectedly)}:{ResourceType}+3", "ErrorCircle", Color.Error, "Exited")]
[InlineData(
/* state */ KnownResourceState.Exited, 0, null, null,
/* expected output */ $"Localized:{nameof(Columns.StateColumnResourceExited)}:{ResourceType}", "RecordStop", Color.Info, "Exited")]
[InlineData(
/* state */ KnownResourceState.Finished, 0, null, null,
/* expected output */ $"Localized:{nameof(Columns.StateColumnResourceExited)}:{ResourceType}", "RecordStop", Color.Info, "Finished")]
Expand Down
Loading