Skip to content

[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

Merged
merged 13 commits into from
Nov 14, 2022

Conversation

adcoelho
Copy link
Contributor

@adcoelho adcoelho commented Oct 31, 2022

Summary

Issues:
#131806
#140008

  • Increase the default table size of the cases table to 10
  • Changed the available page sizes to 10, 25, 50 and 100
  • Save the visualization preferences of the cases table in localStorage
  • Display the current visualization preferences of the cases table in the URL
  • This logic is not applied if the cases table is opened in a modal

Screenshots

Screenshot 2022-10-31 at 12 19 10

Checklist

Delete any items that are not applicable to this PR.


Fixes #140008

Release notes

  • Increase the default table size of the cases table to 10
  • Save the visualization preferences of the cases table in localStorage
  • Display the current visualization preferences of the cases table in the URL

@adcoelho adcoelho added release_note:enhancement Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) Feature:Cases Cases feature v8.6.0 labels Oct 31, 2022
@adcoelho adcoelho force-pushed the increase-default-page-size-cases-table branch 3 times, most recently from 0fc9d07 to ba4228b Compare October 31, 2022 16:01
@peteharverson peteharverson changed the title Increase default page size cases table and save preferences in url/localStorage [Cases] Increase default page size cases table and save preferences in url/localStorage Nov 1, 2022
const [localStorageQueryParams, setLocalStorageQueryParams] =
useLocalStorage<LocalStorageQueryParams>('cases.list.preferences');

const setUrlQueryParams = useCallback(
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 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.

image

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.

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 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.

Copy link
Contributor

@peteharverson peteharverson left a 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?

@adcoelho adcoelho force-pushed the increase-default-page-size-cases-table branch from 6874ebb to 4e10288 Compare November 2, 2022 13:16
Copy link
Contributor

@jonathan-buttner jonathan-buttner left a 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

@adcoelho adcoelho force-pushed the increase-default-page-size-cases-table branch 4 times, most recently from 33e289c to 99855af Compare November 3, 2022 12:48
@adcoelho adcoelho added the ci:cloud-deploy Create or update a Cloud deployment label Nov 3, 2022
@adcoelho adcoelho force-pushed the increase-default-page-size-cases-table branch from 99855af to e0df6be Compare November 3, 2022 15:45
@adcoelho adcoelho marked this pull request as ready for review November 3, 2022 15:47
@adcoelho adcoelho requested a review from a team as a code owner November 3, 2022 15:47
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops-cases (Feature:Cases)

@adcoelho adcoelho force-pushed the increase-default-page-size-cases-table branch from e0df6be to 4a72a7e Compare November 3, 2022 15:51
@adcoelho adcoelho removed the ci:cloud-deploy Create or update a Cloud deployment label Nov 3, 2022
@adcoelho adcoelho force-pushed the increase-default-page-size-cases-table branch from 4a72a7e to 5a82d16 Compare November 4, 2022 10:01
@adcoelho adcoelho requested a review from a team as a code owner November 4, 2022 10:01
@adcoelho adcoelho force-pushed the increase-default-page-size-cases-table branch from 5a82d16 to cf4c1dd Compare November 4, 2022 14:31
@adcoelho adcoelho force-pushed the increase-default-page-size-cases-table branch from cf4c1dd to 7c42e0d Compare November 7, 2022 08:49
@adcoelho adcoelho force-pushed the increase-default-page-size-cases-table branch from 7c42e0d to dec7f74 Compare November 7, 2022 17:00
@EricDavisX EricDavisX added the ci:cloud-deploy Create or update a Cloud deployment label Nov 7, 2022
@EricDavisX
Copy link
Contributor

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.

@adcoelho adcoelho force-pushed the increase-default-page-size-cases-table branch from 63d0ae1 to 0c15670 Compare November 8, 2022 18:13
* Started saving the Cases list visualization preferences in localStorage and in the url
… url params.

* Created unit tests for the useUrlState hook.
* Created app specific localStorage keys for all cases list preferences.
* Started preserving existing url parameters when applicable.
* Wrapped stringify call in try/catch block.
@adcoelho adcoelho force-pushed the increase-default-page-size-cases-table branch from 0c15670 to 4283fe1 Compare November 9, 2022 11:51
Copy link
Member

@cnasikas cnasikas left a 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! 🚀

@adcoelho
Copy link
Contributor Author

@elasticmachine merge upstream

@machadoum machadoum self-requested a review November 10, 2022 13:25
Copy link
Member

@machadoum machadoum left a 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({
Copy link
Member

@machadoum machadoum Nov 10, 2022

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.

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

@machadoum machadoum Nov 14, 2022

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.

Copy link
Member

@cnasikas cnasikas Nov 14, 2022

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?

Copy link
Contributor

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)

Copy link
Member

@machadoum machadoum Nov 14, 2022

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:

  1. The user opens the menu
  2. The user clicks on the cases link
  3. Cases page loads
  4. 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

Copy link
Contributor Author

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 🙌

Copy link
Contributor

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

Copy link
Member

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.

@adcoelho
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

kibana-ci commented Nov 14, 2022

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
cases 508 511 +3

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
cases 344.8KB 346.9KB +2.1KB
securitySolution 9.6MB 9.6MB +24.0B
total +2.1KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
cases 126.6KB 126.6KB +76.0B
Unknown metric groups

ESLint disabled in files

id before after diff
osquery 1 2 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
fleet 59 65 +6
osquery 108 113 +5
securitySolution 441 447 +6
total +19

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
fleet 67 73 +6
osquery 109 115 +6
securitySolution 518 524 +6
total +20

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@adcoelho adcoelho merged commit 46a7197 into elastic:main Nov 14, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting ci:cloud-deploy Create or update a Cloud deployment Feature:Cases Cases feature release_note:enhancement Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ResponseOps][Cases] Increase default page size for cases list page from current value of 5
10 participants