diff --git a/frontend/src/components/workflow/ConnectionEdge.jsx b/frontend/src/components/workflow/ConnectionEdge.jsx new file mode 100644 index 00000000..d1c56596 --- /dev/null +++ b/frontend/src/components/workflow/ConnectionEdge.jsx @@ -0,0 +1,80 @@ +import React, { memo } from 'react'; +import { BaseEdge, EdgeLabelRenderer, getSmoothStepPath } from '@xyflow/react'; +import { X } from 'lucide-react'; +import { connectionLabels, connectionColors, getConnectionType } from '../../utils/connectionRules'; + +const ConnectionEdge = ({ + id, + sourceX, + sourceY, + targetX, + targetY, + sourcePosition, + targetPosition, + source, + target, + sourceHandleId, + selected, + data, + markerEnd +}) => { + const [edgePath, labelX, labelY] = getSmoothStepPath({ + sourceX, + sourceY, + sourcePosition, + targetX, + targetY, + targetPosition, + borderRadius: 8 + }); + + // Get connection type from data or derive from source/target + const connectionType = data?.connectionType || getConnectionType( + data?.sourceType || 'dockerApp', + data?.targetType || 'dockerApp' + ); + + const label = connectionLabels[connectionType] || 'Connected'; + const color = connectionColors[connectionType] || '#6366f1'; + + return ( + <> + + + + {label} + {selected && data?.onDelete && ( + { + e.stopPropagation(); + data.onDelete(id); + }} + > + + + )} + + + > + ); +}; + +export default memo(ConnectionEdge);