-
Notifications
You must be signed in to change notification settings - Fork 16.7k
Add failed and deadline indicators to Grid view #62195
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
base: main
Are you sure you want to change the base?
Changes from all commits
e593169
963ad54
15d67f4
b75c411
80351f9
fe586c8
71ccaad
d932933
af9d4d2
c851cb1
e8099a6
d78dc22
ea0649e
435cb3e
9e17bf0
d083286
d847834
709a4cc
7b9c20a
5d348eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,8 +16,9 @@ | |
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| import { Flex, Box } from "@chakra-ui/react"; | ||
| import { useParams, useSearchParams } from "react-router-dom"; | ||
| import { Flex, Box, Center, Button, Icon } from "@chakra-ui/react"; | ||
| import { LuClock, LuTriangleAlert } from "react-icons/lu"; | ||
| import { useParams, useSearchParams, useNavigate } from "react-router-dom"; | ||
|
|
||
| import { RunTypeIcon } from "src/components/RunTypeIcon"; | ||
| import { VersionIndicatorOptions } from "src/constants/showVersionIndicatorOptions"; | ||
|
|
@@ -32,6 +33,11 @@ import { | |
| type GridRunWithVersionFlags, | ||
| } from "./useGridRunsWithVersionFlags"; | ||
|
|
||
| const ICON_GAP_PX = 4; | ||
| const ICON_HEIGHT_PX = 16; | ||
| const BAR_PADDING_BOTTOM_PX = 2; | ||
| const BAR_MIN_HEIGHT_PX = 14; | ||
|
|
||
| type Props = { | ||
| readonly max: number; | ||
| readonly onClick?: () => void; | ||
|
|
@@ -47,10 +53,24 @@ export const Bar = ({ max, onClick, run, showVersionIndicatorMode }: Props) => { | |
| const isSelected = runId === run.run_id; | ||
| const isHovered = hoveredRunId === run.run_id; | ||
| const search = searchParams.toString(); | ||
| const isFailed = (run.state ?? "").toLowerCase() === "failed"; | ||
| const hasMissedDeadline = Boolean(run.has_missed_deadline); | ||
| const barHeightPx = max > 0 ? (run.duration / max) * BAR_HEIGHT : 0; | ||
|
|
||
| const handleMouseEnter = () => setHoveredRunId(run.run_id); | ||
| const handleMouseLeave = () => setHoveredRunId(undefined); | ||
|
|
||
| const navigate = useNavigate(); | ||
|
|
||
| const handleDeadlineIconClick = () => { | ||
| void navigate({ pathname: `/dags/${dagId}/runs/${run.run_id}/deadlines`, search }); | ||
| }; | ||
|
|
||
| // Account for minHeight and padding-bottom so icons always appear above the rendered bar | ||
| const effectiveBarHeightPx = Math.max(barHeightPx, BAR_MIN_HEIGHT_PX) + BAR_PADDING_BOTTOM_PX; | ||
| const failedIconBottom = effectiveBarHeightPx + ICON_GAP_PX; | ||
| const deadlineIconBottom = isFailed ? failedIconBottom + ICON_HEIGHT_PX : failedIconBottom; | ||
|
|
||
|
Comment on lines
+70
to
+73
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could break alignment with the 'Gantt', can you show a picture with deadline alerts failed and the Gantt chart displayed.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| return ( | ||
| <Box | ||
| bg={isSelected ? "brand.emphasized" : isHovered ? "brand.muted" : undefined} | ||
|
|
@@ -59,6 +79,29 @@ export const Bar = ({ max, onClick, run, showVersionIndicatorMode }: Props) => { | |
| position="relative" | ||
| transition="background-color 0.2s" | ||
| > | ||
| {hasMissedDeadline ? ( | ||
| <Center bottom={`${deadlineIconBottom}px`} left={0} position="absolute" right={0} zIndex={2}> | ||
| <Button | ||
| _focusVisible={{ boxShadow: "none" }} | ||
| borderRadius={0} | ||
| h="auto" | ||
| lineHeight={1} | ||
| m={0} | ||
| minH={0} | ||
| minW={0} | ||
| onClick={handleDeadlineIconClick} | ||
| p={0} | ||
| variant="ghost" | ||
| > | ||
| <Icon as={LuClock} boxSize={3} color="warning.solid" /> | ||
| </Button> | ||
| </Center> | ||
| ) : undefined} | ||
| {isFailed ? ( | ||
| <Center bottom={`${failedIconBottom}px`} left={0} position="absolute" right={0} zIndex={2}> | ||
| <Icon as={LuTriangleAlert} boxSize={3} color="failed.solid" /> | ||
| </Center> | ||
| ) : undefined} | ||
| {run.isBundleVersionChange && | ||
| (showVersionIndicatorMode === VersionIndicatorOptions.BUNDLE_VERSION || | ||
| showVersionIndicatorMode === VersionIndicatorOptions.ALL) ? ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,8 @@ export const ROW_HEIGHT = 20; | |
| export const GRID_OUTER_PADDING_PX = 64; // pt={16} = 16 * 4 = 64px | ||
| export const GRID_HEADER_PADDING_PX = 16; // pt={4} = 4 * 4 = 16px | ||
| export const GRID_HEADER_HEIGHT_PX = 100; // height="100px" for duration bars | ||
| // Space above bars for failed-run icon so it is not clipped | ||
| export const GRID_HEADER_ICON_SPACE_PX = 28; | ||
|
Comment on lines
+25
to
+26
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is making computation complex and easy to mess up in the Grid component. We should probably refactor to make it more straight forward.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was trying to use flexbox before, but the ui kept breaking. Will try to figure out how to get it working without the calculation |
||
|
|
||
| // Gantt chart's x-axis height (time labels at top of chart) | ||
| export const GANTT_AXIS_HEIGHT_PX = 36; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| /*! | ||
| * 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 { Badge } from "@chakra-ui/react"; | ||
| import type { ColumnDef } from "@tanstack/react-table"; | ||
| import type { TFunction } from "i18next"; | ||
| import { useTranslation } from "react-i18next"; | ||
| import { useParams } from "react-router-dom"; | ||
|
|
||
| import { useDeadlinesServiceGetDagRunDeadlines } from "openapi/queries"; | ||
| import type { DeadlineResponse } from "openapi/requests"; | ||
| import { DataTable } from "src/components/DataTable"; | ||
| import { useTableURLState } from "src/components/DataTable/useTableUrlState"; | ||
| import { ErrorAlert } from "src/components/ErrorAlert"; | ||
| import Time from "src/components/Time"; | ||
|
|
||
| const columns = (translate: TFunction): Array<ColumnDef<DeadlineResponse>> => [ | ||
| { | ||
| accessorKey: "alert_name", | ||
| header: translate("deadlines.name"), | ||
| id: "alert_name", | ||
| }, | ||
| { | ||
| accessorKey: "deadline_time", | ||
| cell: ({ row }) => <Time datetime={row.original.deadline_time} />, | ||
| header: translate("deadlines.deadlineTime"), | ||
| id: "deadline_time", | ||
| }, | ||
| { | ||
| accessorKey: "missed", | ||
| cell: ({ row }) => ( | ||
| <Badge colorPalette={row.original.missed ? "red" : "green"}> | ||
| {row.original.missed ? translate("deadlines.missed") : translate("deadlines.onTrack")} | ||
| </Badge> | ||
| ), | ||
| enableSorting: false, | ||
| header: translate("deadlines.status"), | ||
| id: "missed", | ||
| }, | ||
| { | ||
| accessorKey: "created_at", | ||
| cell: ({ row }) => <Time datetime={row.original.created_at} />, | ||
| header: translate("deadlines.createdAt"), | ||
| id: "created_at", | ||
| }, | ||
| { | ||
| accessorKey: "alert_description", | ||
| enableSorting: false, | ||
| header: translate("deadlines.description"), | ||
| id: "alert_description", | ||
| }, | ||
| ]; | ||
|
|
||
| export const Deadlines = () => { | ||
| const { t: translate } = useTranslation("dag"); | ||
| const { dagId = "", runId = "" } = useParams(); | ||
| const { setTableURLState, tableURLState } = useTableURLState(); | ||
| const { pagination, sorting } = tableURLState; | ||
| const [sort] = sorting; | ||
| const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : ["deadline_time"]; | ||
|
|
||
| const { data, error, isLoading } = useDeadlinesServiceGetDagRunDeadlines( | ||
| { | ||
| dagId, | ||
| dagRunId: runId, | ||
| limit: pagination.pageSize, | ||
| offset: pagination.pageIndex * pagination.pageSize, | ||
| orderBy, | ||
| }, | ||
| undefined, | ||
| { placeholderData: (prev) => prev }, | ||
| ); | ||
|
|
||
| return ( | ||
| <DataTable | ||
| columns={columns(translate)} | ||
| data={data?.deadlines ?? []} | ||
| errorMessage={<ErrorAlert error={error} />} | ||
| initialState={tableURLState} | ||
| isLoading={isLoading} | ||
| modelName="common:deadline" | ||
| onStateChange={setTableURLState} | ||
| total={data?.total_entries} | ||
| /> | ||
| ); | ||
| }; |


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.
Why that 'isFailed' based on the 'run.state' ? We do not set an icon for each possible dag run states, what is the motivation here?
Uh oh!
There was an error while loading. Please reload this page.
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.
It is to prevent the failed icon and deadline icon from overlapping