Loading
Add Load more pagination to policy store list
What does this MR do and why?
Summary
This change adds pagination to the policy list, allowing users to load policies in batches rather than all at once. The list now fetches 20 policies at a time, and a "Load more" button appears at the bottom when additional policies are available. Clicking it appends the next batch to the existing list without replacing what's already shown.
Key behaviors handled:
- The main list remains visible and interactive while more policies are loading — only the "Load more" button shows a spinner.
- If the same policy appears in both pages (due to data shifting between requests), duplicates are automatically removed, keeping the first occurrence.
- If loading more fails, an error message is shown and stale data is cleared.
- Retrying after an error resets back to the first page cleanly.
Tests were added to cover all these scenarios for both organization and group contexts.
References
- Resolves https://gitlab.com/gitlab-org/gitlab/-/work_items/628956
- Plan and decision record: https://gitlab.com/gitlab-org/gitlab/-/work_items/628956#note_3830559865
Screenshots or screen recordings
| Description | UI |
|---|---|
| Loading more policies |
How to set up and validate locally
- The policy store list needs to be reachable with the experiment enabled and some policies seeded.
- Open
/-/security/policy_store. Expect 20 rows and a Load more button. (change manually in code for a smaller number) - Click Load more. Expect more rows to appear, and the button to disappear on the last page.
- Stop the Rails server and click Load more. Expect the error alert with a Retry option.
Adversarial review
Verdict: pass with findings. No blocking findings.
Addressed in the second commit:
- The button is hidden while loading, so retry and load-more cannot race for the same cache entry.
- Rows are deduped by id, because a page-number cursor over a mutable store can repeat a boundary row.
- The result hook skips the emission that
fetchMoretriggers before its promise settles, andpageInfocomes from thefetchMoreresult. - New specs cover retry after load more, a repeated boundary row, and the button being hidden while loading.
Left as follow-ups: the known limits listed above.
MR acceptance checklist
Evaluated against the MR acceptance checklist.
Edited by Artur Fedorov