-
Notifications
You must be signed in to change notification settings - Fork 9
OINT-1210: Datatable pagination #486
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Bug Report
|
|
1 similar comment
|
✨ No issues found! Your code is sparkling clean! ✨ 🗒️ View all ignored comments in this repo
|
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.
PR Summary
This PR implements comprehensive pagination functionality across the application's data tables, with server-side pagination support and consistent UI patterns.
- Added
PaginatedData
type inpackages/ui-v1/components/DataTable.tsx
to standardize pagination structure across tables - Implemented server-side pagination in
DataTable
component with manual pagination control and loading states - Fixed potential memory leak in
columnsWithActions
useMemo dependency array inapps/web/app/console/(authenticated)/connections/page.client.tsx
- Added consistent page size of 10 items across all table implementations
- Added loading state handling during page transitions with visual feedback
💡 (4/5) You can add custom instructions or style guidelines for the bot here!
8 file(s) reviewed, 10 comment(s)
Edit PR Review Bot Settings | Greptile
apps/web/app/console/(authenticated)/connector-config/page.client.tsx
Outdated
Show resolved
Hide resolved
const PaginatedTable = (props: DataTableProps<Person, string | number>) => { | ||
const [pageIndex, setPageIndex] = useState(0) | ||
const [isLoading, setIsLoading] = useState(false) | ||
const [currentData, setCurrentData] = useState(generateRandomData(10)) |
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.
style: initial data generation should use props.data.limit instead of hardcoded 10
type Story = StoryObj< | ||
| typeof DataTable<Core['connector_config_select'], unknown> | ||
| typeof ConnectorConfigTable | ||
typeof DataTable<Core['connector_config_select'], unknown> | ||
> |
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.
logic: Story type no longer includes ConnectorConfigTable but meta still uses it as component
type PaginatedData<T> = { | ||
items: T[] | ||
total: number | ||
limit: number | ||
offset: number | ||
} |
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.
style: PaginatedData type is duplicated from DataTable.tsx. Consider importing it instead of redefining.
const pageSize = isPaginated ? data.limit : items.length | ||
const currentPage = isPaginated ? Math.floor(data.offset / data.limit) : 0 | ||
|
||
const [pageIndex, setPageIndex] = useState(currentPage) |
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.
logic: pageIndex state may get out of sync with currentPage when data.offset changes externally
const [pageIndex, setPageIndex] = useState(currentPage) | |
const [pageIndex, setPageIndex] = useState(currentPage) | |
React.useEffect(() => { | |
setPageIndex(currentPage) | |
}, [currentPage]) |
|
||
export const Default: Story = { | ||
args: { | ||
data: customers, | ||
onPageChange: () => {}, |
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.
style: Empty onPageChange handler won't demonstrate pagination behavior. Consider adding a mock implementation that logs the page change.
onPageChange: () => {}, | |
onPageChange: (page: number) => { console.log('Page changed to:', page) }, |
? (updater) => { | ||
if (typeof updater === 'function') { | ||
const newState = updater({pageIndex, pageSize}) | ||
setPageIndex(newState.pageIndex) | ||
onPageChange?.(newState.pageIndex) | ||
} | ||
} |
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.
logic: onPaginationChange should handle non-function updaters (direct state updates) as well
type Story = StoryObj< | ||
typeof DataTable<AppRouterOutput['listCustomers']['items'][number], unknown> | ||
> | ||
type Story = StoryObj<typeof CustomersTable> |
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.
logic: Story type changed from DataTable to CustomersTable, but meta still uses DataTable as component. This mismatch could cause type issues.
type Story = StoryObj<typeof CustomersTable> | |
const meta: Meta<typeof CustomersTable> = { | |
title: 'Domain Components/CustomersTable', | |
component: CustomersTable, | |
parameters: { | |
layout: 'padded', | |
}, | |
} |
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.
❌ Changes requested. Reviewed everything up to f6198c2 in 2 minutes and 3 seconds
More details
- Looked at
808
lines of code in8
files - Skipped
0
files when reviewing. - Skipped posting
19
drafted comments based on config settings.
1. apps/web/app/console/(authenticated)/connections/page.client.tsx:63
- Draft comment:
Pagination is implemented correctly using pageIndex; ensure that the offset calculation (pageIndex * 10) aligns with API expected values. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
2. apps/web/app/console/(authenticated)/connector-config/page.client.tsx:35
- Draft comment:
Pagination is added by setting limit and offset; ensure that multiple queries (connector configs, connectors) remain in sync if pagination affects both. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
3. apps/web/app/console/(authenticated)/customers/page.client.tsx:9
- Draft comment:
Ensure the use of pageIndex state properly drives the customer list pagination. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
4. packages/ui-v1/components/DataTable.stories.tsx:207
- Draft comment:
The PaginatedTable story simulates a delay; ensure the delay logic (setTimeout) mimics real API pagination without side effects. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
5. packages/ui-v1/components/DataTable.tsx:180
- Draft comment:
The onPaginationChange callback only handles function updaters. Consider handling cases where updater might be a direct object for broader compatibility. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
6. packages/ui-v1/domain-components/tables/ConnectorConfigTable.stories.tsx:137
- Draft comment:
The Default story passes data as connectorConfigs.items while WithPagination uses connectorConfigs. Ensure clarity across stories for paginated and non-paginated props. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
7. packages/ui-v1/domain-components/tables/CustomerTable.tsx:71
- Draft comment:
The CustomersTable component wraps DataTable correctly. Verify that onPageChange and isLoading props align with paginated data structure expected by DataTable. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
8. packages/ui-v1/domain-components/tables/CustomersTable.stories.tsx:59
- Draft comment:
The story for CustomersTable provides a paginated data object. Ensure that the shape of data matches what CustomersTable component expects. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
9. apps/web/app/console/(authenticated)/connections/page.client.tsx:73
- Draft comment:
Consider memoizing the 'handlePageChange' function to avoid unnecessary re-renders. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
10. apps/web/app/console/(authenticated)/connector-config/page.client.tsx:53
- Draft comment:
Pagination logic is integrated well. Consider resetting pageIndex when filters or data conditions change. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
11. apps/web/app/console/(authenticated)/customers/page.client.tsx:17
- Draft comment:
Pagination options for listCustomers are correctly applied via limit and offset. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
12. packages/ui-v1/components/DataTable.stories.tsx:226
- Draft comment:
Consider parameterizing the simulated async delay in PaginatedTable for easier testing and clarity. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
13. packages/ui-v1/components/DataTable.tsx:180
- Draft comment:
Ensure that the onPaginationChange updater is always a function; consider adding fallback handling if a non‐function value is provided. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
14. packages/ui-v1/components/DataTable.tsx:195
- Draft comment:
Revisit memoization of the context value to ensure stable re-renders without performance trade-offs (see commented-out optimization). - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
15. packages/ui-v1/domain-components/tables/ConnectorConfigTable.stories.tsx:137
- Draft comment:
Ensure consistent data shapes for connectorConfigs: default stories pass an array while the pagination variant passes a full paginated object. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
16. packages/ui-v1/domain-components/tables/CustomersTable.stories.tsx:59
- Draft comment:
Consider adding additional story variants to simulate different pagination states (e.g. loading, empty page) for CustomersTable. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
17. packages/ui-v1/components/DataTable.stories.tsx:71
- Draft comment:
Typo: Remove the trailing comma after the closing tag of the Button in the NoData story's JSX. It may be confusing or lead to formatting issues. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
18. packages/ui-v1/components/DataTable.stories.tsx:97
- Draft comment:
Typo: Please remove the trailing comma after the closing Button tag in the WithCallToAction story's header. This extra comma is unnecessary and may affect consistency. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
19. packages/ui-v1/components/DataTable.tsx:248
- Draft comment:
Typo: The class 'size-full' seems out of place. In Tailwind CSS, 'w-full' is typically used for full width. Consider correcting this if it was unintentional. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
Workflow ID: wflow_GwGYdqR3e0Vh9RVR
Want Ellipsis to fix these issues? Tag @ellipsis-dev
in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
const pageSize = isPaginated ? data.limit : items.length | ||
const currentPage = isPaginated ? Math.floor(data.offset / data.limit) : 0 | ||
|
||
const [pageIndex, setPageIndex] = useState(currentPage) |
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.
The derived currentPage
is computed from data.offset
but pageIndex
state is initialized only once. Consider adding an effect to resync pageIndex
when data.offset
changes.
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.
Approach seems reasonable.
Please
- Upload upload a video of it
- Make 20 by default
- Add to the events table
- Address some of the concerning comments form the bots
f6198c2
to
2752bcb
Compare
Error: Agent timed out after 12 minutes of thinking |
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.
Important
Looks good to me! 👍
Reviewed 2752bcb in 51 seconds. Click for details.
- Reviewed
93
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
7
draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. apps/web/app/console/(authenticated)/events/page.client.tsx:25
- Draft comment:
Good move shifting timestamp formatting into the cell renderer. Consider memoizing the date formatting for performance if the table is large. - Reason this comment was not posted:
Confidence changes required:20%
<= threshold50%
None
2. apps/web/app/console/(authenticated)/events/page.client.tsx:50
- Draft comment:
Ensure the TRPC response returns a paginated object with the expected shape (items, total, limit, offset) to match the DataTable's paginated data setup. - Reason this comment was not posted:
Confidence changes required:30%
<= threshold50%
None
3. packages/ui-v1/components/DataTable.tsx:375
- Draft comment:
Pagination now also checks for totalCount === 0 to not render pagination controls. Confirm that this behavior is intended, especially when zero items are a valid state. - Reason this comment was not posted:
Confidence changes required:20%
<= threshold50%
None
4. apps/web/app/console/(authenticated)/events/page.client.tsx:25
- Draft comment:
Good use of a custom cell for timestamp formatting. Consider extracting the repeated date formatting logic into a shared utility for consistency (e.g. used in sheet details too). - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
5. apps/web/app/console/(authenticated)/events/page.client.tsx:50
- Draft comment:
Pagination params (limit and offset) are now passed to the TRPC query. Verify that the backend correctly handles these values. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
6. apps/web/app/console/(authenticated)/events/page.client.tsx:63
- Draft comment:
handlePageChange updates pageIndex; ensure any dependent state (if needed) is also reset when changing pages. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
7. packages/ui-v1/components/DataTable.tsx:375
- Draft comment:
The added check for paginationInfo.totalCount === 0 cleanly avoids rendering pagination when no items exist. Ensure this behavior aligns with the overall UX for empty states. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
Workflow ID: wflow_WSKTfiNBMAfG4Rlf
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Important
Adds pagination support to
DataTable
and updates various components to utilize paginated data handling.ConnectionsPage
,ConnectorConfigList
,CustomerList
, andEventsList
by introducingDATA_PER_PAGE
constant andpageIndex
state.DataTable
component to handle paginated data withPaginatedData
type andonPageChange
callback.processTypedPaginatedResponse()
inpagination.ts
to calculate total based on result length.DataTable
inDataTable.tsx
to support pagination withmanualPagination
andpageCount
.Pagination
component toDataTable
for navigation controls.CustomersTable
,ConnectorConfigTable
, andDataTable
stories to demonstrate pagination.events/page.client.tsx
.handlePageChange
function to manage page index state in multiple components.This description was created by
for 2752bcb. You can customize this summary. It will automatically update as commits are pushed.