[UII] Save agent list table state using session storage#228875
[UII] Save agent list table state using session storage#228875jen-huang merged 12 commits intoelastic:mainfrom
Conversation
| setInactiveAgentsCalloutHasBeenDismissed: (val: boolean) => void; | ||
| }> = ({ children, isOpen, setInactiveAgentsCalloutHasBeenDismissed }) => ( | ||
| <EuiTourStep | ||
| title={ |
There was a problem hiding this comment.
this tour looked weird without a title (a lot of blank space on top of the popover), so I added one
|
Pinging @elastic/fleet (Team:Fleet) |
| agentPolicies={agentPolicies} | ||
| /> | ||
| <EuiFilterButton | ||
| isToggle |
There was a problem hiding this comment.
upgradable filter button previously didn't have a clear "active" state
MichelLosier
left a comment
There was a problem hiding this comment.
This looks and works great, really nice to be able to go deep and come back to my original search context.
One thing to consider, if navigating back to the agents list from another view and I had a kuery param, which is also persisted in the url, it would be nice to have that repopulate so its in a shareable state when it first loads. Otherwise if I add another filter it shows back up as expected.
...lic/applications/fleet/sections/agents/agent_list_page/hooks/use_session_agent_list_state.ts
Outdated
Show resolved
Hide resolved
|
@MichelLosier Thanks for the review! (months ago.. 😄) Finally got back to cleaning up this PR. I adjusted it based on your review and also added these changes:
Do you mind giving this PR another test? |
MichelLosier
left a comment
There was a problem hiding this comment.
LGTM thanks for following up with that improvement!
| } = sessionState; | ||
|
|
||
| // If URL params are used, reset the table state to defaults with the param options | ||
| useEffect(() => { |
There was a problem hiding this comment.
nit: There maybe opportunity here to separate out into its own hook the search session state, with url syncing.
There was a problem hiding this comment.
agreed, I started a refactor to pull this out but ran into issues. didn't have confidence I could finish it & test thoroughly before leave 😅 so merged as-is
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
cc @jen-huang |
## Summary Resolves elastic/ingest-dev#5213. This PR makes Fleet's agent list table state be saved using session storage. The state of the table includes: - Pagination (rows per page and page #) - Sort field and direction - Text search bar - All other filters (status, tags, agent policy, has upgrade) Using session storage means that this state will be saved _within_ a window/tab session. Saving the state this way suffices to manage agents without losing context and clears up the state for new tabs/sessions. When some state is declared using URL query params (i.e. `&kuery=` and `&showInactive=`), the session storage state is overridden with defaults *plus* state from query params. This is so that referral pages that apply filters (like from Agent policy > click into count of Unprivileged agents) do not run into unexpected filtering from the user's session storage. Because the filter state is now persistent, I changed `Clear filters` button to `Reset filters` and updated the behavior accordingly: clicking it resets back to initial filter state rather than clearing every filter (i.e. clicking it resets back to 5 active agent statuses, rather than clearing all statuses which causes inactive agents to be shown). ## Testing I recommend using `node scripts/create_agents` (from Fleet directory) to create large number of agents and playing around with filtering the list UI and navigating between pages. ## Release note Fleet agent list table now persists state of filters while navigating within a session. ## To-do - [x] Make this behave nicely with kuery & other URL query params ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels.
Summary
Resolves https://github.com/elastic/ingest-dev/issues/5213.
This PR makes Fleet's agent list table state be saved using session storage. The state of the table includes:
Using session storage means that this state will be saved within a window/tab session. Saving the state this way suffices to manage agents without losing context and clears up the state for new tabs/sessions.
When some state is declared using URL query params (i.e.
&kuery=and&showInactive=), the session storage state is overridden with defaults plus state from query params. This is so that referral pages that apply filters (like from Agent policy > click into count of Unprivileged agents) do not run into unexpected filtering from the user's session storage.Because the filter state is now persistent, I changed
Clear filtersbutton toReset filtersand updated the behavior accordingly: clicking it resets back to initial filter state rather than clearing every filter (i.e. clicking it resets back to 5 active agent statuses, rather than clearing all statuses which causes inactive agents to be shown).Testing
I recommend using
node scripts/create_agents(from Fleet directory) to create large number of agents and playing around with filtering the list UI and navigating between pages.Release note
Fleet agent list table now persists state of filters while navigating within a session.
To-do
Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
release_note:*label is applied per the guidelinesbackport:*labels.