Skip to content

Commit ecb13a5

Browse files
waleedlatif1claude
andcommitted
fix(lock): ensure consistent behavior across all UIs
Block Menu, Editor, Action Bar now all have identical behavior: - Enable/Disable: disabled when locked OR parent locked - Flip Handles: disabled when locked OR parent locked - Delete: disabled when locked OR parent locked - Remove from Subflow: disabled when locked OR parent locked - Lock: always available for admins - Unlock: disabled when parent is locked (unlock parent first) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent bd36283 commit ecb13a5

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/action-bar/action-bar.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,18 +200,18 @@ export const ActionBar = memo(
200200
variant='ghost'
201201
onClick={(e) => {
202202
e.stopPropagation()
203-
if (!disabled && !isLocked) {
203+
if (!disabled && !isLocked && !isParentLocked) {
204204
collaborativeBatchToggleBlockEnabled([blockId])
205205
}
206206
}}
207207
className={ACTION_BUTTON_STYLES}
208-
disabled={disabled || isLocked}
208+
disabled={disabled || isLocked || isParentLocked}
209209
>
210210
{isEnabled ? <Circle className={ICON_SIZE} /> : <CircleOff className={ICON_SIZE} />}
211211
</Button>
212212
</Tooltip.Trigger>
213213
<Tooltip.Content side='top'>
214-
{isLocked
214+
{isLocked || isParentLocked
215215
? 'Block is locked'
216216
: getTooltipMessage(isEnabled ? 'Disable Block' : 'Enable Block')}
217217
</Tooltip.Content>
@@ -274,12 +274,12 @@ export const ActionBar = memo(
274274
variant='ghost'
275275
onClick={(e) => {
276276
e.stopPropagation()
277-
if (!disabled && !isLocked) {
277+
if (!disabled && !isLocked && !isParentLocked) {
278278
collaborativeBatchToggleBlockHandles([blockId])
279279
}
280280
}}
281281
className={ACTION_BUTTON_STYLES}
282-
disabled={disabled || isLocked}
282+
disabled={disabled || isLocked || isParentLocked}
283283
>
284284
{horizontalHandles ? (
285285
<ArrowLeftRight className={ICON_SIZE} />
@@ -289,7 +289,7 @@ export const ActionBar = memo(
289289
</Button>
290290
</Tooltip.Trigger>
291291
<Tooltip.Content side='top'>
292-
{isLocked
292+
{isLocked || isParentLocked
293293
? 'Block is locked'
294294
: getTooltipMessage(horizontalHandles ? 'Vertical Ports' : 'Horizontal Ports')}
295295
</Tooltip.Content>

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/block-menu/block-menu.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface BlockInfo {
2121
parentId?: string
2222
parentType?: string
2323
locked?: boolean
24+
isParentLocked?: boolean
2425
}
2526

2627
/**
@@ -98,6 +99,8 @@ export function BlockMenu({
9899
const allDisabled = selectedBlocks.every((b) => !b.enabled)
99100
const allLocked = selectedBlocks.every((b) => b.locked)
100101
const allUnlocked = selectedBlocks.every((b) => !b.locked)
102+
// Can't unlock blocks that have locked parents
103+
const hasBlockWithLockedParent = selectedBlocks.some((b) => b.locked && b.isParentLocked)
101104

102105
const hasSingletonBlock = selectedBlocks.some(
103106
(b) =>
@@ -216,12 +219,15 @@ export function BlockMenu({
216219
)}
217220
{canAdmin && onToggleLocked && (
218221
<PopoverItem
222+
disabled={hasBlockWithLockedParent}
219223
onClick={() => {
220-
onToggleLocked()
221-
onClose()
224+
if (!hasBlockWithLockedParent) {
225+
onToggleLocked()
226+
onClose()
227+
}
222228
}}
223229
>
224-
{getToggleLockedLabel()}
230+
{hasBlockWithLockedParent ? 'Parent is locked' : getToggleLockedLabel()}
225231
</PopoverItem>
226232
)}
227233

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-canvas-context-menu.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export function useCanvasContextMenu({ blocks, getNodes, setNodes }: UseCanvasCo
3131
nodes.map((n) => {
3232
const block = blocks[n.id]
3333
const parentId = block?.data?.parentId
34-
const parentType = parentId ? blocks[parentId]?.type : undefined
34+
const parentBlock = parentId ? blocks[parentId] : undefined
35+
const parentType = parentBlock?.type
3536
return {
3637
id: n.id,
3738
type: block?.type || '',
@@ -40,6 +41,7 @@ export function useCanvasContextMenu({ blocks, getNodes, setNodes }: UseCanvasCo
4041
parentId,
4142
parentType,
4243
locked: block?.locked ?? false,
44+
isParentLocked: parentBlock?.locked ?? false,
4345
}
4446
}),
4547
[blocks]

0 commit comments

Comments
 (0)