mirror of
https://github.com/Nikhil-Doye/workflow-builder.git
synced 2026-07-22 02:01:56 +02:00
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:
@@ -0,0 +1,5 @@
|
||||
[33m5ca121b[m[33m ([m[1;36mHEAD -> [m[1;32mmain[m[33m, [m[1;31morigin/main[m[33m)[m Add SlackWizard component for configuring Slack operations
|
||||
[33m4136930[m Add SlackNode component for enhanced Slack operation visualization
|
||||
[33m578456b[m Add slackProcessor function for handling Slack operations
|
||||
[33me518a70[m Add SlackService class to handle various Slack operations
|
||||
[33m315e01c[m Add Slack integration support across components
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user