Skip to content

Commit 1bb3a71

Browse files
waleedlatif1claude
andcommitted
fix(lock): add lock check to duplicate button and clean up drag handler
- Added lock check to duplicate button in action bar to prevent duplicating locked blocks (consistent with other edit operations) - Removed ineffective early return in onNodeDragStart since the `draggable` property on nodes already prevents dragging protected blocks - the early return was misleading as it couldn't actually stop a drag operation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e5d078b commit 1bb3a71

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,21 @@ export const ActionBar = memo(
267267
variant='ghost'
268268
onClick={(e) => {
269269
e.stopPropagation()
270-
if (!disabled) {
270+
if (!disabled && !isLocked && !isParentLocked) {
271271
handleDuplicateBlock()
272272
}
273273
}}
274274
className={ACTION_BUTTON_STYLES}
275-
disabled={disabled}
275+
disabled={disabled || isLocked || isParentLocked}
276276
>
277277
<Copy className={ICON_SIZE} />
278278
</Button>
279279
</Tooltip.Trigger>
280-
<Tooltip.Content side='top'>{getTooltipMessage('Duplicate Block')}</Tooltip.Content>
280+
<Tooltip.Content side='top'>
281+
{isLocked || isParentLocked
282+
? 'Block is locked'
283+
: getTooltipMessage('Duplicate Block')}
284+
</Tooltip.Content>
281285
</Tooltip.Root>
282286
)}
283287

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2855,10 +2855,7 @@ const WorkflowContent = React.memo(() => {
28552855
/** Captures initial parent ID and position when drag starts. */
28562856
const onNodeDragStart = useCallback(
28572857
(_event: React.MouseEvent, node: any) => {
2858-
// Prevent dragging protected blocks
2859-
if (isBlockProtected(node.id, blocks)) {
2860-
return
2861-
}
2858+
// Note: Protected blocks are already non-draggable via the `draggable` node property
28622859

28632860
// Store the original parent ID when starting to drag
28642861
const currentParentId = blocks[node.id]?.data?.parentId || null

0 commit comments

Comments
 (0)