Skip to content

Commit c53b53a

Browse files
Move asset events to its own tab (#51625) (#51655)
* Move asset events to its own tab * Address PR comments (cherry picked from commit e8505aa)
1 parent 8e16705 commit c53b53a

File tree

8 files changed

+108
-33
lines changed

8 files changed

+108
-33
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*!
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
import { useParams } from "react-router-dom";
20+
21+
import { useDagRunServiceGetDagRun, useDagRunServiceGetUpstreamAssetEvents } from "openapi/queries";
22+
import { AssetEvents as AssetEventsTable } from "src/components/Assets/AssetEvents";
23+
import { isStatePending, useAutoRefresh } from "src/utils";
24+
25+
export const AssetEvents = () => {
26+
const { dagId = "", runId = "" } = useParams();
27+
28+
const refetchInterval = useAutoRefresh({ dagId });
29+
30+
const { data: dagRun } = useDagRunServiceGetDagRun(
31+
{
32+
dagId,
33+
dagRunId: runId,
34+
},
35+
undefined,
36+
{ refetchInterval: (query) => (isStatePending(query.state.data?.state) ? refetchInterval : false) },
37+
);
38+
39+
const { data, isLoading } = useDagRunServiceGetUpstreamAssetEvents({ dagId, dagRunId: runId }, undefined, {
40+
enabled: dagRun?.run_type === "asset_triggered",
41+
refetchInterval: () => (isStatePending(dagRun?.state) ? refetchInterval : false),
42+
});
43+
44+
return <AssetEventsTable data={data} isLoading={isLoading} title="Source Asset Event" />;
45+
};

airflow-core/src/airflow/ui/src/pages/Run/Details.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
import { Box, Flex, HStack, StackSeparator, Table, Text, VStack } from "@chakra-ui/react";
2020
import { useParams } from "react-router-dom";
2121

22-
import { useDagRunServiceGetDagRun, useDagRunServiceGetUpstreamAssetEvents } from "openapi/queries";
23-
import { AssetEvents } from "src/components/Assets/AssetEvents";
22+
import { useDagRunServiceGetDagRun } from "openapi/queries";
2423
import { DagVersionDetails } from "src/components/DagVersionDetails";
2524
import RenderedJsonField from "src/components/RenderedJsonField";
2625
import { RunTypeIcon } from "src/components/RunTypeIcon";
@@ -43,17 +42,9 @@ export const Details = () => {
4342
{ refetchInterval: (query) => (isStatePending(query.state.data?.state) ? refetchInterval : false) },
4443
);
4544

46-
const { data, isLoading } = useDagRunServiceGetUpstreamAssetEvents({ dagId, dagRunId: runId }, undefined, {
47-
enabled: dagRun?.run_type === "asset_triggered",
48-
refetchInterval: () => (isStatePending(dagRun?.state) ? refetchInterval : false),
49-
});
50-
5145
// TODO : Render DagRun configuration object
5246
return (
5347
<Box p={2}>
54-
{data === undefined || dagRun?.run_type !== "asset_triggered" ? undefined : (
55-
<AssetEvents data={data} isLoading={isLoading} title="Source Asset Event" />
56-
)}
5748
{dagRun === undefined ? (
5849
<div />
5950
) : (

airflow-core/src/airflow/ui/src/pages/Run/Run.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919
import { ReactFlowProvider } from "@xyflow/react";
20-
import { FiCode } from "react-icons/fi";
20+
import { FiCode, FiDatabase } from "react-icons/fi";
2121
import { MdDetails, MdOutlineEventNote, MdOutlineTask } from "react-icons/md";
2222
import { useParams } from "react-router-dom";
2323

@@ -29,9 +29,10 @@ import { Header } from "./Header";
2929

3030
const tabs = [
3131
{ icon: <MdOutlineTask />, label: "Task Instances", value: "" },
32-
{ icon: <MdOutlineEventNote />, label: "Events", value: "events" },
32+
{ icon: <MdOutlineEventNote />, label: "Audit Logs", value: "events" },
3333
{ icon: <FiCode />, label: "Code", value: "code" },
3434
{ icon: <MdDetails />, label: "Details", value: "details" },
35+
{ icon: <FiDatabase />, label: "Asset Events", value: "asset_events" },
3536
];
3637

3738
export const Run = () => {

airflow-core/src/airflow/ui/src/pages/Task/Task.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { Header } from "./Header";
2929
const tabs = [
3030
{ icon: <LuChartColumn />, label: "Overview", value: "" },
3131
{ icon: <MdOutlineTask />, label: "Task Instances", value: "task_instances" },
32-
{ icon: <MdOutlineEventNote />, label: "Events", value: "events" },
32+
{ icon: <MdOutlineEventNote />, label: "Audit Logs", value: "events" },
3333
];
3434

3535
export const Task = () => {
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*!
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
import { useParams } from "react-router-dom";
20+
21+
import { useAssetServiceGetAssetEvents, useTaskInstanceServiceGetMappedTaskInstance } from "openapi/queries";
22+
import { AssetEvents as AssetEventsTable } from "src/components/Assets/AssetEvents";
23+
import { isStatePending, useAutoRefresh } from "src/utils";
24+
25+
export const AssetEvents = () => {
26+
const { dagId = "", mapIndex = "-1", runId = "", taskId = "" } = useParams();
27+
28+
const { data: taskInstance } = useTaskInstanceServiceGetMappedTaskInstance({
29+
dagId,
30+
dagRunId: runId,
31+
mapIndex: parseInt(mapIndex, 10),
32+
taskId,
33+
});
34+
35+
const refetchInterval = useAutoRefresh({ dagId });
36+
37+
const { data: assetEventsData, isLoading } = useAssetServiceGetAssetEvents(
38+
{
39+
sourceDagId: dagId,
40+
sourceMapIndex: parseInt(mapIndex, 10),
41+
sourceRunId: runId,
42+
sourceTaskId: taskId,
43+
},
44+
undefined,
45+
{
46+
refetchInterval: () => (isStatePending(taskInstance?.state) ? refetchInterval : false),
47+
},
48+
);
49+
50+
return <AssetEventsTable data={assetEventsData} isLoading={isLoading} title="Created Asset Event" />;
51+
};

airflow-core/src/airflow/ui/src/pages/TaskInstance/Details.tsx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ import { Box, Flex, HStack, Table, Heading } from "@chakra-ui/react";
2020
import { useParams, useSearchParams } from "react-router-dom";
2121

2222
import {
23-
useAssetServiceGetAssetEvents,
2423
useTaskInstanceServiceGetMappedTaskInstance,
2524
useTaskInstanceServiceGetTaskInstanceTryDetails,
2625
} from "openapi/queries";
27-
import { AssetEvents } from "src/components/Assets/AssetEvents";
2826
import { DagVersionDetails } from "src/components/DagVersionDetails";
2927
import { StateBadge } from "src/components/StateBadge";
3028
import { TaskTrySelect } from "src/components/TaskTrySelect";
@@ -76,24 +74,8 @@ export const Details = () => {
7674
},
7775
);
7876

79-
const { data: assetEventsData, isLoading: isLoadingAssetEvents } = useAssetServiceGetAssetEvents(
80-
{
81-
sourceDagId: dagId,
82-
sourceMapIndex: parseInt(mapIndex, 10),
83-
sourceRunId: runId,
84-
sourceTaskId: taskId,
85-
},
86-
undefined,
87-
{
88-
refetchInterval: () => (isStatePending(taskInstance?.state) ? refetchInterval : false),
89-
},
90-
);
91-
9277
return (
9378
<Box p={2}>
94-
{assetEventsData !== undefined && assetEventsData.asset_events.length > 0 ? (
95-
<AssetEvents data={assetEventsData} isLoading={isLoadingAssetEvents} title="Created Asset Event" />
96-
) : undefined}
9779
{taskInstance === undefined || tryNumber === undefined || taskInstance.try_number <= 1 ? (
9880
<div />
9981
) : (

airflow-core/src/airflow/ui/src/pages/TaskInstance/TaskInstance.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919
import { ReactFlowProvider } from "@xyflow/react";
20-
import { FiCode } from "react-icons/fi";
20+
import { FiCode, FiDatabase } from "react-icons/fi";
2121
import { MdDetails, MdOutlineEventNote, MdOutlineTask, MdReorder, MdSyncAlt } from "react-icons/md";
2222
import { PiBracketsCurlyBold } from "react-icons/pi";
2323
import { useParams } from "react-router-dom";
@@ -36,9 +36,10 @@ const tabs = [
3636
{ icon: <MdReorder />, label: "Logs", value: "" },
3737
{ icon: <PiBracketsCurlyBold />, label: "Rendered Templates", value: "rendered_templates" },
3838
{ icon: <MdSyncAlt />, label: "XCom", value: "xcom" },
39-
{ icon: <MdOutlineEventNote />, label: "Events", value: "events" },
39+
{ icon: <MdOutlineEventNote />, label: "Audit Logs", value: "events" },
4040
{ icon: <FiCode />, label: "Code", value: "code" },
4141
{ icon: <MdDetails />, label: "Details", value: "details" },
42+
{ icon: <FiDatabase />, label: "Asset Events", value: "asset_events" },
4243
];
4344

4445
export const TaskInstance = () => {

airflow-core/src/airflow/ui/src/router.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ import { Variables } from "src/pages/Variables";
5353
import { XCom } from "src/pages/XCom";
5454

5555
import { Configs } from "./pages/Configs";
56+
import { AssetEvents as DagRunAssetEvents } from "./pages/Run/AssetEvents";
5657
import { Security } from "./pages/Security";
58+
import { AssetEvents as TaskInstanceAssetEvents } from "./pages/TaskInstance/AssetEvents";
5759
import { client } from "./queryClient";
5860

5961
const taskInstanceRoutes = [
@@ -64,6 +66,7 @@ const taskInstanceRoutes = [
6466
{ element: <TaskInstanceDetails />, path: "details" },
6567
{ element: <RenderedTemplates />, path: "rendered_templates" },
6668
{ element: <TaskInstances />, path: "task_instances" },
69+
{ element: <TaskInstanceAssetEvents />, path: "asset_events" },
6770
];
6871

6972
export const routerConfig = [
@@ -156,6 +159,7 @@ export const routerConfig = [
156159
{ element: <Events />, path: "events" },
157160
{ element: <Code />, path: "code" },
158161
{ element: <DagRunDetails />, path: "details" },
162+
{ element: <DagRunAssetEvents />, path: "asset_events" },
159163
],
160164
element: <Run />,
161165
path: "dags/:dagId/runs/:runId",

0 commit comments

Comments
 (0)