Skip to content

Commit

Permalink
Add basic autorefresh to grid and graph (apache#46330)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbovenzi authored Jan 31, 2025
1 parent 41aae33 commit 9ec0076
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions airflow/ui/src/layouts/Details/Graph/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { useParams } from "react-router-dom";
import { useGridServiceGridData, useStructureServiceStructureData } from "openapi/queries";
import { useColorMode } from "src/context/colorMode";
import { useOpenGroups } from "src/context/openGroups";
import { isStatePending, useAutoRefresh } from "src/utils";

import Edge from "./Edge";
import { JoinNode } from "./JoinNode";
Expand Down Expand Up @@ -87,6 +88,8 @@ export const Graph = () => {
openGroupIds,
});

const refetchInterval = useAutoRefresh({ dagId });

const { data: gridData } = useGridServiceGridData(
{
dagId,
Expand All @@ -97,6 +100,8 @@ export const Graph = () => {
undefined,
{
enabled: Boolean(runId),
refetchInterval: (query) =>
query.state.data?.dag_runs.some((dr) => isStatePending(dr.state)) && refetchInterval,
},
);

Expand Down
4 changes: 4 additions & 0 deletions airflow/ui/src/layouts/Details/Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { useParams, useSearchParams } from "react-router-dom";
import { useGridServiceGridData, useStructureServiceStructureData } from "openapi/queries";
import type { GridResponse } from "openapi/requests/types.gen";
import { useOpenGroups } from "src/context/openGroups";
import { isStatePending, useAutoRefresh } from "src/utils";

import { Bar } from "./Bar";
import { DurationAxis } from "./DurationAxis";
Expand All @@ -47,6 +48,7 @@ export const Grid = () => {
});

const [searchParams, setSearchParams] = useSearchParams();
const refetchInterval = useAutoRefresh({ dagId });

const offset = parseInt(searchParams.get("offset") ?? "0", 10);

Expand All @@ -62,6 +64,8 @@ export const Grid = () => {
undefined,
{
placeholderData: keepPreviousData,
refetchInterval: (query) =>
query.state.data?.dag_runs.some((dr) => isStatePending(dr.state)) && refetchInterval,
},
);

Expand Down

0 comments on commit 9ec0076

Please sign in to comment.