mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-01 02:05:18 -05:00
fix(lock): prevent unlocking blocks inside locked containers
- Editor: can't unlock block if parent container is locked - Action bar: can't unlock block if parent container is locked - Shows "Parent container is locked" tooltip in both cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -225,17 +225,24 @@ export const ActionBar = memo(
|
||||
variant='ghost'
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
if (!disabled) {
|
||||
// Can't unlock a block if its parent container is locked
|
||||
if (!disabled && !(isLocked && isParentLocked)) {
|
||||
collaborativeBatchToggleLocked([blockId])
|
||||
}
|
||||
}}
|
||||
className={ACTION_BUTTON_STYLES}
|
||||
disabled={disabled}
|
||||
disabled={disabled || (isLocked && isParentLocked)}
|
||||
>
|
||||
{isLocked ? <Unlock className={ICON_SIZE} /> : <Lock className={ICON_SIZE} />}
|
||||
</Button>
|
||||
</Tooltip.Trigger>
|
||||
<Tooltip.Content side='top'>{isLocked ? 'Unlock Block' : 'Lock Block'}</Tooltip.Content>
|
||||
<Tooltip.Content side='top'>
|
||||
{isLocked && isParentLocked
|
||||
? 'Parent container is locked'
|
||||
: isLocked
|
||||
? 'Unlock Block'
|
||||
: 'Lock Block'}
|
||||
</Tooltip.Content>
|
||||
</Tooltip.Root>
|
||||
)}
|
||||
|
||||
|
||||
@@ -368,11 +368,11 @@ export function Editor() {
|
||||
)}
|
||||
</div>
|
||||
<div className='flex shrink-0 items-center gap-[8px]'>
|
||||
{/* Locked indicator - clickable to unlock if user has admin permissions and block itself is locked */}
|
||||
{/* Locked indicator - clickable to unlock if user has admin permissions, block is locked, and parent is not locked */}
|
||||
{isLocked && currentBlock && (
|
||||
<Tooltip.Root>
|
||||
<Tooltip.Trigger asChild>
|
||||
{userPermissions.canAdmin && currentBlock.locked ? (
|
||||
{userPermissions.canAdmin && currentBlock.locked && !isParentLocked ? (
|
||||
<Button
|
||||
variant='ghost'
|
||||
className='p-0'
|
||||
@@ -389,10 +389,10 @@ export function Editor() {
|
||||
</Tooltip.Trigger>
|
||||
<Tooltip.Content side='top'>
|
||||
<p>
|
||||
{userPermissions.canAdmin && currentBlock.locked
|
||||
? 'Unlock block'
|
||||
: isParentLocked
|
||||
? 'Parent container is locked'
|
||||
{isParentLocked
|
||||
? 'Parent container is locked'
|
||||
: userPermissions.canAdmin && currentBlock.locked
|
||||
? 'Unlock block'
|
||||
: 'Block is locked'}
|
||||
</p>
|
||||
</Tooltip.Content>
|
||||
|
||||
Reference in New Issue
Block a user