-
Notifications
You must be signed in to change notification settings - Fork 686
Use friendly name in console logs with single replica #8470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use friendly name in console logs with single replica #8470
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the console logs to use a resource’s friendly (display) name when there is a single replica and disables the resource select control while resources are loading.
- Introduces an additional branch in TrackResourceSnapshotsAsync to select a resource by display name if there’s a single matching replica.
- Refactors the resource selection logic by adding a new helper method GetSelectedOption and updates resource select component parameter nullability and event callbacks.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/Aspire.Dashboard/Components/Pages/ConsoleLogs.razor.cs | Adds friendly name selection logic and refactors how the selected option is set. |
src/Aspire.Dashboard/Components/Controls/ResourceSelect.razor.cs | Updates nullability for parameters and simplifies the event callback logic. |
src/Aspire.Dashboard/Components/Controls/ResourceSelect.razor | Disables the resource select control when resources are loading. |
Comments suppressed due to low confidence (2)
src/Aspire.Dashboard/Components/Pages/ConsoleLogs.razor.cs:249
- Using SingleOrDefault here may throw an exception if multiple matching resources exist. Consider checking if there is exactly one match before selecting, to align with the intended behavior described in the PR.
return _resources.SingleOrDefault(
src/Aspire.Dashboard/Components/Controls/ResourceSelect.razor.cs:41
- [nitpick] Consider renaming 'ValuedChanged' to 'ValueChanged' for improved clarity.
private static void ValuedChanged(string? value)
Note: This change is for 9.3, not 9.2. This page is a bug magnet and we don't want to make large changes at the last minute. |
src/Aspire.Dashboard/Components/Controls/ResourceActions.razor.cs
Outdated
Show resolved
Hide resolved
private SelectViewModel<ResourceTypeDetails> GetSelectedOption() | ||
{ | ||
Debug.Assert(_resources is not null); | ||
return _resources.SingleOrDefault( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can ApplicationsSelectHelpers.GetApplication
be used here? That is what other pages with a selector (structured logs, traces, metrics) use to match the name to a select view model.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I don't know how I didn't find this.
…ith-single-replica # Conflicts: # src/Aspire.Dashboard/Model/DashboardCommandExecutor.cs
private bool TryGetResourceByName(string resourceName, [NotNullWhen(true)] out ResourceViewModel? resource) | ||
{ | ||
if (_resourceByName.TryGetValue(resourceName, out resource)) | ||
{ | ||
return true; | ||
} | ||
|
||
var resourcesWithDisplayName = _resourceByName.Values.Where(r => string.Equals(resourceName, r.DisplayName, StringComparisons.ResourceName)).ToList(); | ||
if (resourcesWithDisplayName.Count == 1) | ||
{ | ||
resource = resourcesWithDisplayName.Single(); | ||
return true; | ||
} | ||
|
||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move this to be a helper method on ResourceViewModel
. That way other people doing the same thing can reuse this logic.
…ith-single-replica # Conflicts: # src/Aspire.Dashboard/Components/Controls/ResourceActions.razor.cs # src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor
Description
When there is a single replica, uses the display name of the resource. If there are multiple replicas and a display name is provided as the resource name, no resource is selected.
Also disables the resource select control while resources are loading.
Fixes #8328
Checklist
<remarks />
and<code />
elements on your triple slash comments?breaking-change
template):doc-idea
template):