From 7650f09d5647be6331a804c513a80df43be8a10e Mon Sep 17 00:00:00 2001 From: Karthikeyan Singaravelan Date: Wed, 4 Sep 2024 22:17:11 +0530 Subject: [PATCH] Implement pagination for the new home page. (#41905) * Implement pagination for the home page. * Add page number buttons. * Change default number of dags to display to 50. * Fix imports. * Fix PR comments. --- airflow/ui/src/app.tsx | 23 ++++++++- airflow/ui/src/dagsList.tsx | 97 ++++++++++++++++++++++++++++++++++++- 2 files changed, 117 insertions(+), 3 deletions(-) diff --git a/airflow/ui/src/app.tsx b/airflow/ui/src/app.tsx index d5d582c7902e7..a8e2b213f8ae9 100644 --- a/airflow/ui/src/app.tsx +++ b/airflow/ui/src/app.tsx @@ -17,21 +17,40 @@ * under the License. */ +import { useState } from "react"; import { Box, Spinner } from "@chakra-ui/react"; +import { PaginationState } from "@tanstack/react-table"; import { useDagServiceGetDags } from "openapi/queries"; import { DagsList } from "src/dagsList"; import { Nav } from "src/nav"; export const App = () => { - const { data, isLoading } = useDagServiceGetDags(); + // TODO: Change this to be taken from airflow.cfg + const pageSize = 50; + const [pagination, setPagination] = useState({ + pageIndex: 0, + pageSize: pageSize, + }); + + const { data, isLoading } = useDagServiceGetDags({ + limit: pagination.pageSize, + offset: pagination.pageIndex * pagination.pageSize, + }); return (