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.
This commit is contained in:
Nikhil-Doye
2025-10-23 15:26:23 -04:00
parent 62d0398a50
commit b194addd76
5 changed files with 35 additions and 28 deletions
+5
View File
@@ -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
-22
View File
@@ -143,28 +143,6 @@ export const WorkflowEditor: React.FC<WorkflowEditorProps> = ({ 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<NodeData>);
}
},
[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<NodeData>);
}
}
},
[connectionSource, nodes]
);
const handleSuggestionClick = useCallback(
(suggestion: any) => {
const sourceNode = nodes.find((n) => n.id === suggestion.sourceId);
+2
View File
@@ -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";
@@ -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
+28 -5
View File
@@ -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<string>();
const recStack = new Set<string>();
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);
}
/**