Skip to content

Pagination

Jasmine Francois edited this page Jul 9, 2021 · 2 revisions

Non-paginated but technically paginated calls

There are a few calls being made to Rode that are not paginated in the UI but are paginated in Rode. The API endpoints in the UI are all specifying pageSize=1000 to pull back the relevant data. Those endpoints are....

These are all currently using the useFetch hook to get their data. If you want to make these calls paginated, it is only a few steps to achieve

  1. Swap out useFetch for usePaginatedFetch. The first two parameters are the same but you will need to add a third parameter to specify the page size you want to fetch. There are some constants used for searching and the policy playground if you want to use those.
  2. In the API endpoint, add the call to buildPaginationParams to pass the pageSize and pageToken to the request.
  3. In the component that is receiving the paginated data, add a check for isLastPage to determine whether or not to show the "View More"-type button.

The endpoint /api/policy-groups/[name]/assignments is called in the usePolicyGroupAssignments hook and is also paginated by Rode but not in the UI. Because this endpoint is also used when managing assignments, this call will not easily be updated to use pagination without rethinking how assigning a policy will work in the UI. I hope that people are not assigning 1000+ policies to a policy group, but who am I to say?

Clone this wiki locally