feat: templates list pagination#352
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0fde47cc58
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
6c8863a to
5947cfc
Compare
huv1k
left a comment
There was a problem hiding this comment.
Few nit picks, what do you think?
| import type { SortingState } from '@tanstack/react-table' | ||
| import type { TemplatesSort } from '@/core/modules/templates/models' | ||
|
|
||
| export const TEMPLATES_PAGE_SIZE = 50 |
There was a problem hiding this comment.
Should we have some default page size for everything instead of having it specific to templates?
There was a problem hiding this comment.
I would keep it as-is for now since page size could depend on row item size and API performance
|
@huv1k addressed all three:
Skipping the page-size constant nit for now — happy to lift it to a shared constant in a follow-up if other paginated lists land that'd reuse it. Pushed in fa088ab. |
fa088ab to
fb7743b
Compare
ben-fornefeld
left a comment
There was a problem hiding this comment.
one nit, otherwise lgtm
…i spec
Regenerates the dashboard-api client types for the cursor-paginated
GET /templates (single `sort` enum) and GET /templates/{templateID}.
…nput getTemplates accepts cursor/limit/filter/search and a single `sort` token and returns a paginated page via the dashboard-api endpoint. The full-list getTeamTemplates (used by the terminal page) is kept unchanged.
…/filter Switches the list to useSuspenseInfiniteQuery, flattens pages, auto-loads the next page on scroll, and maps the active column+direction to the single server `sort` token (react-table runs in manual mode).
…y change Replaces the optimistic setQueryData (incompatible with the infinite query cache) with a pathKey invalidation matching every filter/sort variant.
Template IDs are random nanoid strings — sorting alphabetically by them gives no meaningful order. The server-side sort enum has no templateID variant (clicks would silently fall back to updated_at_desc on the server), so this just removes the misleading sort affordance from the column header to match the other unsortable columns (Visibility, ENVD Ver., Actions).
- pass options directly as query - early return on empty data - single-literal mapping with conditional spread for default templates
fb7743b to
852347e
Compare
This reverts commit deca10d. # Conflicts: # src/features/dashboard/templates/builds/table-cells.tsx
Summary
Replaces the full-list
getTemplatesquery with a cursor-paginated endpoint and rewires the templates list UI arounduseSuspenseInfiniteQuery+ a Load More button. Sorting, filtering, and search are now executed server-side, so the page no longer needs to download every template up front and the table is a pure renderer over the rows returned by the paginated query.Changes
Backend (tRPC + repository)
listTeamTemplatesrepo method acceptingcursor,limit,cpuCount,memoryMB,public,search, and a singlesorttoken; returns{ data, nextCursor }.templates.getTemplatesrouter input now validates the same params (limit ≤ 100, default 50;sortdefaults toupdated_at_desc).getTeamTemplatesis kept untouched — still used by the terminal page.Sort token
The active react-table column + direction is mapped to one of the server enum values:
namename_ascname_desccpuCountcpu_count_asccpu_count_descmemoryMBmemory_mb_ascmemory_mb_desccreatedAtcreated_at_asccreated_at_descupdatedAtupdated_at_ascupdated_at_desc