Skip to content
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

Change availability filter to a toggle #44182

Merged
merged 2 commits into from
Jul 18, 2024
Merged

Change availability filter to a toggle #44182

merged 2 commits into from
Jul 18, 2024

Conversation

avatus
Copy link
Contributor

@avatus avatus commented Jul 12, 2024

This PR will remove the radio/checkbox options for the availability filter and instead use a toggle to "show requestable resources or not"

This takes into account if users have the requestable option toggled in their user prefs still so everything should work for them in the new version

The default option for new users is still to show requestable resources, aka "toggled on".
Screenshot 2024-07-12 at 6 04 14 PM

changelog: the availability filter is now a toggle to show (or hide) requestable resources

Comment on lines +525 to +526
availabilityFilter.mode === 'requestable' ||
availabilityFilter.mode === 'all'
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice if these were enums

Copy link
Contributor

Choose a reason for hiding this comment

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

(it's a union at least)
But it seems that we should get rid of the now unused none option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we'll have to keep none around for a little bit to ensure users who had it selected will still work correctly

@@ -140,7 +140,7 @@ export function FilterPanel({
kindsFromParams={kinds || []}
/>
{ClusterDropdown}
{availabilityFilter && (
{availabilityFilter && availabilityFilter.canRequestAll && (
Copy link
Contributor

Choose a reason for hiding this comment

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

What if canRequestAll is false? Previously we could choose between accessible and requestable.
I think we should still allow this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok sure. I originally programmed this as "if the feature is off, just dont show it at all", but i'll udpate to still show it and use requestable

return (
availabilityFilter.mode === option || availabilityFilter.mode === 'all'
);
onChange('all');
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, shouldn't we set all or accessible depending on canRequestAll?

availabilityFilter.mode === 'requestable' ||
availabilityFilter.mode === 'all'
}
onToggle={handleToggle}
Copy link
Contributor

Choose a reason for hiding this comment

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

The popover closes as soon as the user clicks the toggle, this is unexpected.
I think clicking on the toggle should update the unified view, but not close the popover.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The popup doesn't close for me. Am i using it weird?

5a2b8062aaa9984db71529f6dcb5150a.mp4

Copy link
Contributor

Choose a reason for hiding this comment

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

I tested it in Connect:
https://github.com/user-attachments/assets/a82b2cb8-7d69-408c-98c2-39a1d2a898ff

This happens because when params change, we remount the component so it can re-fetch the list.
I don't have a good idea how to fix it, if you don't have either, we can keep it as is :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't think of anything quick. We'll keep as is and see if anyone complains

Comment on lines +525 to +526
availabilityFilter.mode === 'requestable' ||
availabilityFilter.mode === 'all'
Copy link
Contributor

Choose a reason for hiding this comment

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

(it's a union at least)
But it seems that we should get rid of the now unused none option.

avatus added 2 commits July 15, 2024 14:28
This PR will remove the radio/checkbox options for the availability
filter and instead use a toggle to "show requestable resources or not"

The default option for new users is still "toggled on" to show
requestable resources.
@avatus avatus force-pushed the avatus/fix_filter branch from b5972ab to 8c5e740 Compare July 15, 2024 19:51
@avatus avatus requested a review from gzdunek July 17, 2024 13:36
<ChevronDown ml={2} size="small" color="text.slightlyMuted" />
{availabilityFilter.canRequestAll === true &&
availabilityFilter.mode !== 'none' && <FiltersExistIndicator />}
{availabilityFilter.mode === 'accessible' && (
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it doesn't work correctly for show_resources: 'accessible'. It shows the indicator when the toggle is not checked (so it's in a default state):
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The default state is "on" so the indicator should show when accessible is the value

availabilityFilter.mode === 'requestable' ||
availabilityFilter.mode === 'all'
}
onToggle={handleToggle}
Copy link
Contributor

Choose a reason for hiding this comment

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

I tested it in Connect:
https://github.com/user-attachments/assets/a82b2cb8-7d69-408c-98c2-39a1d2a898ff

This happens because when params change, we remount the component so it can re-fetch the list.
I don't have a good idea how to fix it, if you don't have either, we can keep it as is :(

@avatus avatus enabled auto-merge July 18, 2024 19:19
@avatus avatus added this pull request to the merge queue Jul 18, 2024
Merged via the queue into master with commit b0255a0 Jul 18, 2024
38 checks passed
@avatus avatus deleted the avatus/fix_filter branch July 18, 2024 19:30
@public-teleport-github-review-bot

@avatus See the table below for backport results.

Branch Result
branch/v16 Failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants