-
Notifications
You must be signed in to change notification settings - Fork 241
ui: Extend useURLState and useQueryState hooks #6137
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enhances the useURLState hook with mergeStrategy ('replace', 'append', 'preserve-existing'), namespace, and enabled options for more flexible URL state management. Adds useURLStateReset hook to clear specific URL params and a hasQueryParams helper. Updates tests to cover new behaviors and options.
Introduces support for view-specific defaults in useQueryState and related hooks, ensuring defaults are only applied when URL params are empty and do not overwrite existing values.
Introduces a forceApplyFilters method to profile filter hooks for bypassing the preserve-existing strategy. Enhances useQueryState to support matchers-only view defaults by prepending the first available profile type, and ensures view defaults are reapplied when profile types finish loading. Also removes debug logging from useLabels.
Introduces a forceApplyViewDefaults method to the useQueryState hook, allowing view defaults to be forcibly applied and overwrite existing URL parameters. Updates tests to cover this new behavior and ensures groupBy and sumBy are applied even if profile types are loading or unavailable for matchers-only expressions. Also fixes groupBy handling in useURLState to always return an array.
|
✅ Meticulous spotted visual differences in 33 of 378 screens tested, but all differences have already been approved: view differences detected. Meticulous evaluated ~4 hours of user flows against your PR. Last updated for commit 9e64bd4. This comment will update as new commits are pushed. |
07c9cf7 to
a7fdb6e
Compare
82a8c0e to
5e762b5
Compare
- Add return types to helper functions in useQueryState.test.tsx - Remove unnecessary undefined initialization - Restore build-preview.sh that was corrupted with Go code
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR extends useURLState, useQueryState, and related hooks to support view-aware state management.
The core change is adding a
mergeStrategyoption to useURLState with three modes:replace(default),preserve-existing(only apply if URL param is empty), andappend(merge arrays with deduplication). This enables views to provide default configuration that respects user modifications already in the URL.The useQueryState hook now supports
viewDefaultsprops passed from upstream and methods likeapplyViewDefaults()andforceApplyViewDefaults()for applying view settings. It also now parses expressions to extract profile type components and can auto-prepend a profile type to matchers-only expressions (e.g., {comm='parca'}).The useProfileFiltersUrlState hook now also supports a
applyViewDefaults()andforceApplyFilters()for managing profile filter defaults from views.Also added comprehensive tests for the new functionality including useURLState merge strategies and view defaults application.