Skip to content

Commit 1814487

Browse files
feat: add refresh button to dag (#600)
1 parent 43e5e94 commit 1814487

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

src/app/runs/[id]/Dag.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ export function DAG() {
4949
fitView(); // Keep an eye on performance here
5050
}, [width, height]);
5151

52+
useEffect(() => {
53+
const timeout = setTimeout(() => {
54+
fitView({ duration: 200 });
55+
}, 100);
56+
return () => {
57+
clearTimeout(timeout);
58+
};
59+
}, [data]);
60+
5261
useLayoutEffect(() => {
5362
onDagreLayout();
5463
}, [data?.nodes, data?.edges, onDagreLayout]);
@@ -82,7 +91,7 @@ export function DAG() {
8291
onEdgesChange={onEdgesChange}
8392
fitView
8493
>
85-
<DagControls />
94+
<DagControls runId={runId} />
8695
</ReactFlow>
8796
);
8897
}

src/components/dag-visualizer/Controls.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@ import { Button } from "@zenml-io/react-component-library/components";
22
import Plus from "@/assets/icons/plus.svg?react";
33
import Minus from "@/assets/icons/minus.svg?react";
44
import Maximize from "@/assets/icons/maximize.svg?react";
5+
import Refresh from "@/assets/icons/refresh.svg?react";
56
import { useReactFlow } from "reactflow";
7+
import { usePipelineRun } from "../../data/pipeline-runs/pipeline-run-detail-query";
8+
import { usePipelineRunGraph } from "../../data/pipeline-runs/pipeline-run-graph-query";
69

7-
export function DagControls() {
10+
type Props = {
11+
runId: string;
12+
};
13+
14+
export function DagControls({ runId }: Props) {
815
const { fitView, zoomIn, zoomOut } = useReactFlow();
916

17+
const run = usePipelineRun({ runId });
18+
const graph = usePipelineRunGraph({ runId });
19+
1020
return (
1121
<div aria-label="Dag Controls" className="absolute left-4 top-4 z-10 flex flex-col gap-1">
1222
<div className="divide-y divide-neutral-300 overflow-hidden rounded-md border border-neutral-300">
@@ -39,6 +49,18 @@ export function DagControls() {
3949
>
4050
<Maximize className="h-5 w-5 fill-theme-text-primary" />
4151
</Button>
52+
<Button
53+
className="h-6 w-6 bg-theme-surface-primary p-0.5"
54+
onClick={() => {
55+
run.refetch();
56+
graph.refetch();
57+
}}
58+
emphasis="subtle"
59+
intent="secondary"
60+
>
61+
<span className="sr-only">Refresh</span>
62+
<Refresh className="h-5 w-5 fill-theme-text-primary" />
63+
</Button>
4264
</div>
4365
);
4466
}

0 commit comments

Comments
 (0)