feat(app): editor views tab, drawing upload and cleaning, guarded crops

This commit is contained in:
bchanot committed 2026-11-04 13:02:30 +01:00
1 parent d163b2ce9a
commit 8343528be9
22 files changed
+2164 -4

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
import type { PreviewState, SheetView } from '@faunosteo/core-wasm/types'
import type { CatalogueFailure } from '@/catalogue/failure'
import { loadFailureMessage } from './messages'
/** The state of the drawing a view names itself (not the one it inherits). */
export type DrawingStatus =
| { kind: 'none' }
| { kind: 'ok' }
| { kind: 'missing' | 'rejected'; detail: string | null }
| { kind: 'failed'; failure: CatalogueFailure }
export function drawingStatusOf(
view: SheetView,
state: PreviewState,
failures: Readonly<Record<string, CatalogueFailure>>,
): DrawingStatus {
const assetId = view.svg_asset_id
if (assetId === null) return { kind: 'none' }
const held = state.drawings.find((drawing) => drawing.asset_id === assetId)
if (held?.state === 'ok') return { kind: 'ok' }
if (held) return { kind: held.state, detail: held.detail }
const failure = failures[assetId]
return failure
? { kind: 'failed', failure }
: { kind: 'missing', detail: null }
}
type Translate = (key: string) => string
export function drawingStatusText(t: Translate, status: DrawingStatus): string {
if (status.kind === 'failed') return loadFailureMessage(t, status.failure)
const label = t(`editor.views.drawing.${status.kind}`)
if (status.kind === 'ok' || status.kind === 'none' || !status.detail)
return label
return `${label} ${t('editor.views.drawing.detail').replace('{detail}', status.detail)}`
}