ui: fix pagination metadata when filtering secrets#31763
ui: fix pagination metadata when filtering secrets#31763lklivingstone wants to merge 4 commits intohashicorp:mainfrom
Conversation
|
@lklivingstone is attempting to deploy a commit to the HashiCorp Team on Vercel. A member of the Team first needs to authorize it. |
…d of array reference
| prevPage: page - 1, | ||
| total: data.length, | ||
| filteredTotal: filteredData.length, | ||
| filteredTotal: fullFilteredDataLength, |
There was a problem hiding this comment.
Great work on the PR! Quick note: I think the previous logic in this file is actually the way to go, as it covers some specific requirements we have. Could we revert this file to the previous version?
There was a problem hiding this comment.
Hi @kiannaquach
The previous logic sets the filteredTotal to filteredData.slice(start, end);, which means if filtered items are more than 100, it will still show 100 items and will only display one page.
My fix changes the filteredTotal to be equal to the actual number of filtered items, which can be used in list.hbs file.
If you want the previous logic to be unchanged, I will have to assign total to be equal to the total filtered items, and revert the change in list.hbs. I have tested this and works as expected, if this seems ok i can commit them.
| @showSizeSelector={{false}} | ||
| @models={{@currentRouteParams}} | ||
| @totalItems={{@secrets.meta.total}} | ||
| @totalItems={{if @filterValue @secrets.meta.filteredTotal @secrets.meta.total}} |
There was a problem hiding this comment.
Nice work using @filterValue to determine which total to show!
| const expected = [18, 19]; | ||
| assert.deepEqual(paginatedData, expected, 'returns correct items for last page'); | ||
| }); | ||
|
|
There was a problem hiding this comment.
Thank you for adding the test!
Description
Closes #31761
Fixes an issue in the KV secrets list view where pagination does not correctly reflect filtered results.
When applying a filter, the pagination component continued to use the unfiltered total count, resulting in incorrect page calculations.
Changes
paginateutility to compute:filteredTotalbased on the full filtered dataset (before slicing)lastPagebased on the full filtered datasetfilteredTotalwhen a filter is applied.filteredTotalsemantics.Why
Previously:
filteredTotalincorrectly reflected the page slice size.Now:
filteredTotalreflects full filtered dataset size.lastPagecorrectly reflects filtered dataset size.Screenshots:



TODO only if you're a HashiCorp employee
backport/label that matches the desired release branch.PCI review checklist
Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.