feat(ui): confine read-only users to the transcription read view (#697)
On the document detail page, pass canEdit={canWrite} to the panel header,
guard onModeChange so a reader can never flip to edit, and default panelMode
to 'read' for readers. Thread canAnnotate={canWrite} through DocumentViewer
to PdfViewer so the annotation layer's canDraw (which also gates delete and
resize) is off for readers — they can open and read, but not draw, edit, or
delete. The writer-only OCR status check is also skipped for readers.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -71,7 +71,7 @@ const ocrJob = createOcrJob({
|
||||
onJobFinished: async () => {
|
||||
await transcription.load();
|
||||
transcription.bumpAnnotationReloadKey();
|
||||
panelMode = transcription.hasBlocks ? 'read' : 'edit';
|
||||
panelMode = canWrite && !transcription.hasBlocks ? 'edit' : 'read';
|
||||
}
|
||||
});
|
||||
|
||||
@@ -148,10 +148,10 @@ $effect(() => {
|
||||
if (skipInitialPanelMode) {
|
||||
skipInitialPanelMode = false;
|
||||
} else {
|
||||
panelMode = transcription.hasBlocks ? 'read' : 'edit';
|
||||
panelMode = canWrite && !transcription.hasBlocks ? 'edit' : 'read';
|
||||
}
|
||||
});
|
||||
ocrJob.checkStatus();
|
||||
if (canWrite) ocrJob.checkStatus();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -252,6 +252,7 @@ onMount(() => {
|
||||
isLoading={fileLoader.isLoading}
|
||||
error={fileLoader.fileError}
|
||||
transcribeMode={transcribeMode && !ocrJob.running}
|
||||
canAnnotate={canWrite}
|
||||
blockNumbers={transcription.blockNumbers}
|
||||
annotationReloadKey={transcription.annotationReloadKey}
|
||||
annotationsDimmed={transcribeMode && panelMode === 'read'}
|
||||
@@ -293,7 +294,10 @@ onMount(() => {
|
||||
hasBlocks={transcription.hasBlocks}
|
||||
blockCount={transcription.blocks.length}
|
||||
lastEditedAt={transcription.lastEditedAt}
|
||||
onModeChange={(newMode) => (panelMode = newMode)}
|
||||
canEdit={canWrite}
|
||||
onModeChange={(newMode) => {
|
||||
if (canWrite) panelMode = newMode;
|
||||
}}
|
||||
onClose={() => (transcribeMode = false)}
|
||||
/>
|
||||
<div class="flex-1 overflow-y-auto">
|
||||
|
||||
Reference in New Issue
Block a user