-
Notifications
You must be signed in to change notification settings - Fork 70
feat: templates list pagination #352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1d6fc37
feat(templates): mirror paginated templates endpoints in dashboard-ap…
drankou 538774d
feat(templates): paginated listTeamTemplates repo method and router i…
drankou d332fc9
feat(templates): infinite-scroll templates list with server-side sort…
drankou dd70043
feat(templates): invalidate the templates list after delete/visibilit…
drankou 9f96350
use load more button pattern
drankou ac6dd1f
openapi spec
drankou be678e4
fix(dashboard): disable sort on Template ID column
drankou 6d18d4c
fallback to created_at
drankou c4925b6
prefetch first page
drankou 852347e
refactor(templates): address review nits on listTeamTemplates
drankou ba5a557
chore: use types from generated openapi spec
drankou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
27 changes: 23 additions & 4 deletions
27
src/app/dashboard/[teamSlug]/templates/(tabs)/list/page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,30 @@ | ||
| import { Suspense } from 'react' | ||
| import LoadingLayout from '@/features/dashboard/loading-layout' | ||
| import { | ||
| TEMPLATES_DEFAULT_SORT, | ||
| TEMPLATES_PAGE_SIZE, | ||
| } from '@/features/dashboard/templates/list/constants' | ||
| import TemplatesTable from '@/features/dashboard/templates/list/table' | ||
| import { HydrateClient, prefetch, trpc } from '@/trpc/server' | ||
|
|
||
| export default async function TemplatesListPage({ | ||
| params, | ||
| }: PageProps<'/dashboard/[teamSlug]/templates/list'>) { | ||
| const { teamSlug } = await params | ||
|
|
||
| prefetch( | ||
| trpc.templates.getTemplates.infiniteQueryOptions({ | ||
| teamSlug, | ||
| limit: TEMPLATES_PAGE_SIZE, | ||
| sort: TEMPLATES_DEFAULT_SORT, | ||
| }) | ||
| ) | ||
|
|
||
| export default function TemplatesListPage() { | ||
| return ( | ||
| <Suspense fallback={<LoadingLayout />}> | ||
| <TemplatesTable /> | ||
| </Suspense> | ||
| <HydrateClient> | ||
| <Suspense fallback={<LoadingLayout />}> | ||
| <TemplatesTable /> | ||
| </Suspense> | ||
| </HydrateClient> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import type { SortingState } from '@tanstack/react-table' | ||
| import type { TemplatesSort } from '@/core/modules/templates/models' | ||
|
|
||
| export const TEMPLATES_PAGE_SIZE = 50 | ||
|
|
||
| export const TEMPLATES_DEFAULT_SORT_COLUMN_ID = 'createdAt' | ||
| export const TEMPLATES_DEFAULT_SORT_BASE = 'created_at' | ||
| export const TEMPLATES_DEFAULT_SORT_DESC = true | ||
|
|
||
| export const TEMPLATES_DEFAULT_SORT: TemplatesSort = `${TEMPLATES_DEFAULT_SORT_BASE}_${ | ||
| TEMPLATES_DEFAULT_SORT_DESC ? 'desc' : 'asc' | ||
| }` | ||
|
|
||
| export const TEMPLATES_DEFAULT_SORTING: SortingState = [ | ||
| { id: TEMPLATES_DEFAULT_SORT_COLUMN_ID, desc: TEMPLATES_DEFAULT_SORT_DESC }, | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have some default page size for everything instead of having it specific to templates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep it as-is for now since page size could depend on row item size and API performance