-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Refactor use url state hook #112675
Refactor use url state hook #112675
Conversation
84d2671
to
241b6d6
Compare
Pinging @elastic/security-threat-hunting (Team:Threat Hunting) |
src/plugins/data/server/data_views/saved_objects_client_wrapper.test.ts
Outdated
Show resolved
Hide resolved
Fix empty query validation by considering 'query=()' as empty
It mostly rename variables
c6454df
to
f88842c
Compare
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.
ran it locally, parts of the app that use url state heavily all seemed to work properly, lgtm 🚀
💚 Build SucceededMetrics [docs]Async chunks
Unknown metric groupsReferences to deprecated APIs
History
To update your PR or re-run it, just comment with: cc @machadoum |
* Refactor useUrlStateHooks by batching updates to location * Delete unused detail name * Delete URL_STATE_KEYS constants * Refactor useUrlStateHook * Fix cypress tests by removing empty AppQuery from URL query string Fix empty query validation by considering 'query=()' as empty * Small code readability improvements It mostly rename variables
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
* Refactor useUrlStateHooks by batching updates to location * Delete unused detail name * Delete URL_STATE_KEYS constants * Refactor useUrlStateHook * Fix cypress tests by removing empty AppQuery from URL query string Fix empty query validation by considering 'query=()' as empty * Small code readability improvements It mostly rename variables Co-authored-by: Pablo Machado <pablo.nevesmachado@elastic.co>
Summary
This PR aims to simplify
useUrlState
and improve readability by implementing quick and easy changes (low hanging fruits).document.title
with the page detail name. I deleted this feature because it didn't work correctly.The most relevant changes are:
x-pack/plugins/security_solution/public/common/components/url_state/index.tsx
dispatchSetInitialStateFromUrl
into a hook nameduseSetInitialStateFromUrl
use_url_state.tsx
useCallback
tohandleInitialize
What is NOT included:
updateTimeRange
logic<Spyroute>
dispatch(timelineActions.showTimeline
away fromroute_capture.tsx
history.replace
from "replace state to location" and use navigate to app insteadmakeMapStateToProps
to use hooks as in this commit 7a4029cHow to test it?
All possible query strings/filters:
query, filters, savedQuery, sourcerer, timerange, timeline
When we change one of the previously listed filters we rewrite the URL to contain add them. So if we refresh the page the application should persist the data.
Ex: Open alerts and search for
test
. The URL will update and it should containquery=(language:kuery,query:test)
It can be tested in many different ways. And it should be tested for every query string. I am listing here what this code is responsible for:
Checklist
Delete any items that are not applicable to this PR.