-
Notifications
You must be signed in to change notification settings - Fork 8.4k
[Cases] Increase default page size cases table and save preferences in url/localStorage #144228
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
[Cases] Increase default page size cases table and save preferences in url/localStorage #144228
Conversation
0fc9d07
to
ba4228b
Compare
const [localStorageQueryParams, setLocalStorageQueryParams] = | ||
useLocalStorage<LocalStorageQueryParams>('cases.list.preferences'); | ||
|
||
const setUrlQueryParams = useCallback( |
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 think we need to be careful about setting parameters in the URL when using the case list as a modal inside another page / app as this can have unwanted side effects. For example, when attaching ML embeddables to a case, the page is expecting job ID parameters to be present in the URL and the job selector flyout is incorrectly being opened when the URL is being manipulated.
It might make more sense to only persist page settings in the URL if you are on the Cases list page, and for the modal to always default to 10 cases per page for example.
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 think we need to be careful about setting parameters in the URL when using the case list as a modal inside another page / app as this can have unwanted side effects.
The current behavior should remove the modal-specific URL parameters as soon as the modal is unmounted.
When I noticed that the alerts page had some URL parameters of its own, I made it so that those would remain on the page and page + perPage + sortField + sortOrder
disappear when you close the modal.
Did it behave differently with these job ID params you mention?
I did find a somewhat related bug though.
If we filter by status in the all-cases view and pick Closed
, the sortField
becomes closedAt
.
This works fine in this view but if then we navigate to Alerts and pick Add existing case to alert
we shouldn't be able to filter by that status there so the table doesn't work properly. Existing Cases imply Open
or In Progress
only.
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.
Tested and overall this is looking like a great enhancement. Just wonder if we need to limit the scope so that it doesn't include the modal?
6874ebb
to
4e10288
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.
Looking good! Left some preliminary feedback
x-pack/plugins/cases/public/components/all_cases/all_cases_list.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/all_cases/all_cases_list.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/all_cases/all_cases_list.tsx
Outdated
Show resolved
Hide resolved
33e289c
to
99855af
Compare
99855af
to
e0df6be
Compare
Pinging @elastic/response-ops (Team:ResponseOps) |
Pinging @elastic/response-ops-cases (Feature:Cases) |
e0df6be
to
4a72a7e
Compare
x-pack/plugins/cases/public/components/all_cases/all_cases_list.tsx
Outdated
Show resolved
Hide resolved
4a72a7e
to
5a82d16
Compare
5a82d16
to
cf4c1dd
Compare
cf4c1dd
to
7c42e0d
Compare
x-pack/plugins/cases/public/components/all_cases/all_cases_list.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/all_cases/all_cases_list.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/all_cases/use_url_state.test.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/all_cases/use_url_state.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/all_cases/use_url_state.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/all_cases/use_url_state.test.tsx
Outdated
Show resolved
Hide resolved
7c42e0d
to
dec7f74
Compare
Heya @adcoelho I added the ci:cloud-deploy label, next time a commit is pushed up it'll start building it and I can easily take a quick peek at it from the feature/user side. I can share details of the process/usage of the cloud build with you async. |
63d0ae1
to
0c15670
Compare
* Started saving the Cases list visualization preferences in localStorage and in the url
… url params. * Created unit tests for the useUrlState hook.
… modal. * Update tests.
* Created app specific localStorage keys for all cases list preferences. * Started preserving existing url parameters when applicable. * Wrapped stringify call in try/catch block.
0c15670
to
4283fe1
Compare
…ases list preferences.
…ge-size-cases-table
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.
Tested without any issues! Code LGTM! 🚀
@elasticmachine merge upstream |
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.
Hey!
We have implemented a set of utility hooks inside the security solution app that could have helped here, like useReplaceUrlParams
and useGetInitialUrlParamValue
.
Unrelated question: I noticed that the cases page has sourcerer
and timerange
query params. Are they used for anything? Does it make sense to delete it?
|
||
if (!isEqual(newUrlParams, urlParams)) { | ||
try { | ||
history.push({ |
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.
Every time the user updates one of the query param values this code is stacking a history entry. So if users want to go to back to the previous page they have to click many times the back button.
The usage of history.push
makes the implementation inconsistent with how other query parameters work inside Security solution. We use history.replace
to avoid stacking many entries to the history stack.
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.
Cases are being used in Observability, Security solution, and the Stack. We decided it is better to push the history so the user can go back to the previous filtering. Why did you decide to not keep the history in your queries?
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.
Hi @machadoum , thanks for the review!
I noticed that the cases page has sourcerer and timerange query params. Are they used for anything? Does it make sense to delete it?
These are actually not ours, they come from your side and I tried to leave everything as is. In fact, at some point, the logic did not take them into account and the security tests failed.
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.
That decision preceded me. But I can imagine that one reason is that security has many filters, and it could take many clicks for a user to return to the previous page.
Especially if you consider that filters are added the first time a page loads, if a user opens the cases page and decides to go to the previous page immediately, it wouldn't work. They would have to click at least twice. I tested some pages, and it is very inconsistent across applications. For example, on the Observability Alerts page, the user must click four times the back button to leave the page.
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.
My experience as a user of other applications is that the history is being kept but I am not sure what is best. @mdefazio Any input on this?
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.
Unrelated question: I noticed that the cases page has sourcerer and timerange query params. Are they used for anything? Does it make sense to delete it?
@machadoum I think this params are used by the timeline, the TL bottom bar is enabled in Cases (in Security)
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.
Since the back button behaviour is inconsistent across different pages and areas, let's not block this PR because of it. The only scenario that looks like a bug to me is the back button behaviour when the page loads.
Given the following scenario:
- The user opens the menu
- The user clicks on the cases link
- Cases page loads
- The user clicks the browser back button
Expected behaviour: It should navigate back to the previous page
Current behaviour: It stays on the cases page
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.
As discussed offline, I will merge this PR now to make FF and created an issue for this bug behavior .
I will handle this issue during the bug-fixing phase sometime this week.
Thanks for the review @machadoum 🙌
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 Agree, let's not block it.
But the workflow described by @machadoum is weird. I think we should discuss this issue, the back button behavior should be consistent across the app.
(IMHO, I don't think the expected behavior of the browser's back button is to roll back the filters.)
cc @YulNaumenko
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.
Thank you both for the feedback. the back button behavior is inconsistent across Kibana. For example, Discovery & Lens keeps the filtering in the history.
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
Summary
Issues:
#131806
#140008
Screenshots
Checklist
Delete any items that are not applicable to this PR.
Fixes #140008
Release notes