From 2811664a51819ee3365a63d35a5338ad33a22ab5 Mon Sep 17 00:00:00 2001 From: Devika Date: Fri, 23 May 2025 16:31:06 +0530 Subject: [PATCH] Added Edit Process Functionality --- src/components/DataflowCanvas.jsx | 54 ++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/src/components/DataflowCanvas.jsx b/src/components/DataflowCanvas.jsx index 1eaaaa4..92c3ade 100644 --- a/src/components/DataflowCanvas.jsx +++ b/src/components/DataflowCanvas.jsx @@ -310,7 +310,18 @@ const CustomEdge = ({ id, source, target, sourceX, sourceY, targetX, targetY, so }; // Process Node (represents ETL or data transformation) -const ProcessNode = ({ data }) => { +const ProcessNode = ({ data, id }) => { + // Function to handle process edit + const handleProcessEdit = () => { + // Find the process in the mock data + const process = mockApiData.processes.find(p => p.slug === id); + if (process) { + // We'll use window.processEditCallback which will be set in the main component + if (window.processEditCallback) { + window.processEditCallback(process); + } + } + }; // Determine status color const statusColor = data.status === 'active' ? '#52c41a' : '#ff4d4f'; const isActive = data.status === 'active'; @@ -393,15 +404,20 @@ const ProcessNode = ({ data }) => { /> {/* Process Icon with integrated content */} -
+
{getProcessIcon()} {/* Status indicator (small dot) */} @@ -633,6 +649,20 @@ const DataflowCanvas = () => { const [showProcessForm, setShowProcessForm] = useState(false); const [selectedProcessForEdit, setSelectedProcessForEdit] = useState(null); + // Set up a global callback for process editing + // This is used by the ProcessNode component + useEffect(() => { + window.processEditCallback = (process) => { + setSelectedProcessForEdit(process); + setShowProcessForm(true); + }; + + return () => { + // Clean up when component unmounts + window.processEditCallback = null; + }; + }, []); + // Define node types const nodeTypes = useMemo(() => ({ table: TableNode, @@ -1717,7 +1747,7 @@ const DataflowCanvas = () => { alignItems: 'center', gap: '5px' }}> - Source Tables + Source Tables
    { alignItems: 'center', gap: '5px' }}> - Destination Tables + Destination Tables