Skip to content
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

[Cloud Posture] add pagination to findings by resource #130968

Merged
merged 4 commits into from
May 18, 2022

Conversation

orouz
Copy link
Contributor

@orouz orouz commented Apr 26, 2022

Summary

adds pagination to group-by-resource table

Checklist

Delete any items that are not applicable to this PR.

@orouz orouz added release_note:skip Skip the PR/issue when compiling release notes v8.3.0 labels Apr 26, 2022
@orouz orouz force-pushed the findings_groupby_pagination branch from 5b6c704 to 6170e7a Compare April 27, 2022 08:30
@orouz orouz marked this pull request as ready for review April 27, 2022 11:51
@orouz orouz requested a review from a team as a code owner April 27, 2022 11:51
@orouz orouz added the Team:Cloud Security Cloud Security team related label Apr 27, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security Posture)

@amitkanfer
Copy link

@orouz - aren't we missing a counter somewhere to show "page 1 of many", "page 2 of .."
I know we don't know how many pages we have, but seems weird that we don't have an indication at all...

Is this how it works in other places in Kibana?

@kfirpeled kfirpeled requested a review from ari-aviran April 27, 2022 14:47
@kfirpeled
Copy link
Contributor

@orouz - aren't we missing a counter somewhere to show "page 1 of many", "page 2 of .." I know we don't know how many pages we have, but seems weird that we don't have an indication at all...

Is this how it works in other places in Kibana?

Hey @amitkanfer , the current pagination is what comes out of the box also in EUITablePagination. Because we are in a tight schedule I'll postpone that tiny fix from this PR. lets do that after our internal FF.
Another note on @orouz work, he went over and did his own pagination component in order to remove the first/last pages as well. Since we can't show the last one.
I'm reaching eui team for more details about that

Copy link
Contributor

@ari-aviran ari-aviran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm rejecting before actually going over the code, some of the page's functionality is not working as expected.

The "rows per page" break the pagination. I think "rows per page" can never work with cursor based pagination, as changing the size of the page will always break backward navigation (if you are on page 5 and you change page size from 10 to 20 you don't have the cursor to fetch the previous 20, only the previous 10 items, and you end up with documents showing up in multiple pages). Here's a short video demonstrating an issue, after changing the page size there's no way to see previous findings

Screen.Recording.2022-04-28.at.11.48.56.mov

I suggest removing the rows per page functionality completely, and setting it to 20.

In addition, persisting the page in the URL is also problematic (and was explicitly out of scope for the task). The issue is that when a user refreshes the page, they don't have the previous cursors in memory so the back navigation always takes you to the first page, which is very confusing UX. This also can not be implemented properly, even if you somehow store previous cursors between page refreshes (e.g. local storage or similar) since new data might have arrived that messes with the order of documents, making the previous cursors invalid.

Here's a video demonstrating the issue:

Screen.Recording.2022-04-28.at.11.49.36.mov

@ari-aviran
Copy link
Contributor

Here's a video that better describes the "rows per page" issue I mentioned with duplicate data between pages:

111.mov

@orouz
Copy link
Contributor Author

orouz commented Apr 28, 2022

I'm rejecting before actually going over the code, some of the page's functionality is not working as expected.

agreed, there's some funky business here around pagination (some messy code too) 😄

The "rows per page" break the pagination

yes, seems like a bug. i think whenever it changes, the after_keys should reset so we start a clean slate.
I prefer not removing the selection of how many rows to show, as that diverges the pagination between the two tables even further (now only the right side is different). will fix

persisting the page in the URL is also problematic

yes, this is known. complete seperation of queries will happen (as it's required) in my next PR

regarding the UX issue, as you've noticed, it's a best effort. but i do think it has some sense:

  • initial visits without an after_key in the URL will results in the back button being disabled, as we can't go back.
  • initial visits with an after_key will have a back button enabled, so users can go back to the first page.

this is very much confusing, but preventing them from ever getting to the first page would probably be weirder. and like you said, there is no reliable way to know the previous cursors. we could probably mitigate this with a callout whenever users enters the page with an after key on initial visit, making sure they know "back" means "first" in this case.


this PR has a high ratio. 😅

@orouz orouz force-pushed the findings_groupby_pagination branch 2 times, most recently from 838c097 to e91811b Compare May 3, 2022 17:33
@orouz orouz force-pushed the findings_groupby_pagination branch 2 times, most recently from 35e32cc to 9d2e372 Compare May 16, 2022 10:11
@orouz orouz requested review from ari-aviran and JordanSh May 16, 2022 11:11
Copy link
Contributor

@ari-aviran ari-aviran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM other than the bug I commented about. Please also reply to @JordanSh comments

failed_findings: {
total: bucket.failed_findings.doc_count,
total: bucket.doc_count,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an error, it displays wrong number of failed findings, I believe this should be reverted to bucket.failed_findings.doc_count

Video:

Screen.Recording.2022-05-17.at.11.46.22.mov

@orouz orouz force-pushed the findings_groupby_pagination branch from 9d2e372 to 717eddd Compare May 17, 2022 13:25
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
cloudSecurityPosture 182.4KB 183.0KB +633.0B

History

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

@orouz orouz requested review from JordanSh and ari-aviran May 17, 2022 15:34
@@ -104,28 +93,34 @@ export const useFindingsByResource = ({ index, query, from, size }: UseResourceF
data.search.search<FindingsAggRequest, FindingsAggResponse>({
params: getFindingsByResourceAggQuery({ index, query, from, size }),
})
),
).then(({ rawResponse: { aggregations } }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using await instead of then

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do in the next one (overlaps anyway) and i'd prefer merge this now

@orouz orouz merged commit 51d2ce9 into elastic:main May 18, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label May 18, 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 release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related v8.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants