mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-03 19:24:57 -05:00
fix code block disabled state, allow unlock from editor
This commit is contained in:
@@ -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>
|
||||
)}
|
||||
|
||||
@@ -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'
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user