@@ -57,6 +57,9 @@ import {
5757 estimateBlockDimensions ,
5858 filterProtectedBlocks ,
5959 getClampedPositionForNode ,
60+ hasProtectedBlocks ,
61+ isBlockProtected ,
62+ isEdgeProtected ,
6063 isInEditableElement ,
6164 resolveParentChildSelectionConflicts ,
6265 validateTriggerPaste ,
@@ -2519,21 +2522,10 @@ const WorkflowContent = React.memo(() => {
25192522 . filter ( ( change : any ) => change . type === 'remove' )
25202523 . map ( ( change : any ) => change . id )
25212524 . filter ( ( edgeId : string ) => {
2522- // Prevent removing edges connected to locked blocks or blocks inside locked containers
2525+ // Prevent removing edges connected to protected blocks
25232526 const edge = edges . find ( ( e ) => e . id === edgeId )
25242527 if ( ! edge ) return true
2525- const sourceBlock = blocks [ edge . source ]
2526- const targetBlock = blocks [ edge . target ]
2527- const sourceParentLocked =
2528- sourceBlock ?. data ?. parentId && blocks [ sourceBlock . data . parentId ] ?. locked
2529- const targetParentLocked =
2530- targetBlock ?. data ?. parentId && blocks [ targetBlock . data . parentId ] ?. locked
2531- return (
2532- ! sourceBlock ?. locked &&
2533- ! targetBlock ?. locked &&
2534- ! sourceParentLocked &&
2535- ! targetParentLocked
2536- )
2528+ return ! isEdgeProtected ( edge , blocks )
25372529 } )
25382530
25392531 if ( edgeIdsToRemove . length > 0 ) {
@@ -2602,19 +2594,8 @@ const WorkflowContent = React.memo(() => {
26022594
26032595 if ( ! sourceNode || ! targetNode ) return
26042596
2605- // Prevent connections to/from locked blocks or blocks inside locked containers
2606- const sourceBlock = blocks [ connection . source ]
2607- const targetBlock = blocks [ connection . target ]
2608- const sourceParentLocked =
2609- sourceBlock ?. data ?. parentId && blocks [ sourceBlock . data . parentId ] ?. locked
2610- const targetParentLocked =
2611- targetBlock ?. data ?. parentId && blocks [ targetBlock . data . parentId ] ?. locked
2612- if (
2613- sourceBlock ?. locked ||
2614- targetBlock ?. locked ||
2615- sourceParentLocked ||
2616- targetParentLocked
2617- ) {
2597+ // Prevent connections to/from protected blocks
2598+ if ( isEdgeProtected ( connection , blocks ) ) {
26182599 addNotification ( {
26192600 level : 'info' ,
26202601 message : 'Cannot connect to locked blocks or blocks inside locked containers' ,
@@ -2875,9 +2856,8 @@ const WorkflowContent = React.memo(() => {
28752856 /** Captures initial parent ID and position when drag starts. */
28762857 const onNodeDragStart = useCallback (
28772858 ( _event : React . MouseEvent , node : any ) => {
2878- // Prevent dragging locked blocks
2879- const block = blocks [ node . id ]
2880- if ( block ?. locked ) {
2859+ // Prevent dragging protected blocks
2860+ if ( isBlockProtected ( node . id , blocks ) ) {
28812861 return
28822862 }
28832863
@@ -3386,28 +3366,15 @@ const WorkflowContent = React.memo(() => {
33863366 /** Stable delete handler to avoid creating new function references per edge. */
33873367 const handleEdgeDelete = useCallback (
33883368 ( edgeId : string ) => {
3389- // Prevent removing edges connected to locked blocks or blocks inside locked containers
3369+ // Prevent removing edges connected to protected blocks
33903370 const edge = edges . find ( ( e ) => e . id === edgeId )
3391- if ( edge ) {
3392- const sourceBlock = blocks [ edge . source ]
3393- const targetBlock = blocks [ edge . target ]
3394- const sourceParentLocked =
3395- sourceBlock ?. data ?. parentId && blocks [ sourceBlock . data . parentId ] ?. locked
3396- const targetParentLocked =
3397- targetBlock ?. data ?. parentId && blocks [ targetBlock . data . parentId ] ?. locked
3398- if (
3399- sourceBlock ?. locked ||
3400- targetBlock ?. locked ||
3401- sourceParentLocked ||
3402- targetParentLocked
3403- ) {
3404- addNotification ( {
3405- level : 'info' ,
3406- message : 'Cannot remove connections from locked blocks' ,
3407- workflowId : activeWorkflowId || undefined ,
3408- } )
3409- return
3410- }
3371+ if ( edge && isEdgeProtected ( edge , blocks ) ) {
3372+ addNotification ( {
3373+ level : 'info' ,
3374+ message : 'Cannot remove connections from locked blocks' ,
3375+ workflowId : activeWorkflowId || undefined ,
3376+ } )
3377+ return
34113378 }
34123379 removeEdge ( edgeId )
34133380 // Remove this edge from selection (find by edge ID value)
@@ -3462,22 +3429,11 @@ const WorkflowContent = React.memo(() => {
34623429
34633430 // Handle edge deletion first (edges take priority if selected)
34643431 if ( selectedEdges . size > 0 ) {
3465- // Get all selected edge IDs and filter out edges connected to locked blocks or blocks inside locked containers
3432+ // Get all selected edge IDs and filter out edges connected to protected blocks
34663433 const edgeIds = Array . from ( selectedEdges . values ( ) ) . filter ( ( edgeId ) => {
34673434 const edge = edges . find ( ( e ) => e . id === edgeId )
34683435 if ( ! edge ) return true
3469- const sourceBlock = blocks [ edge . source ]
3470- const targetBlock = blocks [ edge . target ]
3471- const sourceParentLocked =
3472- sourceBlock ?. data ?. parentId && blocks [ sourceBlock . data . parentId ] ?. locked
3473- const targetParentLocked =
3474- targetBlock ?. data ?. parentId && blocks [ targetBlock . data . parentId ] ?. locked
3475- return (
3476- ! sourceBlock ?. locked &&
3477- ! targetBlock ?. locked &&
3478- ! sourceParentLocked &&
3479- ! targetParentLocked
3480- )
3436+ return ! isEdgeProtected ( edge , blocks )
34813437 } )
34823438 if ( edgeIds . length > 0 ) {
34833439 collaborativeBatchRemoveEdges ( edgeIds )
@@ -3657,8 +3613,10 @@ const WorkflowContent = React.memo(() => {
36573613 canRunFromBlock = { runFromBlockState . canRun }
36583614 disableEdit = {
36593615 ! effectivePermissions . canEdit ||
3660- contextMenuBlocks . some ( ( b ) => b . locked ) ||
3661- contextMenuBlocks . some ( ( b ) => b . parentId && blocks [ b . parentId ] ?. locked )
3616+ hasProtectedBlocks (
3617+ contextMenuBlocks . map ( ( b ) => b . id ) ,
3618+ blocks
3619+ )
36623620 }
36633621 userCanEdit = { effectivePermissions . canEdit }
36643622 isExecuting = { isExecuting }
0 commit comments