Skip to content

Commit

Permalink
Improve DAGs table UI (apache#42119)
Browse files Browse the repository at this point in the history
* Rebase and fix filter pagination

* Add pluralize test
  • Loading branch information
bbovenzi authored Sep 10, 2024
1 parent c5e058a commit afc0532
Show file tree
Hide file tree
Showing 12 changed files with 488 additions and 91 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ pnpm-debug.log*
.vscode/*
!.vscode/extensions.json
/.vite/
/.pnpm-store/

# Airflow log files when airflow is run locally
airflow-*.err
Expand Down
2 changes: 2 additions & 0 deletions airflow/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
"test": "vitest run"
},
"dependencies": {
"@chakra-ui/anatomy": "^2.2.2",
"@chakra-ui/react": "^2.8.2",
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@tanstack/react-query": "^5.52.1",
"@tanstack/react-table": "^8.20.1",
"axios": "^1.7.4",
"chakra-react-select": "^4.9.2",
"framer-motion": "^11.3.29",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
130 changes: 130 additions & 0 deletions airflow/ui/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 2 additions & 26 deletions airflow/ui/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,16 @@
* 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 { Box } from "@chakra-ui/react";
import { DagsList } from "src/dagsList";
import { Nav } from "src/nav";

export const App = () => {
// TODO: Change this to be taken from airflow.cfg
const pageSize = 50;
const [pagination, setPagination] = useState<PaginationState>({
pageIndex: 0,
pageSize: pageSize,
});

const { data, isLoading } = useDagServiceGetDags({
limit: pagination.pageSize,
offset: pagination.pageIndex * pagination.pageSize,
});

return (
<div>
<Nav />
<Box p={3} ml={24}>
{isLoading && <Spinner />}
{!isLoading && !!data?.dags && (
<DagsList
data={data.dags}
total={data.total_entries}
pagination={pagination}
setPagination={setPagination}
/>
)}
<DagsList />
</Box>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
* under the License.
*/

"use client";

import {
ColumnDef,
Table as TanStackTable,
Expand All @@ -41,6 +39,7 @@ import {
Th,
Thead,
Tr,
useColorModeValue,
} from "@chakra-ui/react";
import React, { Fragment } from "react";

Expand Down Expand Up @@ -143,10 +142,12 @@ export function DataTable<TData>({
},
});

const theadBg = useColorModeValue("white", "gray.800");

return (
<TableContainer>
<ChakraTable variant="striped">
<Thead>
<TableContainer overflowY="auto" maxH="calc(100vh - 10rem)">
<ChakraTable colorScheme="blue">
<Thead position="sticky" top={0} bg={theadBg}>
{table.getHeaderGroups().map((headerGroup) => (
<Tr key={headerGroup.id}>
{headerGroup.headers.map((header) => {
Expand Down
20 changes: 20 additions & 0 deletions airflow/ui/src/components/DataTable/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*!
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export * from "./DataTable";
Loading

0 comments on commit afc0532

Please sign in to comment.