From a2c5a48434a95432ef369a1ffcd69a1dac435ed7 Mon Sep 17 00:00:00 2001
From: Linh <62679553+dauinh@users.noreply.github.com>
Date: Fri, 3 Jan 2025 12:00:53 -0600
Subject: [PATCH] Redo task instance details (#45382) (#45383)
* redo add task instance details (#45382)
* fix static checks
* fix type error for try instance pid
---
airflow/ui/src/pages/Run/Details.tsx | 193 +++++++++++++++++++++++++++
airflow/ui/src/router.tsx | 3 +-
2 files changed, 195 insertions(+), 1 deletion(-)
create mode 100644 airflow/ui/src/pages/Run/Details.tsx
diff --git a/airflow/ui/src/pages/Run/Details.tsx b/airflow/ui/src/pages/Run/Details.tsx
new file mode 100644
index 0000000000000..bb526041a26a4
--- /dev/null
+++ b/airflow/ui/src/pages/Run/Details.tsx
@@ -0,0 +1,193 @@
+/*!
+ * 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, HStack, Table } from "@chakra-ui/react";
+import { useParams, useSearchParams } from "react-router-dom";
+
+import {
+ useTaskInstanceServiceGetMappedTaskInstance,
+ useTaskInstanceServiceGetTaskInstanceTryDetails,
+} from "openapi/queries";
+import { TaskTrySelect } from "src/components/TaskTrySelect";
+import Time from "src/components/Time";
+import { ClipboardRoot, ClipboardIconButton, Status } from "src/components/ui";
+import { getDuration } from "src/utils";
+
+export const Details = () => {
+ const { dagId = "", runId = "", taskId = "" } = useParams();
+ const [searchParams, setSearchParams] = useSearchParams();
+
+ const mapIndexParam = searchParams.get("map_index");
+ const tryNumberParam = searchParams.get("try_number");
+ const mapIndex = parseInt(mapIndexParam ?? "-1", 10);
+
+ const { data: taskInstance } = useTaskInstanceServiceGetMappedTaskInstance({
+ dagId,
+ dagRunId: runId,
+ mapIndex,
+ taskId,
+ });
+
+ const onSelectTryNumber = (newTryNumber: number) => {
+ if (newTryNumber === taskInstance?.try_number) {
+ searchParams.delete("try_number");
+ } else {
+ searchParams.set("try_number", newTryNumber.toString());
+ }
+ setSearchParams(searchParams);
+ };
+
+ const tryNumber = tryNumberParam === null ? taskInstance?.try_number : parseInt(tryNumberParam, 10);
+
+ const { data: tryInstance } = useTaskInstanceServiceGetTaskInstanceTryDetails({
+ dagId,
+ dagRunId: runId,
+ mapIndex,
+ taskId,
+ taskTryNumber: tryNumber ?? 1,
+ });
+
+ return (
+ , path: "code" },
- { element: