forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Grid View to new UI (apache#45497)
* Basic grid view Add task selection Refactor away from a table layout. Include pagination. Remove tooltips Add date ticks, remove multiple nested tasks iteration Add toggle groups, fix memos and date ticks Add title as standin for tooltips * Fix comment * Rebase grid colors
- Loading branch information
Showing
17 changed files
with
819 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/*! | ||
* 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 { Link } from "@chakra-ui/react"; | ||
import { useParams, useSearchParams, Link as RouterLink } from "react-router-dom"; | ||
|
||
import { TaskName, type TaskNameProps } from "src/components/TaskName"; | ||
|
||
type Props = { | ||
readonly id: string; | ||
} & TaskNameProps; | ||
|
||
export const TaskLink = ({ id, isGroup, ...rest }: Props) => { | ||
const { dagId = "", runId, taskId } = useParams(); | ||
const [searchParams] = useSearchParams(); | ||
|
||
// We don't have a task group details page to link to | ||
if (isGroup) { | ||
return <TaskName isGroup={true} {...rest} />; | ||
} | ||
|
||
return ( | ||
<Link asChild data-testid={id}> | ||
<RouterLink | ||
to={{ | ||
// Do not include runId if there is no selected run, clicking a second time will deselect a task id | ||
pathname: `/dags/${dagId}/${runId === undefined ? "" : `runs/${runId}/`}${taskId === id ? "" : `tasks/${id}`}`, | ||
search: searchParams.toString(), | ||
}} | ||
> | ||
<TaskName {...rest} /> | ||
</RouterLink> | ||
</Link> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/*! | ||
* 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 { Flex, Box, VStack, Text } from "@chakra-ui/react"; | ||
import { useParams, useSearchParams } from "react-router-dom"; | ||
|
||
import { RunTypeIcon } from "src/components/RunTypeIcon"; | ||
import Time from "src/components/Time"; | ||
|
||
import { GridButton } from "./GridButton"; | ||
import { TaskInstances } from "./TaskInstances"; | ||
import type { GridTask, RunWithDuration } from "./utils"; | ||
|
||
const BAR_HEIGHT = 100; | ||
|
||
type Props = { | ||
readonly index: number; | ||
readonly limit: number; | ||
readonly max: number; | ||
readonly nodes: Array<GridTask>; | ||
readonly run: RunWithDuration; | ||
}; | ||
|
||
export const Bar = ({ index, limit, max, nodes, run }: Props) => { | ||
const { dagId = "", runId } = useParams(); | ||
const [searchParams] = useSearchParams(); | ||
|
||
const isSelected = runId === run.dag_run_id; | ||
|
||
const search = searchParams.toString(); | ||
|
||
const shouldShowTick = index % 8 === 0 || index === limit - 1; | ||
|
||
return ( | ||
<Box | ||
_hover={{ bg: "blue.subtle" }} | ||
bg={isSelected ? "blue.muted" : undefined} | ||
position="relative" | ||
transition="background-color 0.2s" | ||
> | ||
<Flex | ||
alignItems="flex-end" | ||
height={BAR_HEIGHT} | ||
justifyContent="center" | ||
pb="2px" | ||
px="5px" | ||
width="14px" | ||
zIndex={1} | ||
> | ||
<GridButton | ||
dagId={dagId} | ||
height={`${(run.duration / max) * BAR_HEIGHT}px`} | ||
justifyContent="flex-end" | ||
label={run.dag_run_id} | ||
minHeight="14px" | ||
runId={run.dag_run_id} | ||
searchParams={search} | ||
state={run.state} | ||
zIndex={1} | ||
> | ||
{run.run_type !== "scheduled" && <RunTypeIcon runType={run.run_type} size="8px" />} | ||
</GridButton> | ||
{shouldShowTick ? ( | ||
<VStack gap={0} left="8px" position="absolute" top={0} width={0} zIndex={-1}> | ||
<Text | ||
color="border.emphasized" | ||
fontSize="xs" | ||
mt="-35px !important" | ||
transform="rotate(-40deg) translateX(28px)" | ||
whiteSpace="nowrap" | ||
> | ||
<Time datetime={run.data_interval_start} format="MMM DD, HH:mm" /> | ||
</Text> | ||
<Box borderLeftWidth={1} height="100px" opacity={0.7} zIndex={0} /> | ||
</VStack> | ||
) : undefined} | ||
</Flex> | ||
<TaskInstances nodes={nodes} runId={run.dag_run_id} taskInstances={run.task_instances} /> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/*! | ||
* 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 { Box, type BoxProps } from "@chakra-ui/react"; | ||
|
||
export const DurationAxis = (props: BoxProps) => ( | ||
<Box borderBottomWidth={1} left="30px" position="absolute" right="25px" zIndex={0} {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/*! | ||
* 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 { Text, type TextProps } from "@chakra-ui/react"; | ||
|
||
export const DurationTick = ({ children, ...rest }: TextProps) => ( | ||
<Text color="border.emphasized" fontSize="xs" position="absolute" right={1} whiteSpace="nowrap" {...rest}> | ||
{children} | ||
</Text> | ||
); |
Oops, something went wrong.