From b194addd7613d9979a815f00d27cc565487ed48a Mon Sep 17 00:00:00 2001 From: Nikhil-Doye Date: Thu, 23 Oct 2025 15:26:23 -0400 Subject: [PATCH] Refactor WorkflowEditor and connection suggestion logic; add SlackNode export - Removed unused connection handling functions from WorkflowEditor to streamline the component. - Updated connectionSuggestions to improve cycle detection with a new hasCycleWithEdges function. - Exported SlackNode from the nodes index for enhanced integration with Slack operations. --- c --noEmit | 5 +++ src/components/WorkflowEditor.tsx | 22 ------------- src/components/nodes/index.ts | 2 ++ src/services/processors/ProcessorRegistry.ts | 1 - src/utils/connectionSuggestions.ts | 33 +++++++++++++++++--- 5 files changed, 35 insertions(+), 28 deletions(-) create mode 100644 c --noEmit diff --git a/c --noEmit b/c --noEmit new file mode 100644 index 0000000..a7bfeb0 --- /dev/null +++ b/c --noEmit @@ -0,0 +1,5 @@ +5ca121b (HEAD -> main, origin/main) Add SlackWizard component for configuring Slack operations +4136930 Add SlackNode component for enhanced Slack operation visualization +578456b Add slackProcessor function for handling Slack operations +e518a70 Add SlackService class to handle various Slack operations +315e01c Add Slack integration support across components diff --git a/src/components/WorkflowEditor.tsx b/src/components/WorkflowEditor.tsx index 990ac7d..2a90ca1 100644 --- a/src/components/WorkflowEditor.tsx +++ b/src/components/WorkflowEditor.tsx @@ -143,28 +143,6 @@ export const WorkflowEditor: React.FC = ({ onClose }) => { [selectNode] ); - const handleConnectionStart = useCallback( - (event: React.MouseEvent | React.TouchEvent, params: any) => { - const node = nodes.find((n) => n.id === params.nodeId); - if (node) { - setConnectionSource(node as Node); - } - }, - [nodes] - ); - - const handleConnectionEnd = useCallback( - (event: React.MouseEvent | React.TouchEvent, params: any) => { - if (connectionSource && params.nodeId) { - const node = nodes.find((n) => n.id === params.nodeId); - if (node) { - setConnectionTarget(node as Node); - } - } - }, - [connectionSource, nodes] - ); - const handleSuggestionClick = useCallback( (suggestion: any) => { const sourceNode = nodes.find((n) => n.id === suggestion.sourceId); diff --git a/src/components/nodes/index.ts b/src/components/nodes/index.ts index c32c2c4..3b91a3c 100644 --- a/src/components/nodes/index.ts +++ b/src/components/nodes/index.ts @@ -8,3 +8,5 @@ export { DataInputNode } from "./DataInputNode"; export { DataOutputNode } from "./DataOutputNode"; // Unified database node export { UnifiedDatabaseNode } from "./UnifiedDatabaseNode"; +// Slack node +export { SlackNode } from "./SlackNode"; diff --git a/src/services/processors/ProcessorRegistry.ts b/src/services/processors/ProcessorRegistry.ts index 9bacf13..b425d3f 100644 --- a/src/services/processors/ProcessorRegistry.ts +++ b/src/services/processors/ProcessorRegistry.ts @@ -135,7 +135,6 @@ export class ProcessorRegistry { * Get suggestions for similar node types */ static getSimilarTypes(nodeType: string): string[] { - const supportedTypes = this.getSupportedTypes(); const similarTypes: string[] = []; // Simple similarity matching based on common patterns diff --git a/src/utils/connectionSuggestions.ts b/src/utils/connectionSuggestions.ts index cc2dfd0..cead513 100644 --- a/src/utils/connectionSuggestions.ts +++ b/src/utils/connectionSuggestions.ts @@ -148,9 +148,6 @@ export function generateConnectionSuggestions( // Find unconnected nodes and suggest connections const unconnectedNodes = nodes.filter((node) => !connectedNodes.has(node.id)); - const connectedNodesList = nodes.filter((node) => - connectedNodes.has(node.id) - ); // Suggest connections for unconnected nodes unconnectedNodes.forEach((node) => { @@ -339,8 +336,34 @@ function wouldCreateCircularDependency( { source: sourceId, target: targetId } as Edge, ]; - // Check for cycles starting from the target - return hasCycle(targetId); + // Check for cycles starting from the target using tempEdges + return hasCycleWithEdges(targetId, tempEdges); +} + +/** + * Check for cycles using specific edges + */ +function hasCycleWithEdges(nodeId: string, edges: Edge[]): boolean { + const visited = new Set(); + const recStack = new Set(); + + function hasCycle(nodeId: string): boolean { + if (recStack.has(nodeId)) return true; + if (visited.has(nodeId)) return false; + + visited.add(nodeId); + recStack.add(nodeId); + + const outgoingEdges = edges.filter((edge) => edge.source === nodeId); + for (const edge of outgoingEdges) { + if (hasCycle(edge.target)) return true; + } + + recStack.delete(nodeId); + return false; + } + + return hasCycle(nodeId); } /**