Skip to content

Commit 0ee52df

Browse files
emir-karabegcursoragentwaleedlatif1
authored
feat(canvas): allow locked block outbound connections (#3229)
* Allow outbound connections from locked blocks to be modified - Modified isEdgeProtected to only check target block protection - Outbound connections (from locked blocks) can now be added/removed - Inbound connections (to locked blocks) remain protected - Updated notification messages and comments to reflect the change Co-authored-by: Emir Karabeg <emir-karabeg@users.noreply.github.com> * update notif msg --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Emir Karabeg <emir-karabeg@users.noreply.github.com> Co-authored-by: waleed <walif6@gmail.com>
1 parent 6421b1a commit 0ee52df

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/utils/block-protection-utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,18 @@ export function isBlockProtected(blockId: string, blocks: Record<string, BlockSt
3636

3737
/**
3838
* Checks if an edge is protected from modification.
39-
* An edge is protected if either its source or target block is protected.
39+
* An edge is protected only if its target block is protected.
40+
* Outbound connections from locked blocks are allowed to be modified.
4041
*
4142
* @param edge - The edge to check (must have source and target)
4243
* @param blocks - Record of all blocks in the workflow
43-
* @returns True if the edge is protected
44+
* @returns True if the edge is protected (target is locked)
4445
*/
4546
export function isEdgeProtected(
4647
edge: { source: string; target: string },
4748
blocks: Record<string, BlockState>
4849
): boolean {
49-
return isBlockProtected(edge.source, blocks) || isBlockProtected(edge.target, blocks)
50+
return isBlockProtected(edge.target, blocks)
5051
}
5152

5253
/**

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,7 +2523,7 @@ const WorkflowContent = React.memo(() => {
25232523
.filter((change: any) => change.type === 'remove')
25242524
.map((change: any) => change.id)
25252525
.filter((edgeId: string) => {
2526-
// Prevent removing edges connected to protected blocks
2526+
// Prevent removing edges targeting protected blocks
25272527
const edge = edges.find((e) => e.id === edgeId)
25282528
if (!edge) return true
25292529
return !isEdgeProtected(edge, blocks)
@@ -2595,7 +2595,7 @@ const WorkflowContent = React.memo(() => {
25952595

25962596
if (!sourceNode || !targetNode) return
25972597

2598-
// Prevent connections to/from protected blocks
2598+
// Prevent connections to protected blocks (outbound from locked blocks is allowed)
25992599
if (isEdgeProtected(connection, blocks)) {
26002600
addNotification({
26012601
level: 'info',
@@ -3357,12 +3357,12 @@ const WorkflowContent = React.memo(() => {
33573357
/** Stable delete handler to avoid creating new function references per edge. */
33583358
const handleEdgeDelete = useCallback(
33593359
(edgeId: string) => {
3360-
// Prevent removing edges connected to protected blocks
3360+
// Prevent removing edges targeting protected blocks
33613361
const edge = edges.find((e) => e.id === edgeId)
33623362
if (edge && isEdgeProtected(edge, blocks)) {
33633363
addNotification({
33643364
level: 'info',
3365-
message: 'Cannot remove connections from locked blocks',
3365+
message: 'Cannot remove connections to locked blocks',
33663366
workflowId: activeWorkflowId || undefined,
33673367
})
33683368
return
@@ -3420,7 +3420,7 @@ const WorkflowContent = React.memo(() => {
34203420

34213421
// Handle edge deletion first (edges take priority if selected)
34223422
if (selectedEdges.size > 0) {
3423-
// Get all selected edge IDs and filter out edges connected to protected blocks
3423+
// Get all selected edge IDs and filter out edges targeting protected blocks
34243424
const edgeIds = Array.from(selectedEdges.values()).filter((edgeId) => {
34253425
const edge = edges.find((e) => e.id === edgeId)
34263426
if (!edge) return true

0 commit comments

Comments
 (0)