From 410b93083bb2d9889d8acc495513328f81b49794 Mon Sep 17 00:00:00 2001 From: Brent Bovenzi Date: Wed, 11 Dec 2024 13:05:34 -0500 Subject: [PATCH] Add Task Details page (#44828) * Add Task Details page * Fix sorts and links --- airflow/ui/src/assets/TaskIcon.tsx | 41 +++++++ airflow/ui/src/pages/Dag/Tasks/TaskCard.tsx | 47 +++---- airflow/ui/src/pages/Dag/Tasks/Tasks.tsx | 15 ++- airflow/ui/src/pages/DagsList/DagCard.tsx | 20 +-- airflow/ui/src/pages/Run/TaskInstances.tsx | 31 ++--- airflow/ui/src/pages/Task/Header.tsx | 53 ++++++++ airflow/ui/src/pages/Task/Instances.tsx | 129 ++++++++++++++++++++ airflow/ui/src/pages/Task/Task.tsx | 90 ++++++++++++++ airflow/ui/src/pages/Task/index.ts | 21 ++++ airflow/ui/src/router.tsx | 9 ++ 10 files changed, 408 insertions(+), 48 deletions(-) create mode 100644 airflow/ui/src/assets/TaskIcon.tsx create mode 100644 airflow/ui/src/pages/Task/Header.tsx create mode 100644 airflow/ui/src/pages/Task/Instances.tsx create mode 100644 airflow/ui/src/pages/Task/Task.tsx create mode 100644 airflow/ui/src/pages/Task/index.ts diff --git a/airflow/ui/src/assets/TaskIcon.tsx b/airflow/ui/src/assets/TaskIcon.tsx new file mode 100644 index 0000000000000..cd8f4440f09d3 --- /dev/null +++ b/airflow/ui/src/assets/TaskIcon.tsx @@ -0,0 +1,41 @@ +/*! + * 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. + */ +import { createIcon } from "@chakra-ui/react"; + +export const TaskIcon = createIcon({ + defaultProps: { + height: "1em", + width: "1em", + }, + displayName: "Task Icon", + path: ( + + + + + + ), + viewBox: "0 0 16 16", +}); diff --git a/airflow/ui/src/pages/Dag/Tasks/TaskCard.tsx b/airflow/ui/src/pages/Dag/Tasks/TaskCard.tsx index 05726989a91d6..d8a2ffe158c24 100644 --- a/airflow/ui/src/pages/Dag/Tasks/TaskCard.tsx +++ b/airflow/ui/src/pages/Dag/Tasks/TaskCard.tsx @@ -16,14 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -import { - Heading, - VStack, - HStack, - Box, - SimpleGrid, - Text, -} from "@chakra-ui/react"; +import { Heading, VStack, Box, SimpleGrid, Text, Link } from "@chakra-ui/react"; +import { Link as RouterLink } from "react-router-dom"; import type { TaskResponse, @@ -36,22 +30,27 @@ import { Status } from "src/components/ui"; import { TaskRecentRuns } from "./TaskRecentRuns.tsx"; type Props = { + readonly dagId: string; readonly task: TaskResponse; readonly taskInstances: Array; }; -export const TaskCard = ({ task, taskInstances }: Props) => ( +export const TaskCard = ({ dagId, task, taskInstances }: Props) => ( - - {task.task_display_name ?? task.task_id} - {task.is_mapped ? "[]" : undefined} - - + + + {task.task_display_name ?? task.task_id} + {task.is_mapped ? "[]" : undefined} + + + Operator @@ -70,14 +69,18 @@ export const TaskCard = ({ task, taskInstances }: Props) => ( {taskInstances[0] ? ( - - + + + + ) : undefined} diff --git a/airflow/ui/src/pages/Dag/Tasks/Tasks.tsx b/airflow/ui/src/pages/Dag/Tasks/Tasks.tsx index 4b844ad2b64f9..4b76110099e15 100644 --- a/airflow/ui/src/pages/Dag/Tasks/Tasks.tsx +++ b/airflow/ui/src/pages/Dag/Tasks/Tasks.tsx @@ -36,10 +36,12 @@ import { pluralize } from "src/utils"; import { TaskCard } from "./TaskCard"; const cardDef = ( + dagId: string, taskInstances?: Array, ): CardDef => ({ card: ({ row }) => ( { - const { dagId } = useParams(); + const { dagId = "" } = useParams(); const { data, error: tasksError, isFetching, isLoading, } = useTaskServiceGetTasks({ - dagId: dagId ?? "", + dagId, }); // TODO: Replace dagIdPattern with dagId once supported for better matching const { data: runsData } = useDagsServiceRecentDagRuns( - { dagIdPattern: dagId ?? "", dagRunsLimit: 14 }, + { dagIdPattern: dagId, dagRunsLimit: 14 }, undefined, { enabled: Boolean(dagId), @@ -85,7 +87,7 @@ export const Tasks = () => { const { data: taskInstancesResponse } = useTaskInstanceServiceGetTaskInstances( { - dagId: dagId ?? "", + dagId, dagRunId: "~", logicalDateGte: runs.at(-1)?.logical_date ?? "", }, @@ -100,7 +102,10 @@ export const Tasks = () => { {pluralize("Task", data ? data.total_entries : 0)} { {latestRun ? ( - + + + + + ) : undefined} diff --git a/airflow/ui/src/pages/Run/TaskInstances.tsx b/airflow/ui/src/pages/Run/TaskInstances.tsx index 9503b2e20ad2e..95b1ebf3c92f7 100644 --- a/airflow/ui/src/pages/Run/TaskInstances.tsx +++ b/airflow/ui/src/pages/Run/TaskInstances.tsx @@ -41,16 +41,8 @@ const columns: Array> = [ ), - header: "Task ID", - }, - { - accessorKey: "map_index", - header: "Map Index", - }, - { - accessorKey: "try_number", enableSorting: false, - header: "Try Number", + header: "Task ID", }, { accessorKey: "state", @@ -61,11 +53,6 @@ const columns: Array> = [ }) => {state}, header: () => "State", }, - { - accessorKey: "operator", - enableSorting: false, - header: "Operator", - }, { accessorKey: "start_date", cell: ({ row: { original } }) =>