-
Notifications
You must be signed in to change notification settings - Fork 17.2k
UI: Add Details tab to the mapped task instance view #68340
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
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 |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| /*! | ||
| * 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, Table } from "@chakra-ui/react"; | ||
| import { useTranslation } from "react-i18next"; | ||
| import { useOutletContext, useParams } from "react-router-dom"; | ||
|
|
||
| import { useTaskServiceGetTask } from "openapi/queries"; | ||
| import type { LightGridTaskInstanceSummary } from "openapi/requests/types.gen"; | ||
| import { StateBadge } from "src/components/StateBadge"; | ||
| import Time from "src/components/Time"; | ||
| import { getDuration } from "src/utils"; | ||
|
|
||
| export const Details = () => { | ||
| const { dagId = "", taskId = "" } = useParams(); | ||
| const { t: translate } = useTranslation("common"); | ||
|
|
||
| // The aggregate summary (per-state counts, dates) is streamed once by the parent page and | ||
| // shared through the router outlet, so this tab does not re-open the TI summaries stream. | ||
| const taskInstance = useOutletContext<LightGridTaskInstanceSummary | undefined>(); | ||
|
|
||
| const { data: task } = useTaskServiceGetTask({ dagId, taskId }, undefined, { enabled: Boolean(taskId) }); | ||
|
|
||
| const childStates = Object.entries(taskInstance?.child_states ?? {}); | ||
|
|
||
| return ( | ||
| <Box p={2}> | ||
| <Table.Root striped> | ||
| <Table.Body> | ||
| <Table.Row> | ||
| <Table.Cell>{translate("overallStatus")}</Table.Cell> | ||
| <Table.Cell> | ||
| <Flex alignItems="center" gap={1}> | ||
| <StateBadge state={taskInstance?.state} /> | ||
| {taskInstance?.state ?? translate("states.no_status")} | ||
| </Flex> | ||
| </Table.Cell> | ||
| </Table.Row> | ||
| {childStates.map(([state, count]) => ( | ||
| <Table.Row key={state}> | ||
| <Table.Cell>{translate("total", { state: translate(`states.${state}`) })}</Table.Cell> | ||
| <Table.Cell> | ||
| <Flex alignItems="center" gap={2}> | ||
| <Box | ||
| bg={`${state}.solid`} | ||
| border="1px solid" | ||
| borderColor="border.emphasized" | ||
| borderRadius="2px" | ||
| height="10px" | ||
| width="10px" | ||
| /> | ||
| {count} | ||
| </Flex> | ||
| </Table.Cell> | ||
| </Table.Row> | ||
| ))} | ||
| <Table.Row> | ||
| <Table.Cell>{translate("taskId")}</Table.Cell> | ||
| <Table.Cell>{taskId}</Table.Cell> | ||
| </Table.Row> | ||
| <Table.Row> | ||
| <Table.Cell>{translate("task.operator")}</Table.Cell> | ||
| <Table.Cell>{task?.operator_name}</Table.Cell> | ||
| </Table.Row> | ||
| <Table.Row> | ||
| <Table.Cell>{translate("task.triggerRule")}</Table.Cell> | ||
| <Table.Cell>{task?.trigger_rule}</Table.Cell> | ||
| </Table.Row> | ||
| <Table.Row> | ||
| <Table.Cell>{translate("dagDetails.owner")}</Table.Cell> | ||
| <Table.Cell>{task?.owner}</Table.Cell> | ||
| </Table.Row> | ||
| <Table.Row> | ||
| <Table.Cell>{translate("task.retries")}</Table.Cell> | ||
| <Table.Cell>{task?.retries}</Table.Cell> | ||
| </Table.Row> | ||
| <Table.Row> | ||
| <Table.Cell>{translate("taskInstance.pool")}</Table.Cell> | ||
| <Table.Cell>{task?.pool}</Table.Cell> | ||
| </Table.Row> | ||
| <Table.Row> | ||
| <Table.Cell>{translate("taskInstance.poolSlots")}</Table.Cell> | ||
| <Table.Cell>{task?.pool_slots}</Table.Cell> | ||
| </Table.Row> | ||
| <Table.Row> | ||
| <Table.Cell>{translate("taskInstance.queue")}</Table.Cell> | ||
| <Table.Cell>{task?.queue}</Table.Cell> | ||
| </Table.Row> | ||
| <Table.Row> | ||
| <Table.Cell>{translate("taskInstance.priorityWeight")}</Table.Cell> | ||
| <Table.Cell>{task?.priority_weight}</Table.Cell> | ||
| </Table.Row> | ||
| <Table.Row> | ||
| <Table.Cell>{translate("task.dependsOnPast")}</Table.Cell> | ||
| <Table.Cell>{task === undefined ? undefined : String(task.depends_on_past)}</Table.Cell> | ||
| </Table.Row> | ||
| <Table.Row> | ||
| <Table.Cell>{translate("task.waitForDownstream")}</Table.Cell> | ||
| <Table.Cell>{task === undefined ? undefined : String(task.wait_for_downstream)}</Table.Cell> | ||
| </Table.Row> | ||
| <Table.Row> | ||
| <Table.Cell>{translate("startDate")}</Table.Cell> | ||
| <Table.Cell> | ||
| <Time datetime={taskInstance?.min_start_date} /> | ||
| </Table.Cell> | ||
| </Table.Row> | ||
| <Table.Row> | ||
| <Table.Cell>{translate("endDate")}</Table.Cell> | ||
| <Table.Cell> | ||
| <Time datetime={taskInstance?.max_end_date} /> | ||
| </Table.Cell> | ||
| </Table.Row> | ||
| <Table.Row> | ||
| <Table.Cell>{translate("duration")}</Table.Cell> | ||
| <Table.Cell>{getDuration(taskInstance?.min_start_date, taskInstance?.max_end_date)}</Table.Cell> | ||
| </Table.Row> | ||
| <Table.Row> | ||
| <Table.Cell>{translate("taskInstance.dagVersion")}</Table.Cell> | ||
| <Table.Cell>{taskInstance?.dag_version_number}</Table.Cell> | ||
| </Table.Row> | ||
| </Table.Body> | ||
| </Table.Root> | ||
| </Box> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ | |
| */ | ||
| import { ReactFlowProvider } from "@xyflow/react"; | ||
| import { useTranslation } from "react-i18next"; | ||
| import { MdOutlineTask } from "react-icons/md"; | ||
| import { MdDetails, MdOutlineTask } from "react-icons/md"; | ||
| import { useParams } from "react-router-dom"; | ||
|
|
||
| import { DetailsLayout } from "src/layouts/Details/DetailsLayout"; | ||
|
|
@@ -41,11 +41,12 @@ export const MappedTaskInstance = () => { | |
|
|
||
| const tabs = [ | ||
| { icon: <MdOutlineTask />, label: `${translate("tabs.taskInstances")} [${taskCount}]`, value: "" }, | ||
| { icon: <MdDetails />, label: translate("tabs.details"), value: "details" }, | ||
| ]; | ||
|
|
||
| return ( | ||
| <ReactFlowProvider> | ||
| <DetailsLayout tabs={tabs}> | ||
| <DetailsLayout outletContext={taskInstance} tabs={tabs}> | ||
|
Contributor
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. What does this context actually do? We're only using it here and I don't get what its helping us with?
Member
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. This is to re-use the Grid summary. Otherwise the detail tab will have to This allow to share the stream from the grid view with the details view, via a context. Preventing a second call to |
||
| {taskInstance === undefined ? undefined : <Header taskInstance={taskInstance} />} | ||
| </DetailsLayout> | ||
| </ReactFlowProvider> | ||
|
|
||
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.
Do we want to use this hook anywhere else?
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.
No, we are only consuming the parent context once, here. (retrieving the TIsummaries provided by the parent page to avoid opening a second stream for that)