tirkarthi commented on code in PR #41905:
URL: https://github.com/apache/airflow/pull/41905#discussion_r1743970885
##########
airflow/ui/src/dagsList.tsx:
##########
@@ -84,23 +89,100 @@ const columns: ColumnDef<DAG>[] = [
type TableProps<TData> = {
data: TData[];
+ total: number | undefined;
columns: ColumnDef<TData>[];
renderSubComponent: (props: { row: Row<TData> }) => React.ReactElement;
getRowCanExpand: (row: Row<TData>) => boolean;
+ pagination: PaginationState;
+ setPagination: OnChangeFn<PaginationState>;
};
+type PaginatorProps<TData> = {
+ table: TanStackTable<TData>;
+};
+
+function TablePaginator({ table }: PaginatorProps<DAG>) {
+ const pageInterval = 3;
+ const currentPageNumber = table.getState().pagination.pageIndex + 1;
+ const startPageNumber = Math.max(1, currentPageNumber - pageInterval);
+ const endPageNumber = Math.min(
+ table.getPageCount(),
+ startPageNumber + pageInterval * 2
+ );
+ const pageNumbers = [];
+
+ for (let index = startPageNumber; index <= endPageNumber; index++) {
+ pageNumbers.push(
+ <Button
+ borderRadius={0}
+ key={index}
+ isDisabled={index === currentPageNumber}
+ onClick={() => table.setPageIndex(index - 1)}
+ >
+ {" "}
+ {index}{" "}
+ </Button>
+ );
+ }
+
+ return (
+ <Box mt={2} mb={2}>
+ <Button
+ borderRadius={0}
+ onClick={() => table.firstPage()}
+ isDisabled={!table.getCanPreviousPage()}
+ >
+ {"<<"}
Review Comment:
I am not well versed with JSX syntax but it throws an error for me.
```
(myenv) ➜ ui git:(add-pagination) ✗ node_modules/prettier/bin/prettier.cjs
-w src/app.tsx src/dagsList.tsx
src/app.tsx 78ms (unchanged)
src/dagsList.tsx
[error] src/dagsList.tsx: SyntaxError: Identifier expected. (134:10)
[error] 132 | isDisabled={!table.getCanPreviousPage()}
[error] 133 | >
[error] > 134 | <<
[error] | ^
[error] 135 | </Button>
[error] 136 |
[error] 137 | <Button
(myenv) ➜ ui git:(add-pagination) ✗ node_modules/prettier/bin/prettier.cjs
-w src/app.tsx src/dagsList.tsx
src/app.tsx 72ms (unchanged)
src/dagsList.tsx
[error] src/dagsList.tsx: SyntaxError: Identifier expected. (134:11)
[error] 132 | isDisabled={!table.getCanPreviousPage()}
[error] 133 | >
[error] > 134 | "<<"
[error] | ^
[error] 135 | </Button>
[error] 136 |
[error] 137 | <Button
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]