feat(FN-3082): restructure dependency graph plugin with modular architectur
Implements a modular dependency graph feature for the Fusion dashboard plugin, replacing the monolithic `DependencyGraphView` component with a factored architecture: graph types and filtering (Step 1), a data hook (Step 2), auto-layout engine (Step 3), SVG edge rendering (Step 4), an interaction hoo Fusion-Task-Id: FN-3082
This commit is contained in:
17
plugins/fusion-plugin-dependency-graph/src/useGraphData.ts
Normal file
17
plugins/fusion-plugin-dependency-graph/src/useGraphData.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useMemo } from "react";
|
||||
import type { Task } from "@fusion/core";
|
||||
import type { GraphData, GraphNode } from "./types";
|
||||
|
||||
export function useGraphData(tasks: Task[]): GraphData {
|
||||
return useMemo(() => {
|
||||
const nodes: GraphNode[] = tasks.map((task) => ({ task }));
|
||||
const taskIds = new Set(tasks.map((task) => task.id));
|
||||
const edges = tasks.flatMap((task) =>
|
||||
(task.dependencies ?? [])
|
||||
.filter((dependencyId) => taskIds.has(dependencyId))
|
||||
.map((dependencyId) => ({ source: task.id, target: dependencyId })),
|
||||
);
|
||||
|
||||
return { nodes, edges };
|
||||
}, [tasks]);
|
||||
}
|
||||
Reference in New Issue
Block a user