-
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
[Cloud Posture] add pagination to findings by resource #130968
Conversation
5b6c704
to
6170e7a
Compare
Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security Posture) |
@orouz - aren't we missing a counter somewhere to show "page 1 of many", "page 2 of .." Is this how it works in other places in Kibana? |
x-pack/plugins/cloud_security_posture/public/pages/findings/findings.test.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cloud_security_posture/public/pages/findings/findings_by_resource_table.test.tsx
Outdated
Show resolved
Hide resolved
...ugins/cloud_security_posture/public/pages/findings/findings_by_resource_table_pagination.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cloud_security_posture/public/pages/findings/findings_container.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cloud_security_posture/public/pages/findings/use_findings_by_resource.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/cloud_security_posture/public/pages/findings/use_findings_by_resource.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/cloud_security_posture/public/pages/findings/use_findings_by_resource.ts
Outdated
Show resolved
Hide resolved
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. |
x-pack/plugins/cloud_security_posture/public/pages/findings/findings_container.tsx
Outdated
Show resolved
Hide resolved
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'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
Here's a video that better describes the "rows per page" issue I mentioned with duplicate data between pages: 111.mov |
agreed, there's some funky business here around pagination (some messy code too) 😄
yes, seems like a bug. i think whenever it changes, the
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:
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 this PR has a high ratio. 😅 |
838c097
to
e91811b
Compare
...ugins/cloud_security_posture/public/pages/findings/latest_findings/latest_findings_table.tsx
Outdated
Show resolved
Hide resolved
35e32cc
to
9d2e372
Compare
...curity_posture/public/pages/findings/latest_findings_by_resource/use_findings_by_resource.ts
Outdated
Show resolved
Hide resolved
...curity_posture/public/pages/findings/latest_findings_by_resource/use_findings_by_resource.ts
Outdated
Show resolved
Hide resolved
...curity_posture/public/pages/findings/latest_findings_by_resource/use_findings_by_resource.ts
Show resolved
Hide resolved
...curity_posture/public/pages/findings/latest_findings_by_resource/use_findings_by_resource.ts
Show resolved
Hide resolved
...curity_posture/public/pages/findings/latest_findings_by_resource/use_findings_by_resource.ts
Outdated
Show resolved
Hide resolved
...curity_posture/public/pages/findings/latest_findings_by_resource/use_findings_by_resource.ts
Outdated
Show resolved
Hide resolved
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.
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, |
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.
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
9d2e372
to
717eddd
Compare
💚 Build SucceededMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
@@ -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 } }) => { |
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.
Consider using await
instead of then
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.
+1
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.
will do in the next one (overlaps anyway) and i'd prefer merge this now
Summary
adds pagination to
group-by-resource
tableChecklist
Delete any items that are not applicable to this PR.