fix code block disabled state, allow unlock from editor

This commit is contained in:
waleed
2026-01-31 18:45:42 -08:00
parent c19263e25f
commit 3f908d6121
2 changed files with 20 additions and 7 deletions

View File

@@ -11,6 +11,7 @@ import {
Loader2,
Lock,
Pencil,
Unlock,
} from 'lucide-react'
import { useParams } from 'next/navigation'
import { useShallow } from 'zustand/react/shallow'
@@ -227,6 +228,7 @@ export function Editor() {
collaborativeSetBlockCanonicalMode,
collaborativeUpdateBlockName,
collaborativeToggleBlockAdvancedMode,
collaborativeBatchToggleLocked,
} = useCollaborativeWorkflow()
// Advanced mode toggle handler
@@ -366,16 +368,27 @@ export function Editor() {
)}
</div>
<div className='flex shrink-0 items-center gap-[8px]'>
{/* Locked indicator */}
{/* Locked indicator - clickable to unlock if user has admin permissions */}
{isLocked && currentBlock && (
<Tooltip.Root>
<Tooltip.Trigger asChild>
<div className='flex items-center justify-center'>
<Lock className='h-[14px] w-[14px] text-[var(--text-secondary)]' />
</div>
{userPermissions.canAdmin ? (
<Button
variant='ghost'
className='p-0'
onClick={() => collaborativeBatchToggleLocked([currentBlockId!])}
aria-label='Unlock block'
>
<Unlock className='h-[14px] w-[14px] text-[var(--text-secondary)]' />
</Button>
) : (
<div className='flex items-center justify-center'>
<Lock className='h-[14px] w-[14px] text-[var(--text-secondary)]' />
</div>
)}
</Tooltip.Trigger>
<Tooltip.Content side='top'>
<p>Block is locked</p>
<p>{userPermissions.canAdmin ? 'Unlock block' : 'Block is locked'}</p>
</Tooltip.Content>
</Tooltip.Root>
)}

View File

@@ -458,8 +458,8 @@ export function getCodeEditorProps(options?: {
'caret-[var(--text-primary)] dark:caret-white',
// Font smoothing
'[-webkit-font-smoothing:antialiased] [-moz-osx-font-smoothing:grayscale]',
// Disable interaction for streaming/preview
(isStreaming || isPreview) && 'pointer-events-none'
// Disable interaction for streaming/preview/disabled
(isStreaming || isPreview || disabled) && 'pointer-events-none'
),
}
}