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.
Flesh out a basic task instance details page
- Loading branch information
Showing
7 changed files
with
226 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/*! | ||
* 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, Flex, Heading, HStack, SimpleGrid, Text } from "@chakra-ui/react"; | ||
import dayjs from "dayjs"; | ||
import { MdOutlineModeComment, MdOutlineTask } from "react-icons/md"; | ||
|
||
import type { TaskInstanceResponse } from "openapi/requests/types.gen"; | ||
import { Stat } from "src/components/Stat"; | ||
import Time from "src/components/Time"; | ||
import { Status } from "src/components/ui"; | ||
|
||
export const Header = ({ | ||
taskInstance, | ||
}: { | ||
readonly taskInstance: TaskInstanceResponse; | ||
}) => ( | ||
<Box borderColor="border" borderRadius={8} borderWidth={1}> | ||
<Box p={2}> | ||
<Flex alignItems="center" justifyContent="space-between" mb={2}> | ||
<HStack alignItems="center" gap={2}> | ||
<MdOutlineTask size="1.75rem" /> | ||
<Heading size="lg"> | ||
<strong>Task Instance: </strong> | ||
{taskInstance.task_display_name}{" "} | ||
<Time datetime={taskInstance.start_date} /> | ||
</Heading> | ||
<Status state={taskInstance.state ?? undefined}> | ||
{taskInstance.state} | ||
</Status> | ||
<Flex> | ||
<div /> | ||
</Flex> | ||
</HStack> | ||
</Flex> | ||
{taskInstance.note === null || | ||
taskInstance.note.length === 0 ? undefined : ( | ||
<Flex alignItems="flex-start" justifyContent="space-between" mr={16}> | ||
<MdOutlineModeComment size="3rem" /> | ||
<Text fontSize="sm" ml={3}> | ||
{taskInstance.note} | ||
</Text> | ||
</Flex> | ||
)} | ||
<SimpleGrid columns={4} gap={4} my={2}> | ||
<Stat label="Operator">{taskInstance.operator}</Stat> | ||
{taskInstance.map_index > -1 ? ( | ||
<Stat label="Map Index">{taskInstance.map_index}</Stat> | ||
) : undefined} | ||
{taskInstance.try_number > 1 ? ( | ||
<Stat label="Try Number">{taskInstance.try_number}</Stat> | ||
) : undefined} | ||
<Stat label="Start"> | ||
<Time datetime={taskInstance.start_date} /> | ||
</Stat> | ||
<Stat label="End"> | ||
<Time datetime={taskInstance.end_date} /> | ||
</Stat> | ||
<Stat label="Duration"> | ||
{dayjs | ||
.duration( | ||
dayjs(taskInstance.end_date).diff(taskInstance.start_date), | ||
) | ||
.asSeconds() | ||
.toFixed(2)} | ||
s | ||
</Stat> | ||
</SimpleGrid> | ||
</Box> | ||
</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,72 @@ | ||
/*! | ||
* 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 { Button } from "@chakra-ui/react"; | ||
import { useSearchParams } from "react-router-dom"; | ||
|
||
import type { DAGResponse } from "openapi/requests/types.gen"; | ||
import { DagIcon } from "src/assets/DagIcon"; | ||
import { DagVizModal } from "src/components/DagVizModal"; | ||
import { NavTabs } from "src/components/NavTabs"; | ||
|
||
const tabs = [ | ||
{ label: "Logs", value: "" }, | ||
{ label: "Events", value: "events" }, | ||
{ label: "XCom", value: "xcom" }, | ||
{ label: "Code", value: "code" }, | ||
{ label: "Details", value: "details" }, | ||
]; | ||
|
||
const MODAL = "modal"; | ||
|
||
export const TaskInstanceTabs = ({ dag }: { readonly dag?: DAGResponse }) => { | ||
const [searchParams, setSearchParams] = useSearchParams(); | ||
|
||
const modal = searchParams.get(MODAL); | ||
|
||
const isGraphOpen = modal === "graph"; | ||
const onClose = () => { | ||
searchParams.delete(MODAL); | ||
setSearchParams(searchParams); | ||
}; | ||
|
||
const onOpen = () => { | ||
searchParams.set(MODAL, "graph"); | ||
setSearchParams(searchParams); | ||
}; | ||
|
||
return ( | ||
<> | ||
<NavTabs | ||
rightButtons={ | ||
<Button colorPalette="blue" onClick={onOpen} variant="ghost"> | ||
<DagIcon height={5} width={5} /> | ||
Graph | ||
</Button> | ||
} | ||
tabs={tabs} | ||
/> | ||
<DagVizModal | ||
dagDisplayName={dag?.dag_display_name} | ||
dagId={dag?.dag_id} | ||
onClose={onClose} | ||
open={isGraphOpen} | ||
/> | ||
</> | ||
); | ||
}; |
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