From 19b5a05af09a61cb3ac30c856dd064569569b900 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 2 Aug 2023 21:26:18 -0300 Subject: [PATCH] fix(reactflowUtils.ts): import Edge from reactflow to fix type error and improve code semantics feat(reactflowUtils.ts): add getConnectedNodes function to retrieve connected nodes based on an edge fix(styleUtils.ts): remove unused getConnectedNodes function --- src/frontend/src/utils/reactflowUtils.ts | 11 ++++++++++- src/frontend/src/utils/styleUtils.ts | 6 ------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index 063daee74..ff486ebb2 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -1,5 +1,5 @@ import _ from "lodash"; -import { Connection, ReactFlowInstance } from "reactflow"; +import { Connection, Edge, ReactFlowInstance } from "reactflow"; import { APITemplateType } from "../types/api"; import { FlowType, NodeType } from "../types/flow"; import { cleanEdgesType } from "../types/utils/reactflowUtils"; @@ -232,3 +232,12 @@ export function addVersionToDuplicates(flow: FlowType, flows: FlowType[]) { return newName; } + +export function getConnectedNodes( + edge: Edge, + nodes: Array +): Array { + const sourceId = edge.source; + const targetId = edge.target; + return nodes.filter((node) => node.id === targetId || node.id === sourceId); +} diff --git a/src/frontend/src/utils/styleUtils.ts b/src/frontend/src/utils/styleUtils.ts index dd34b5001..42fbe8773 100644 --- a/src/frontend/src/utils/styleUtils.ts +++ b/src/frontend/src/utils/styleUtils.ts @@ -65,7 +65,6 @@ import { XCircle, Zap, } from "lucide-react"; -import { Edge, Node } from "reactflow"; import { AirbyteIcon } from "../icons/Airbyte"; import { AnthropicIcon } from "../icons/Anthropic"; import { BingIcon } from "../icons/Bing"; @@ -277,8 +276,3 @@ export const nodeIconsLucide = { MessageSquare, MoreHorizontal, }; -export function getConnectedNodes(edge: Edge, nodes: Array): Array { - const sourceId = edge.source; - const targetId = edge.target; - return nodes.filter((node) => node.id === targetId || node.id === sourceId); -}