-
Notifications
You must be signed in to change notification settings - Fork 510
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
Allow filtering by resource state and health status, and update the filters based on visible grid items #6925
base: main
Are you sure you want to change the base?
Conversation
…der options by name
src/Aspire.Dashboard/Components/Controls/SelectResourceOptions.razor
Outdated
Show resolved
Hide resolved
{ | ||
private async Task OnAllValuesCheckedChangedInternalAsync(bool? newAreAllVisible) | ||
{ | ||
AreAllVisible = newAreAllVisible; |
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.
Previously this line (and the logic in OnValueVisibilityChangedInternalAsync) was done in the callback but can be done directly in this component before invoking the callback.
What happens if there are a lot of states, resources types and health states? The popup should probably have a maximum height and a scoll bar to handle that situation nicely. |
src/Aspire.Dashboard/Components/Controls/SelectResourceOptions.razor
Outdated
Show resolved
Hide resolved
Reverted the change. |
…lthstatus # Conflicts: # src/Aspire.Dashboard/wwwroot/css/app.css
if (isVisible) | ||
{ | ||
AllValues[value] = true; | ||
} | ||
else | ||
{ | ||
AllValues[value] = 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.
if (isVisible) | |
{ | |
AllValues[value] = true; | |
} | |
else | |
{ | |
AllValues[value] = false; | |
} | |
AllValues[value] = isVisible; |
return areAllChecked | ||
? true | ||
: areAllUnchecked | ||
? false | ||
: null; |
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.
I don't like nested ternary statements. Make at least one of these an if.
private async Task OnAllValuesCheckedChangedInternalAsync(bool? newAreAllVisible) | ||
{ | ||
SetCheckState(newAreAllVisible, AllValues); | ||
await OnAllResourceTypesCheckedChangedAsync(); | ||
} |
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.
private async Task OnAllValuesCheckedChangedInternalAsync(bool? newAreAllVisible) | |
{ | |
SetCheckState(newAreAllVisible, AllValues); | |
await OnAllResourceTypesCheckedChangedAsync(); | |
} | |
private async Task OnAllValuesCheckedChangedInternalAsync(bool? newAreAllVisible) | |
{ | |
SetCheckState(newAreAllVisible, Values); | |
await OnResourceTypesCheckedChangedAsync(); | |
} |
Don't need All
in many of these names anymore (I think this suggestion is right). All should just be used when working with the all button now.
|
||
@code { | ||
[Parameter, EditorRequired] | ||
public required ConcurrentDictionary<TValue, bool> AllValues { get; set; } |
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.
public required ConcurrentDictionary<TValue, bool> AllValues { get; set; } | |
public required ConcurrentDictionary<TValue, bool> Values { get; set; } |
} | ||
return _resourceTypesToVisibility.TryGetValue(resource.ResourceType, out var typeVisible) && typeVisible | ||
&& _resourceStatesToVisibility.TryGetValue(GetStateOrDefaultText(resource.State, Loc), out var stateVisible) && stateVisible | ||
&& _resourceHealthStatusesToVisibility.TryGetValue(GetStateOrDefaultText(resource.HealthStatus?.Humanize(), Loc), out var healthStateVisible) && healthStateVisible |
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.
&& _resourceHealthStatusesToVisibility.TryGetValue(GetStateOrDefaultText(resource.HealthStatus?.Humanize(), Loc), out var healthStateVisible) && healthStateVisible | |
&& _resourceHealthStatusesToVisibility.TryGetValue(GetStateOrDefaultText(resource.HealthStatus?.Humanize(), Loc), out var healthStateVisible) && healthStateVisible |
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.
Have a local method for getting true/false from these dictionaries that avoids the need for TryGetValue.
<FluentButton id="typeFilterButton" slot="end" | ||
Appearance="@(AreAllTypesVisible is true ? Appearance.Stealth : Appearance.Accent)" | ||
<FluentButton id="resourceFilterButton" slot="end" | ||
Appearance="@(AreAllVisibleInAnyFilter ? Appearance.Stealth : Appearance.Accent)" |
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.
This doesn't seem to work anymore.
Title="@(AreAllVisibleInAnyFilter ? Loc[nameof(Dashboard.Resources.Resources.ResourcesTypeFilterAllVisible)] : Loc[nameof(Dashboard.Resources.Resources.ResourcesTypeFiltered)])" | ||
aria-label="@(AreAllVisibleInAnyFilter ? Loc[nameof(Dashboard.Resources.Resources.ResourcesTypeFilterAllVisible)] : Loc[nameof(Dashboard.Resources.Resources.ResourcesTypeFiltered)])"></FluentButton> |
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.
The resource text doesn't make sense anymore. It should be made generic to "has filters" vs "no filters"
_resourceStatesToVisibility.TryAdd(GetStateOrDefaultText(resource.State, Loc), preselectedVisibleResourceStates is null || preselectedVisibleResourceStates.Contains(resource.State ?? string.Empty)); | ||
_resourceHealthStatusesToVisibility.TryAdd(GetStateOrDefaultText(resource.HealthStatus?.Humanize(), Loc), preselectedVisibleResourceHealthStates is null || preselectedVisibleResourceHealthStates.Contains(resource.HealthStatus?.Humanize() ?? string.Empty)); |
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.
If there is no value then the key can be an empty string. It shouldn't be translated text.
Translated text should only be applied in the UI, and this isn't UI related code. Later, when you do show the value in the UI, the view can check if the string is empty and display the default text instead.
@@ -734,3 +734,8 @@ fluent-data-grid-cell.no-ellipsis { | |||
vertical-align: text-bottom; | |||
margin-right: 3px | |||
} | |||
|
|||
.resources-popup { |
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.
.resources-popup { | |
.resources-filter-popup { |
|
||
.resources-popup { | ||
max-height: 400px; | ||
overflow-y: scroll; |
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.
This value always display a scrollbar (disabled when not needed). It should be auto
I think you should add some component tests to test these changes. We don't tests for resources page yet so you'll need to add some setup code for registering required services and JS calls, but there a lot of other pages already setup that you can follow. |
Description
Currently, you can filter resources by type, but it would also be useful to filter by health status or by resource state. I extracted the resource filter UI into its own component
ResourceFilters
and convertedSelectResourceTypes
into a component that was more generic and so could be reused for state and health status (SelectResourceOptions
). This also meant other refactoring was necessary, such as creating reusable methodsGet/SetFieldVisibility
from the getter and setter logic previously inAreAllTypesVisible
.Fixes #1190
In a follow-up, we could persist these values in the URL (#3647)
(note that, for example, finished and no state have disappeared from available options because no resource with those values is in the grid anymore)
Checklist
<remarks />
and<code />
elements on your triple slash comments?breaking-change
template):doc-idea
template):Microsoft Reviewers: Open in CodeFlow