feat: Use Store API pagination for remodels table#5681
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the publisher “Remodels” view to use Store API–backed pagination (cursor + page-size) instead of paginating/filtering entirely client-side, aligning the UI with the API’s paging model.
Changes:
- Pass pagination/filter query params through the Flask
/models/remodel-allowlistendpoint toPublisherGW.get_remodel_allowlist. - Replace client-side
TablePaginationwith explicit cursor-based pagination controls and a page-size selector in the React UI. - Update
useRemodelsto build a URL with query params and expand tests around these parameters; bumpcanonicalwebteam.store-apito7.8.2.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| webapp/endpoints/models.py | Forwards page, from-model, and page-size query params (mapping page → Store API cursor) to the Store API gateway call. |
| tests/endpoints/tests_models.py | Adds endpoint tests asserting that pagination/filter query parameters are forwarded to the gateway call. |
| static/js/publisher/pages/Remodel/RemodelTable.tsx | Switches to explicit Pagination + Select controls (instead of TablePagination) and adds truncation styling for table cells. |
| static/js/publisher/pages/Remodel/Remodel.tsx | Introduces cursor state/history, reads page-size from URL search params, and wires pagination handlers into the table. |
| static/js/publisher/hooks/useRemodels.ts | Builds request URL with optional page, page-size, from-model search params and expands the query key. |
| static/js/publisher/hooks/tests/useRemodels.test.tsx | Adds tests intended to validate query-string behavior for useRemodels. |
| requirements.txt | Bumps canonicalwebteam.store-api dependency version. |
bcb400b to
5e3ca17
Compare
|
Page number (or the next cursor) doesn't seem to be added to URL, is this expected? |
|
@bartaz I agree, however we can't reliably know the page number - for example if someone loaded the page with a cursor in the URL, we don't know what the previous cursor is and won't have generated a history unless they have navigated there from the first page. Not ideal I know, but for this iteration this is all we can really do. Having |
edisile
left a comment
There was a problem hiding this comment.
looks good, left some minor suggestions
| const brandId = useAtomValue(brandIdState); | ||
| const [currentCursor, setCurrentCursor] = useState<string | null>(null); | ||
| const [nextCursor, setNextCursor] = useState<string | null>(null); | ||
| const [cursorHistory, setCursorHistory] = useState<Array<string | null>>([]); |
There was a problem hiding this comment.
how about using a ref for cursorHistory? I think it would make the history updates clearer (just .push(...) on page forward and .pop() on page back)
| <Row> | ||
| <Col size={6} medium={3}> | ||
| <Pagination | ||
| onForward={() => { | ||
| handlePageForward(); | ||
| }} | ||
| onBack={() => { | ||
| handlePageBack(); | ||
| }} | ||
| showLabels | ||
| forwardLabel="Next" | ||
| forwardDisabled={forwardDisabled} | ||
| backLabel="Prev" | ||
| backDisabled={backDisabled} | ||
| /> | ||
| </Col> | ||
| <Col size={6} medium={3} className="u-align--right"> | ||
| <Select | ||
| label="Number of remodels per page" | ||
| labelClassName="u-off-screen" | ||
| defaultValue={pageSize} | ||
| style={{ maxWidth: "150px" }} | ||
| onChange={(e: ChangeEvent<HTMLSelectElement>) => { | ||
| setSearchParams({ "page-size": e.target.value }); | ||
| }} | ||
| options={[ | ||
| { label: "10/page", value: 10 }, | ||
| { label: "25/page", value: 25 }, | ||
| { label: "50/page", value: 50 }, | ||
| { label: "100/page", value: 100 }, | ||
| { label: "200/page", value: 200 }, | ||
| ]} | ||
| /> | ||
| </Col> | ||
| </Row> |
There was a problem hiding this comment.
doesn't the TablePagination component already implement this logic? or is it a bad fit for this kind of cursor-based pagination?
There was a problem hiding this comment.
@edisile You're right. I thought it might be a bit complicated, but along with using the ref for the history this makes more sense. Done
5e3ca17 to
b3df19b
Compare
|
@edisile I've addressed your comments |
|
@steverydz thanks! I took a look at the page again and I think there are some missing styles: |
|
@edisile That's really strange? Those styles are there when I run locally, and other instances of pagination e.g. https://snapcraft-io-5681.demos.haus/admin/ahnuP3quahti9vis8aiw/signing-keys seem to be working? I'll investigate. |
|
I think that visiting that page after you've visited one where the pagination loads correctly hides the issue because the styles are already loaded (e.g. go to the "Policies" tab, then come back to the "Remodels" and the pagination looks fine) |
|
@edisile Makes sense, although that's still not the case locally as I've been going directly to the remodel page and the styles are there? |
e2e1bd5 to
c5e94a4
Compare
|
@edisile I've fixed it. The issue was that the |
c5e94a4 to
5118213
Compare

Done
Updated the remodels table to use the
next-cursorpagination supplied by the Store API. This involved removing the ordering by date so as to retain the order returned from the API.How to QA
page-sizequery param is updated in the URL when using the page size selectorTesting
Security
Issue / Card
Fixes https://warthogs.atlassian.net/browse/WD-36146
Screenshots
n/a
UX Approval