Skip to content

Commit 4a5e7ff

Browse files
authored
refactoring - extract generateTaskSpec (#1074)
## Description Moved the `generateTaskSpec` function from `GhostNode.tsx` to a dedicated utility file at `src/utils/nodes/generateTaskSpec.ts` to improve code organization and reusability. This function creates a TaskSpec object with default position annotations from a ComponentReference. ## Related Issue and Pull requests ## Type of Change - [ ] Bug fix - [ ] New feature - [ ] Improvement - [x] Cleanup/Refactor - [ ] Breaking change - [ ] Documentation update ## Checklist - [x] I have tested this does not break current pipelines / runs functionality - [ ] I have tested the changes on staging ## Test Instructions Verify that ghost nodes still render correctly in the flow canvas and that task specs are properly generated when creating new nodes.
1 parent cbca62b commit 4a5e7ff

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/components/shared/ReactFlow/FlowCanvas/GhostNode/GhostNode.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { memo, useMemo } from "react";
44
import { cn } from "@/lib/utils";
55
import { TaskNodeProvider } from "@/providers/TaskNodeProvider";
66
import type { TaskNodeData } from "@/types/taskNode";
7-
import type { ComponentReference, TaskSpec } from "@/utils/componentSpec";
7+
import type { ComponentReference } from "@/utils/componentSpec";
8+
import { generateTaskSpec } from "@/utils/nodes/generateTaskSpec";
89

910
import { TaskNodeCard } from "../TaskNode/TaskNodeCard";
1011

@@ -60,16 +61,6 @@ GhostNode.displayName = "GhostNode";
6061

6162
export default GhostNode;
6263

63-
const generateTaskSpec = (componentRef: ComponentReference): TaskSpec => {
64-
return {
65-
componentRef,
66-
annotations: {
67-
"editor.position.x": "0",
68-
"editor.position.y": "0",
69-
} as { [k: string]: unknown },
70-
};
71-
};
72-
7364
const generateGhostTaskNodeData = (
7465
componentRef: ComponentReference,
7566
taskId?: string,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { ComponentReference, TaskSpec } from "../componentSpec";
2+
3+
export const generateTaskSpec = (
4+
componentRef: ComponentReference,
5+
): TaskSpec => {
6+
return {
7+
componentRef,
8+
annotations: {
9+
"editor.position.x": "0",
10+
"editor.position.y": "0",
11+
} as { [k: string]: unknown },
12+
};
13+
};

0 commit comments

Comments
 (0)