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:
@@ -86,6 +86,38 @@ describe('PdfViewer — loaded state', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('makes the annotation surface drawable (crosshair) when transcribeMode and canAnnotate', async () => {
|
||||
render(PdfViewer, {
|
||||
url: '/api/documents/test/file',
|
||||
documentId: 'test',
|
||||
transcribeMode: true,
|
||||
canAnnotate: true,
|
||||
libLoader: makeFakeLibLoader()
|
||||
});
|
||||
|
||||
await vi.waitFor(() => {
|
||||
const surface = document.querySelector('[role="presentation"]');
|
||||
expect(surface).not.toBeNull();
|
||||
expect(surface?.getAttribute('style') ?? '').toContain('crosshair');
|
||||
});
|
||||
});
|
||||
|
||||
it('does not make the annotation surface drawable when canAnnotate is false (read-only user)', async () => {
|
||||
render(PdfViewer, {
|
||||
url: '/api/documents/test/file',
|
||||
documentId: 'test',
|
||||
transcribeMode: true,
|
||||
canAnnotate: false,
|
||||
libLoader: makeFakeLibLoader()
|
||||
});
|
||||
|
||||
await vi.waitFor(() => {
|
||||
expect(document.querySelector('.bg-pdf-bg')).not.toBeNull();
|
||||
});
|
||||
const surface = document.querySelector('[role="presentation"]');
|
||||
expect(surface?.getAttribute('style') ?? '').not.toContain('crosshair');
|
||||
});
|
||||
|
||||
it('renders the canvas region when documentFileHash is provided', async () => {
|
||||
render(PdfViewer, {
|
||||
url: '/api/documents/test/file',
|
||||
|
||||
Reference in New Issue
Block a user