diff --git a/frontend/src/components/reactflow/overlayui/ContextMenu.tsx b/frontend/src/components/reactflow/overlayui/ContextMenu.tsx index 731eb62..71c72a2 100644 --- a/frontend/src/components/reactflow/overlayui/ContextMenu.tsx +++ b/frontend/src/components/reactflow/overlayui/ContextMenu.tsx @@ -84,11 +84,17 @@ export default function ContextMenu({ onClick(); // close the context menu setDisableDelete(true); // Check if the device has any edges - const edgesForDevice = edges.filter(e => e.source === node?.data.deviceData?.name || e.target === node?.data.deviceData?.name); - console.log(edgesForDevice); + const edgesForDevice = edges.filter(e => e.source === node?.data.deviceData?.name || e.target === node?.data.deviceData?.name).map(e => ({ + value: e.id, + label: `(${e.source}) ${e.data?.sourcePort ?? ''} -> (${e.target}) ${e.data?.targetPort ?? ''}`, + firstLabDevice: e.source, + firstLabDevicePort: e.data?.sourcePort ?? '', + secondLabDevice: e.target, + secondLabDevicePort: e.data?.targetPort ?? '', + })); if (edgesForDevice.length > 0) { // attempt to delete all links - const numFailures = await deleteLinkBulk(new Set(currentEdges)); + const numFailures = await deleteLinkBulk(new Set(edgesForDevice)); // only remove the node if all links were successfully deleted if (numFailures === 0) { diff --git a/frontend/src/components/reactflow/overlayui/CreateLinkModal.tsx b/frontend/src/components/reactflow/overlayui/CreateLinkModal.tsx index 7de1fbe..d77faf1 100644 --- a/frontend/src/components/reactflow/overlayui/CreateLinkModal.tsx +++ b/frontend/src/components/reactflow/overlayui/CreateLinkModal.tsx @@ -109,11 +109,16 @@ export default function CreateLinkModal({ deviceData, currentDevicePorts, labDev disabled={!!deviceData?.name} > - {labDevices.filter((device) => device.userId == null || device.userId == user?.id).map((device) => ( - - ))} + {labDevices.filter((device) => device.userId == null || device.userId == user?.id).map((device) => { + const portsArray = device.ports.split(','); + const generatedPorts = portsArray.flatMap(portDef => generatePorts(portDef)); + const hasAvailablePorts = generatedPorts.some(port => !firstDeviceOccupiedPorts.includes(port)); + return ( + + ); + })}