Skip to content

Commit 73856af

Browse files
waleedlatif1claude
andcommitted
fix(lock): address code review feedback
- Fix toggle enabled using first toggleable block, not first block - Delete button now checks isParentLocked - Lock button now has disabled state - Editor lock icon distinguishes block vs parent lock state Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3f908d6 commit 73856af

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,12 @@ export const ActionBar = memo(
225225
variant='ghost'
226226
onClick={(e) => {
227227
e.stopPropagation()
228-
collaborativeBatchToggleLocked([blockId])
228+
if (!disabled) {
229+
collaborativeBatchToggleLocked([blockId])
230+
}
229231
}}
230232
className={ACTION_BUTTON_STYLES}
233+
disabled={disabled}
231234
>
232235
{isLocked ? <Unlock className={ICON_SIZE} /> : <Lock className={ICON_SIZE} />}
233236
</Button>
@@ -319,18 +322,18 @@ export const ActionBar = memo(
319322
variant='ghost'
320323
onClick={(e) => {
321324
e.stopPropagation()
322-
if (!disabled && !isLocked) {
325+
if (!disabled && !isLocked && !isParentLocked) {
323326
collaborativeBatchRemoveBlocks([blockId])
324327
}
325328
}}
326329
className={ACTION_BUTTON_STYLES}
327-
disabled={disabled || isLocked}
330+
disabled={disabled || isLocked || isParentLocked}
328331
>
329332
<Trash2 className={ICON_SIZE} />
330333
</Button>
331334
</Tooltip.Trigger>
332335
<Tooltip.Content side='top'>
333-
{isLocked ? 'Block is locked' : getTooltipMessage('Delete Block')}
336+
{isLocked || isParentLocked ? 'Block is locked' : getTooltipMessage('Delete Block')}
334337
</Tooltip.Content>
335338
</Tooltip.Root>
336339
</div>

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/editor.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,11 @@ export function Editor() {
368368
)}
369369
</div>
370370
<div className='flex shrink-0 items-center gap-[8px]'>
371-
{/* Locked indicator - clickable to unlock if user has admin permissions */}
371+
{/* Locked indicator - clickable to unlock if user has admin permissions and block itself is locked */}
372372
{isLocked && currentBlock && (
373373
<Tooltip.Root>
374374
<Tooltip.Trigger asChild>
375-
{userPermissions.canAdmin ? (
375+
{userPermissions.canAdmin && currentBlock.locked ? (
376376
<Button
377377
variant='ghost'
378378
className='p-0'
@@ -388,7 +388,13 @@ export function Editor() {
388388
)}
389389
</Tooltip.Trigger>
390390
<Tooltip.Content side='top'>
391-
<p>{userPermissions.canAdmin ? 'Unlock block' : 'Block is locked'}</p>
391+
<p>
392+
{userPermissions.canAdmin && currentBlock.locked
393+
? 'Unlock block'
394+
: isParentLocked
395+
? 'Parent container is locked'
396+
: 'Block is locked'}
397+
</p>
392398
</Tooltip.Content>
393399
</Tooltip.Root>
394400
)}

apps/sim/socket/database/operations.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,10 @@ async function handleBlocksOperationTx(
778778
}
779779
}
780780

781-
// Determine target enabled state based on first block
782-
const firstBlock = blocksById[blockIds[0]]
781+
// Determine target enabled state based on first toggleable block
782+
if (blocksToToggle.size === 0) break
783+
const firstToggleableId = Array.from(blocksToToggle)[0]
784+
const firstBlock = blocksById[firstToggleableId]
783785
if (!firstBlock) break
784786
const targetEnabled = !firstBlock.enabled
785787

0 commit comments

Comments
 (0)