-
Notifications
You must be signed in to change notification settings - Fork 209
feat: integrate pagination into EnhancedDataTable toolbar #326
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
base: main
Are you sure you want to change the base?
Conversation
β¦n LinkedAccountsPage
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
WalkthroughPagination functionality has been introduced to the frontend data table components. New pagination UI components were added, and the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant LinkedAccountsPage
participant EnhancedDataTable
participant EnhancedDataTableToolbar
participant DataTablePagination
User->>LinkedAccountsPage: Loads page
LinkedAccountsPage->>EnhancedDataTable: Renders with paginationOptions
EnhancedDataTable->>EnhancedDataTableToolbar: Passes paginationOptions
EnhancedDataTableToolbar->>DataTablePagination: Conditionally renders if options present
User->>DataTablePagination: Interacts with pagination controls (next, prev, jump)
DataTablePagination->>EnhancedDataTable: Updates pagination state
EnhancedDataTable->>EnhancedDataTable: Fetches and displays new page data
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Poem
β¨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. πͺ§ TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
π§Ή Nitpick comments (5)
frontend/src/components/ui-extensions/enhanced-data-table/data-table-pagination.tsx (3)
3-9
: Remove commented out imports that are not used.The code contains commented-out import statements for Select components that aren't used in the implementation. Remove these commented imports to keep the codebase clean.
-// import { -// Select, -// SelectContent, -// SelectItem, -// SelectTrigger, -// SelectValue, -// } from "@/components/ui/select";
101-118
: Consider handling potential invalid input values for pagination input.The current implementation doesn't handle non-numeric or empty input values, which could lead to unexpected behavior if users manually clear the input field.
<Input type="number" min={1} max={pageCount} value={pageInput} - onChange={(e) => setPageInput(Number(e.target.value))} + onChange={(e) => { + const value = e.target.value; + // Handle empty input or non-numeric values + const numValue = value === '' ? 1 : Number(value); + setPageInput(numValue); + }} onKeyDown={(e) => e.key === "Enter" && jumpToPage()} className="w-14 text-center" />
76-149
: Consider adding pagination size configuration for different view contexts.The pagination component currently has fixed styling, but for better reusability, consider adding size variants (compact, default, large) to accommodate different UI contexts.
You could extend the component interface to support different sizes:
interface DataTablePaginationProps<TData> { table: Table<TData>; + size?: 'compact' | 'default' | 'large'; } // Then apply conditional classes based on size
frontend/src/components/ui/pagination.tsx (2)
29-35
: Consider adding more default styling to PaginationItem.The PaginationItem component has an empty string as the default className. Consider adding some minimal default styling to ensure consistent appearance.
- <li ref={ref} className={cn("", className)} {...props} /> + <li ref={ref} className={cn("list-none", className)} {...props} />
109-117
: Consider adding a reference to documentation in export comment block.For better developer experience, consider adding a reference to usage documentation or examples above the export block.
+/** + * Pagination components for creating accessible pagination interfaces. + * + * @example + * ```tsx + * <Pagination> + * <PaginationContent> + * <PaginationItem> + * <PaginationPrevious href="#" /> + * </PaginationItem> + * {/* ... */} + * </PaginationContent> + * </Pagination> + * ``` + */ export { Pagination, PaginationContent, PaginationLink, PaginationItem, PaginationPrevious, PaginationNext, PaginationEllipsis, }
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
β Files ignored due to path filters (1)
frontend/package-lock.json
is excluded by!**/package-lock.json
π Files selected for processing (6)
frontend/package.json
(1 hunks)frontend/src/app/linked-accounts/page.tsx
(1 hunks)frontend/src/components/ui-extensions/enhanced-data-table/data-table-pagination.tsx
(1 hunks)frontend/src/components/ui-extensions/enhanced-data-table/data-table-toolbar.tsx
(2 hunks)frontend/src/components/ui-extensions/enhanced-data-table/data-table.tsx
(7 hunks)frontend/src/components/ui/pagination.tsx
(1 hunks)
π§° Additional context used
𧬠Code Graph Analysis (2)
frontend/src/components/ui-extensions/enhanced-data-table/data-table-pagination.tsx (1)
frontend/src/components/ui/pagination.tsx (6)
PaginationLink
(112-112)Pagination
(110-110)PaginationContent
(111-111)PaginationItem
(113-113)PaginationPrevious
(114-114)PaginationNext
(115-115)
frontend/src/components/ui-extensions/enhanced-data-table/data-table-toolbar.tsx (1)
frontend/src/components/ui-extensions/enhanced-data-table/data-table-pagination.tsx (1)
DataTablePagination
(57-150)
β° Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Format & Lint
- GitHub Check: Compose Tests
- GitHub Check: Format, Lint, and Test
π Additional comments (24)
frontend/package.json (1)
30-30
: Appropriate dependency version update.Updating
@radix-ui/react-slot
from^1.1.2
to^1.2.2
appropriately supports the new pagination components that leverage the Slot primitive for component composition.frontend/src/app/linked-accounts/page.tsx (1)
399-402
: Well-implemented pagination configuration.The pagination settings with an initial page size of 10 items is a good default for this data table. This provides a nice balance between showing enough data without overwhelming the user interface.
frontend/src/components/ui-extensions/enhanced-data-table/data-table.tsx (7)
14-15
: Good addition of necessary TanStack Table imports.These imports correctly bring in the pagination model and state type from TanStack Table, which are required for implementing the pagination functionality.
49-52
: Well-defined pagination options interface.The
PaginationOptions
interface is clear and properly typed with optional properties, making it flexible for different usage scenarios.
60-60
: Proper interface extension.Adding the optional
paginationOptions
property to theEnhancedDataTableProps
interface makes pagination opt-in, which is a good design choice.
89-92
: Clean pagination state initialization.The pagination state is properly initialized with sensible defaults, falling back to page index 0 and page size 10 when not explicitly provided.
112-112
: Correct state management for pagination.The pagination state is correctly included in the table state object, and the dependency array for the
useMemo
hook is properly updated to include pagination.Also applies to: 121-121
129-135
: Effective conditional pagination setup.The pagination row model is conditionally applied only when pagination options are provided, and the pagination change handler is correctly wired up. This is an elegant approach that avoids unnecessary processing when pagination isn't needed.
189-189
: Proper prop passing to toolbar.The
paginationOptions
prop is correctly passed down to theEnhancedDataTableToolbar
component, enabling the conditional rendering of pagination controls.frontend/src/components/ui-extensions/enhanced-data-table/data-table-toolbar.tsx (4)
8-8
: Appropriate component import.Importing the
DataTablePagination
component correctly brings in the specialized pagination UI for the data table.
10-13
: Consistent interface definition.The
PaginationOptions
interface matches the one in the data table component, maintaining consistency across the component hierarchy.
20-20
: Clean interface extension.The toolbar props interface is properly extended to include the optional pagination options.
70-70
: Effective conditional rendering.The pagination component is only rendered when pagination options are provided, which is an efficient approach that avoids rendering unnecessary UI elements.
Looking at the
DataTablePagination
implementation from the relevant code snippets, the pagination controls include first/previous/next/last buttons and a jump-to-page input with validation, providing a complete pagination experience.frontend/src/components/ui-extensions/enhanced-data-table/data-table-pagination.tsx (5)
23-36
: LGTM: Well-implemented PaginationFirst component with proper accessibility.The PaginationFirst component is well-structured, properly extends PaginationLink, and includes appropriate aria-label and screen reader text for accessibility.
38-51
: LGTM: Well-implemented PaginationLast component with proper accessibility.The PaginationLast component follows the same good pattern as PaginationFirst, with appropriate accessibility attributes.
60-68
: LGTM: Proper state management and synchronization.The component correctly manages its internal state and synchronizes with the table's current page index using useEffect.
70-73
: LGTM: Well-implemented page jumping function.The jumpToPage function correctly handles boundary conditions, ensuring the page index is always within valid range.
134-136
: π οΈ Refactor suggestionFix incorrect disable condition for PaginationLast button.
The PaginationLast button uses the same condition as PaginationNext, but it should check if we're already at the last page specifically.
className={ - !table.getCanNextPage() + !(table.getState().pagination.pageIndex < pageCount - 1) ? "pointer-events-none opacity-50" : "" }Likely an incorrect or invalid review comment.
frontend/src/components/ui/pagination.tsx (6)
7-14
: LGTM: Well-structured Pagination component with proper accessibility attributes.The Pagination component correctly uses the navigation role and includes an aria-label for accessibility.
17-26
: LGTM: Well-implemented PaginationContent component.The PaginationContent component correctly uses forwardRef and has appropriate styling.
37-60
: LGTM: Well-designed PaginationLink component with proper aria attributes.The PaginationLink component is well-implemented with proper aria-current attribute for accessibility and a clean approach to styling active state.
62-76
: LGTM: Well-implemented PaginationPrevious component with good accessibility.The PaginationPrevious component includes both icon and text label, with proper aria-label for accessibility.
78-92
: LGTM: Well-implemented PaginationNext component with good accessibility.The PaginationNext component is consistent with PaginationPrevious and has proper accessibility attributes.
94-107
: LGTM: Well-implemented PaginationEllipsis with screen reader support.The PaginationEllipsis component correctly uses aria-hidden for the visual ellipsis while providing descriptive text for screen readers.
π·οΈ Ticket
Closes #295
π Description
This PR introduces front-end pagination support to the
EnhancedDataTable
component via TanStack Table's pagination model and integrates it into theLinkedAccountsPage
. It also includes a jump-to-page input UX, improves pagination accessibility via ShadCN components, and conditionally renders the pagination toolbar when options are provided.π₯ Demo (if applicable)
N/A
πΈ Screenshots (if applicable)
β Checklist
Summary by CodeRabbit
New Features
Enhancements
Chores