From 6aba9711f0bd99623b34c946652eb277f53384c1 Mon Sep 17 00:00:00 2001 From: bchanot Date: Wed, 4 Nov 2026 12:35:33 +0100 Subject: [PATCH] feat(app): sheet draft editor route, modes, recovery offer and conflict dialog --- .../2026-11-03-v1-2-6-label-proposals.md | 75 ++++ apps/app/src/admin/labels.ts | 9 +- apps/app/src/app/App.tsx | 2 + .../app/admin/AdminSheetCreateRoute.tsx | 4 +- .../routes/app/admin/AdminSheetDraftRoute.tsx | 213 ++++++++++ .../app/routes/app/admin/AdminSheetRoute.tsx | 23 +- .../components/admin/WorkingCopyAction.tsx | 4 +- .../src/components/editor/ConfirmDialog.tsx | 51 +++ .../src/components/editor/ConflictDialog.tsx | 231 ++++++++++ .../src/components/editor/CopyIssueNotice.tsx | 115 +++++ .../app/src/components/editor/DraftHeader.tsx | 167 ++++++++ .../src/components/editor/EditorTabBody.tsx | 28 ++ apps/app/src/components/editor/EditorTabs.tsx | 110 +++++ apps/app/src/components/editor/ModeNotice.tsx | 65 +++ .../src/components/editor/RecoveryNotice.tsx | 100 +++++ .../components/editor/fields/ActionButton.tsx | 9 + .../editor/fields/ReadOnlyValue.tsx | 30 ++ .../components/editor/fields/SelectField.tsx | 54 +++ .../components/editor/fields/TextField.tsx | 95 +++++ .../components/editor/tabs/AnnotationsTab.tsx | 14 + .../components/editor/tabs/FindingsTab.tsx | 14 + .../src/components/editor/tabs/GeneralTab.tsx | 14 + .../components/editor/tabs/ReferencesTab.tsx | 14 + .../editor/tabs/VerificationTab.tsx | 14 + .../components/editor/tabs/VertebraeTab.tsx | 14 + .../src/components/editor/tabs/ViewsTab.tsx | 14 + apps/app/src/components/shell/AppLayout.tsx | 8 +- apps/app/src/components/ui/Icon.tsx | 2 + apps/app/src/editor/format.ts | 24 ++ apps/app/src/editor/messages.ts | 45 ++ apps/app/src/editor/mode.ts | 92 ++++ apps/app/src/editor/otherCopies.ts | 10 + apps/app/src/editor/tabs.ts | 37 ++ apps/app/src/editor/useViewport.ts | 24 ++ apps/app/src/i18n/en.ts | 69 +++ apps/app/src/i18n/fr.ts | 69 +++ apps/app/tests/helpers/editorRoute.tsx | 128 ++++++ apps/app/tests/unit/editor-fields.test.tsx | 122 ++++++ apps/app/tests/unit/editor-mode.test.ts | 117 ++++++ .../tests/unit/editor-route-conflict.test.tsx | 207 +++++++++ .../tests/unit/editor-route-recovery.test.tsx | 286 +++++++++++++ apps/app/tests/unit/editor-route.test.tsx | 394 ++++++++++++++++++ apps/app/tests/unit/routes.admin.test.tsx | 25 +- apps/app/tests/unit/shell.AppLayout.test.tsx | 14 + 44 files changed, 3143 insertions(+), 13 deletions(-) create mode 100644 apps/app/src/app/routes/app/admin/AdminSheetDraftRoute.tsx create mode 100644 apps/app/src/components/editor/ConfirmDialog.tsx create mode 100644 apps/app/src/components/editor/ConflictDialog.tsx create mode 100644 apps/app/src/components/editor/CopyIssueNotice.tsx create mode 100644 apps/app/src/components/editor/DraftHeader.tsx create mode 100644 apps/app/src/components/editor/EditorTabBody.tsx create mode 100644 apps/app/src/components/editor/EditorTabs.tsx create mode 100644 apps/app/src/components/editor/ModeNotice.tsx create mode 100644 apps/app/src/components/editor/RecoveryNotice.tsx create mode 100644 apps/app/src/components/editor/fields/ActionButton.tsx create mode 100644 apps/app/src/components/editor/fields/ReadOnlyValue.tsx create mode 100644 apps/app/src/components/editor/fields/SelectField.tsx create mode 100644 apps/app/src/components/editor/fields/TextField.tsx create mode 100644 apps/app/src/components/editor/tabs/AnnotationsTab.tsx create mode 100644 apps/app/src/components/editor/tabs/FindingsTab.tsx create mode 100644 apps/app/src/components/editor/tabs/GeneralTab.tsx create mode 100644 apps/app/src/components/editor/tabs/ReferencesTab.tsx create mode 100644 apps/app/src/components/editor/tabs/VerificationTab.tsx create mode 100644 apps/app/src/components/editor/tabs/VertebraeTab.tsx create mode 100644 apps/app/src/components/editor/tabs/ViewsTab.tsx create mode 100644 apps/app/src/editor/format.ts create mode 100644 apps/app/src/editor/messages.ts create mode 100644 apps/app/src/editor/mode.ts create mode 100644 apps/app/src/editor/otherCopies.ts create mode 100644 apps/app/src/editor/tabs.ts create mode 100644 apps/app/src/editor/useViewport.ts create mode 100644 apps/app/tests/helpers/editorRoute.tsx create mode 100644 apps/app/tests/unit/editor-fields.test.tsx create mode 100644 apps/app/tests/unit/editor-mode.test.ts create mode 100644 apps/app/tests/unit/editor-route-conflict.test.tsx create mode 100644 apps/app/tests/unit/editor-route-recovery.test.tsx create mode 100644 apps/app/tests/unit/editor-route.test.tsx diff --git a/.claude/audits/2026-11-03-v1-2-6-label-proposals.md b/.claude/audits/2026-11-03-v1-2-6-label-proposals.md index 04838411..95623bcb 100644 --- a/.claude/audits/2026-11-03-v1-2-6-label-proposals.md +++ b/.claude/audits/2026-11-03-v1-2-6-label-proposals.md @@ -6,3 +6,78 @@ Ratified wordings used verbatim (REVUE.md, V1-2 contract §17.9, §17.11, L15). separate review and is never declared approved. Each lot appends its rows to its own section (key, FR, EN, where it shows). + +## Lot E (draft route, header, tabs, modes, recovery offer, conflict dialog) + +Status column: `ratified` = REVUE.md wording; `plan wording` = quoted in the plan (FR verbatim, EN proposed unless noted); `proposal` = new. + +| Key | FR | EN | Where | Status | +|---|---|---|---|---| +| `admin.overview.open_draft` | Ouvrir le brouillon | Open the draft | Overview header, edit possible | plan wording | +| `admin.overview.view_draft` | Consulter le brouillon | View the draft | Overview header, read-only | plan wording | +| `admin.failure.draft.frozen` | Une revue est en cours sur ce brouillon : il ne peut plus être modifié. | A review is under way on this draft: it can no longer be edited. | Header notice after a refused save | proposal | +| `admin.failure.draft.not_a_draft` | Cette version n'est plus un brouillon. | This version is no longer a draft. | Header notice after a refused save | proposal | +| `admin.failure.sheet.inactive` | Cette fiche est archivée : son brouillon ne peut plus être modifié. | This sheet is archived: its draft can no longer be edited. | Header notice after a refused save | proposal | +| `admin.failure.sheet.state` | L'état de la fiche ne permet pas cette action. Rechargez la page. | The sheet's state does not allow this action. Reload the page. | Header notice after a refused save | proposal | +| `admin.failure.sheet.historical_read_only` | La fiche historique ne se modifie pas : créez une copie de travail. | The historical sheet cannot be edited: create a working copy. | Header notice after a refused save | proposal | +| `editor.tab.list` | Sections du brouillon | Draft sections | Tab list accessible name | proposal | +| `editor.tab.general` | Général | General | Tab | ratified (board 04) | +| `editor.tab.views` | Vues et illustrations | Views and drawings | Tab | ratified (board 04) | +| `editor.tab.annotations` | Annotations | Annotations | Tab | ratified (board 04) | +| `editor.tab.findings` | Constats | Findings | Tab | ratified (board 04) | +| `editor.tab.references` | Références | References | Tab | ratified (board 04) | +| `editor.tab.vertebrae` | Vertèbres | Vertebrae | Tab | ratified (board 04) | +| `editor.tab.verification` | Vérification | Verification | Tab | ratified FR (board 04); EN proposal | +| `editor.tab.more` | Plus | More | Narrow tab disclosure | ratified FR (board 05); EN proposal | +| `editor.draft.loading` | Chargement du brouillon… | Loading the draft… | Route, while loading | proposal | +| `editor.draft.none` | Cette fiche n'a pas de brouillon. | This sheet has no draft. | Route, no draft | plan wording (notice + link) | +| `editor.draft.overview_link` | Voir la fiche | View the sheet | Link to the overview (no draft, frozen) | proposal | +| `editor.draft.title` | Brouillon, version {number} | Draft, version {number} | Header title | ratified FR (board 04); EN proposal | +| `editor.draft.read_only` | Lecture seule | Read-only | Header badge with the lock icon | ratified (L16) | +| `editor.draft.discard` | Annuler les modifications | Discard changes | Header button and its dialog title | ratified FR (board 04); EN proposal | +| `editor.draft.discard_ask` | Abandonner les modifications non enregistrées ? Le brouillon reprendra la dernière révision enregistrée sur le serveur. | Discard the unsaved changes? The draft will return to the last revision saved on the server. | Discard confirmation | proposal | +| `editor.draft.discard_confirm` | Abandonner les modifications | Discard changes | Discard confirmation button | proposal | +| `editor.draft.status.revision` | Révision {revision} | Revision {revision} | Header status | ratified FR (board 04); EN proposal | +| `editor.draft.status.unsaved` | modifications non enregistrées | unsaved changes | Header status | ratified FR (board 04); EN proposal | +| `editor.draft.status.saving` | Enregistrement… | Saving… | Header status while a save runs | proposal | +| `editor.draft.status.copy_quota` | Copie locale impossible (stockage plein) | Local copy impossible (storage full) | Header status, write failure | plan wording | +| `editor.draft.status.copy_cap` | Copie locale impossible : deux autres brouillons ont déjà une copie dans cet onglet | Local copy impossible: two other drafts already have a copy in this tab | Header status, cap reached | plan wording | +| `editor.draft.copy_kept` | Une copie locale temporaire existe dans cet onglet. | A temporary local copy exists in this tab. | Appended to a refusal that promises kept work, copy written | plan wording | +| `editor.draft.copy_not_kept` | Les modifications non enregistrées ne peuvent pas être conservées. | The unsaved changes cannot be kept. | Appended to such a refusal, copy not written | plan wording (meaning); sentence proposal | +| `editor.draft.mode.narrow` | L'édition nécessite une largeur d'écran d'au moins 1 024 px. | Editing requires a screen at least 1,024 px wide. | Mode notice, narrow screen | ratified (L15, title alone) | +| `editor.draft.mode.rights` | Vos habilitations ne permettent pas de modifier ce brouillon. Il reste consultable. | Your permissions do not allow editing this draft. It remains readable. | Mode notice, rights | proposal | +| `editor.draft.mode.frozen_verifying` | {round} · vérification en cours | {round} · verification in progress | Mode notice, round verifying ({round} = « Revue n° N ») | plan wording | +| `editor.draft.mode.frozen_generic` | Une revue est en cours : le brouillon ne peut plus être modifié. | A review is under way: the draft can no longer be edited. | Mode notice, frozen without a known round (after a refused save) | proposal | +| `editor.draft.mode.historical` | La fiche historique ne se modifie pas : créez-en une copie de travail pour l'éditer. | The historical sheet cannot be edited: create a working copy to edit it. | Mode notice, historical sheet | proposal | +| `editor.draft.mode.inactive` | Cette fiche est archivée : son brouillon ne se modifie plus. | This sheet is archived: its draft can no longer be edited. | Mode notice, archived sheet | proposal | +| `editor.draft.mode.unusable_copy` | Une copie locale non enregistrée de ce brouillon existe dans cet onglet ; elle ne peut pas être utilisée dans cet état. | An unsaved local copy of this draft exists in this tab; it cannot be used in this state. | Mode notice addition | plan wording FR; EN proposal | +| `editor.draft.recovery.offer` | Une copie locale temporaire de ce brouillon existe dans cet onglet (révision {revision}, {time}). Elle n'est pas enregistrée sur le serveur. Choisissez avant de modifier le brouillon. | A temporary local copy of this draft exists in this tab (revision {revision}, {time}). It is not saved on the server. Choose before editing the draft. | Recovery offer | plan wording FR; EN proposal | +| `editor.draft.recovery.older` | Elle est basée sur la révision {revision} ; le serveur est à la révision {server}. | It is based on revision {revision}; the server is at revision {server}. | Recovery offer, older base | plan wording FR; EN proposal | +| `editor.draft.recovery.unreadable` | Une copie locale de ce brouillon existe dans cet onglet mais ne peut pas être lue. Elle n'est pas enregistrée sur le serveur. L'ignorer la supprime de cet onglet : son contenu sera perdu. | A local copy of this draft exists in this tab but cannot be read. It is not saved on the server. Ignoring it deletes it from this tab: its content will be lost. | Unreadable copy notice (C34) | plan wording FR; EN proposal | +| `editor.draft.recovery.refused` | La copie locale ne passe pas le contrôle du document : {kind}. Elle est conservée. | The local copy does not pass the document check: {kind}. It is kept. | Copy refused by the core ({kind} = the core's closed kind) | plan wording FR; EN proposal | +| `editor.draft.recovery.restore` | Restaurer la copie | Restore the copy | Recovery offer button | ratified (owner 2026-11-03); EN proposal | +| `editor.draft.recovery.ignore` | Ignorer la copie | Ignore the copy | Recovery offer button and dialog title | ratified (owner 2026-11-03); EN proposal | +| `editor.draft.recovery.ignore_body` | Abandonner la copie locale non enregistrée (révision {revision}, {time}) ? Elle sera supprimée de cet onglet. | Abandon the unsaved local copy (revision {revision}, {time})? It will be deleted from this tab. | Ignore / abandon confirmation | plan wording FR; EN proposal | +| `editor.draft.recovery.ignore_unreadable_body` | Abandonner la copie locale illisible ? Elle sera supprimée de cet onglet et son contenu sera perdu. | Abandon the unreadable local copy? It will be deleted from this tab and its content will be lost. | Ignore confirmation, unreadable copy | proposal | +| `editor.draft.recovery.ignore_confirm` | Abandonner la copie | Abandon the copy | Confirmation button | plan wording FR; EN proposal | +| `editor.draft.copy_issue.cap` | Deux autres brouillons ont déjà une copie locale dans cet onglet. Les modifications de celui-ci ne sont pas conservées tant que vous n'en abandonnez pas une. | Two other drafts already have a local copy in this tab. The changes to this one are not kept until you abandon one. | Cap notice | proposal | +| `editor.draft.copy_issue.quota` | Le stockage de cet onglet est plein : les modifications non enregistrées de ce brouillon ne sont pas conservées. Enregistrez le brouillon ou abandonnez une copie ci-dessous. | This tab's storage is full: the unsaved changes to this draft are not kept. Save the draft or abandon a copy below. | Quota notice | proposal | +| `editor.draft.copy.open` | Ouvrir ce brouillon | Open this draft | Other copy of the account | plan wording FR; EN proposal | +| `editor.draft.copy.abandon` | Abandonner cette copie | Abandon this copy | Other copy of the account, and dialog title | plan wording FR; EN proposal | +| `editor.draft.copy.revision` | révision {revision} | revision {revision} | Other copy line | plan wording | +| `editor.draft.copy.unreadable` | Copie illisible | Unreadable copy | Other copy line, no readable name | proposal | +| `editor.draft.conflict.reading_title` | Conflit d'enregistrement | Save conflict | Conflict dialog title while the server draft is read | proposal | +| `editor.draft.conflict.reading` | Lecture de la révision du serveur… | Reading the server revision… | Conflict dialog, reading | proposal | +| `editor.draft.conflict.known` | Une autre session a enregistré la révision {revision} | Another session saved revision {revision} | Conflict dialog title, N known | plan wording FR; EN proposal | +| `editor.draft.conflict.unknown` | Une autre session a enregistré une version plus récente de ce brouillon. | Another session saved a newer version of this draft. | Conflict dialog title, N unknown; header notice after dismissal | plan wording FR; EN proposal | +| `editor.draft.conflict.by_other` | par {name}, le {date} | by {name}, on {date} | Conflict dialog, author known | plan wording FR; EN proposal | +| `editor.draft.conflict.by_you` | depuis une autre session de votre compte, le {date} | from another session of your account, on {date} | Conflict dialog, saved by the caller | plan wording FR; EN proposal | +| `editor.draft.conflict.by_you_short` | une autre session de votre compte | another session of your account | Conflict confirmation, saved by the caller | proposal | +| `editor.draft.conflict.reload` | Recharger | Reload | Conflict dialog button | ratified (owner 2026-11-03); EN proposal | +| `editor.draft.conflict.retry` | Réessayer | Retry | Conflict dialog button, failed read | ratified (owner 2026-11-03); EN proposal | +| `editor.draft.conflict.keep` | Garder ma version | Keep my version | Conflict dialog button | ratified (owner 2026-11-03); EN proposal | +| `editor.draft.conflict.keep_hint` | Révision du serveur inconnue : rechargez ou réessayez. | Server revision unknown: reload or retry. | Hint under the disabled « Garder ma version » | plan wording FR; EN proposal | +| `editor.draft.conflict.reload_ask` | Abandonner vos modifications et recharger la révision {revision} ? | Abandon your changes and reload revision {revision}? | Reload confirmation | plan wording FR; EN proposal | +| `editor.draft.conflict.reload_unknown_ask` | Abandonner vos modifications et recharger la version du serveur ? | Abandon your changes and reload the server version? | Reload confirmation, N unknown | proposal | +| `editor.draft.conflict.keep_ask` | Remplacer la révision {revision} par votre version ? | Replace revision {revision} with your version? | Keep confirmation, author and date unknown | plan wording FR (author omitted); EN proposal | +| `editor.draft.conflict.keep_ask_by` | Remplacer la révision {revision} ({who}, {date}) par votre version ? | Replace revision {revision} ({who}, {date}) with your version? | Keep confirmation, author and date known | plan wording FR; EN proposal | diff --git a/apps/app/src/admin/labels.ts b/apps/app/src/admin/labels.ts index 4f8dd918..f6e9c3c5 100644 --- a/apps/app/src/admin/labels.ts +++ b/apps/app/src/admin/labels.ts @@ -9,8 +9,8 @@ import type { Locale } from '@/i18n/types' type Translate = (key: string) => string /** - * The failure kinds the administration screens can meet (the RPCs they call, - * their helpers and the shared session kinds), each with an + * The failure kinds the administration screens and the draft editor's saves can + * meet (the RPCs they call, their helpers and the shared session kinds), each with an * `admin.failure.` message. Any other kind cannot come from these * calls; it reads as the generic `unavailable`, never as a raw code. */ @@ -28,10 +28,15 @@ const ADMIN_FAILURE_KINDS: ReadonlySet = 'grant.ineligible', 'grant.revoked', 'grant.target_invalid', + 'draft.frozen', + 'draft.not_a_draft', 'document.shape', 'document.schema_version', 'document.species', 'document.too_large', + 'sheet.inactive', + 'sheet.state', + 'sheet.historical_read_only', 'sheet.species_invalid', 'sheet.slug_taken', 'species.exists', diff --git a/apps/app/src/app/App.tsx b/apps/app/src/app/App.tsx index b19a621c..d8458e5d 100644 --- a/apps/app/src/app/App.tsx +++ b/apps/app/src/app/App.tsx @@ -33,6 +33,7 @@ import AdminHomeRoute from './routes/app/admin/AdminHomeRoute' import AdminSheetsRoute from './routes/app/admin/AdminSheetsRoute' import AdminSheetCreateRoute from './routes/app/admin/AdminSheetCreateRoute' import AdminSheetRoute from './routes/app/admin/AdminSheetRoute' +import AdminSheetDraftRoute from './routes/app/admin/AdminSheetDraftRoute' import AdminSpeciesRoute from './routes/app/admin/AdminSpeciesRoute' import AdminAccessRoute from './routes/app/admin/AdminAccessRoute' import { useUnsavedGuard } from './useUnsavedGuard' @@ -96,6 +97,7 @@ export function AppRoutes() { } /> } /> } /> + } /> } /> } /> diff --git a/apps/app/src/app/routes/app/admin/AdminSheetCreateRoute.tsx b/apps/app/src/app/routes/app/admin/AdminSheetCreateRoute.tsx index 33e509a6..b1c8218f 100644 --- a/apps/app/src/app/routes/app/admin/AdminSheetCreateRoute.tsx +++ b/apps/app/src/app/routes/app/admin/AdminSheetCreateRoute.tsx @@ -90,7 +90,7 @@ async function createSheet( } } -/** /app/admin/sheets/new (A1, editor): species, names, slug; the new sheet's overview opens. */ +/** /app/admin/sheets/new (A1, editor): species, names, slug; the new sheet's draft editor opens. */ export default function AdminSheetCreateRoute() { const t = useT() const heading = usePageHeading() @@ -164,7 +164,7 @@ export default function AdminSheetCreateRoute() { const result = await createSheet(parsed.value) setPending(false) if ('id' in result) - navigate(`/app/admin/sheets/${result.id}`, { replace: true }) + navigate(`/app/admin/sheets/${result.id}/draft`, { replace: true }) else setOutcome(result) } diff --git a/apps/app/src/app/routes/app/admin/AdminSheetDraftRoute.tsx b/apps/app/src/app/routes/app/admin/AdminSheetDraftRoute.tsx new file mode 100644 index 00000000..a0cbbfe4 --- /dev/null +++ b/apps/app/src/app/routes/app/admin/AdminSheetDraftRoute.tsx @@ -0,0 +1,213 @@ +import { useEffect, useRef, useState } from 'react' +import { useParams } from 'react-router-dom' +import { + getOfficialSheetAdmin, + type OfficialSheetAdmin, +} from '@faunosteo/supabase' +import ConflictDialog from '@/components/editor/ConflictDialog' +import CopyIssueNotice from '@/components/editor/CopyIssueNotice' +import DraftHeader from '@/components/editor/DraftHeader' +import EditorTabBody from '@/components/editor/EditorTabBody' +import EditorTabs, { PANEL_ID } from '@/components/editor/EditorTabs' +import ModeNotice from '@/components/editor/ModeNotice' +import RecoveryNotice from '@/components/editor/RecoveryNotice' +import CatalogueFailureNotice from '@/components/catalogue/CatalogueFailureNotice' +import AccessDenied from '@/components/shell/AccessDenied' +import PermissionsUnavailable from '@/components/shell/PermissionsUnavailable' +import Button from '@/components/ui/Button' +import ButtonLink from '@/components/ui/ButtonLink' +import Card from '@/components/ui/Card' +import Notice from '@/components/ui/Notice' +import { failureMessage } from '@/admin/labels' +import { useAdminPermissions } from '@/admin/permissions' +import { isRightsRefusal, useAdminQuery } from '@/admin/useAdminQuery' +import { useLeaveGuard } from '@/app/useLeaveGuard' +import { saveFailureMessage } from '@/editor/messages' +import { + editorMode, + hasEditRight, + modeAfterSave, + storeCanEdit, +} from '@/editor/mode' +import { leaveGuardArmed, useEditorStore } from '@/editor/state/editorStore' +import type { EditorTabId } from '@/editor/tabs' +import { useTabTier } from '@/editor/useViewport' +import { useAuthStore } from '@/state/authStore' +import { useT } from '@/i18n/useT' +import { SheetNotFound } from './AdminSheetRoute' + +/** The tab the boards open on (04 and 05 both show the annotations). */ +const FIRST_TAB: EditorTabId = 'annotations' + +interface DraftEditorProps { + sheet: OfficialSheetAdmin + versionId: string + userId: string + hasRight: boolean + reloadSheet: () => void +} + +/** A refused save under the header, phrased from the closed kind and the copy's real flag. */ +function SaveFailureNotice() { + const t = useT() + const failure = useEditorStore((s) => s.saveFailure) + const unsaved = useEditorStore((s) => s.unsaved) + const copyWritten = useEditorStore((s) => s.copyWritten) + const conflictOpen = useEditorStore((s) => s.conflict !== null) + if (failure === null || (failure === 'draft_conflict' && conflictOpen)) + return null + return ( + + {saveFailureMessage(t, failure, { unsaved, copyWritten })} + + ) +} + +/** + * The draft page once the sheet is read: opens the store session for this version, derives + * the mode, and renders what the store holds. Components only render and call actions. + */ +function DraftEditor({ + sheet, + versionId, + userId, + hasRight, + reloadSheet, +}: DraftEditorProps) { + const t = useT() + const tier = useTabTier() + const [tab, setTab] = useState(FIRST_TAB) + const saveFailure = useEditorStore((s) => s.saveFailure) + const status = useEditorStore((s) => s.status) + const sessionVersion = useEditorStore((s) => s.versionId) + const failure = useEditorStore((s) => s.failure) + const recovery = useEditorStore((s) => s.recovery) + const mode = modeAfterSave( + editorMode({ hasRight, sheet, wide: tier === 'wide' }), + saveFailure, + ) + const canEdit = storeCanEdit(mode) + const firstCanEdit = useRef(canEdit) + + useEffect(() => { + useEditorStore + .getState() + .open(versionId, userId, { canEdit: firstCanEdit.current }) + return () => useEditorStore.getState().close() + }, [versionId, userId]) + useEffect(() => useEditorStore.getState().setCanEdit(canEdit), [canEdit]) + useLeaveGuard(useEditorStore(leaveGuardArmed)) + + if (status === 'failed' && failure !== null) { + if (failure === 'denied') return + const retry = () => + void useEditorStore.getState().open(versionId, userId, { canEdit }) + return + } + if (status !== 'ready' || sessionVersion !== versionId) { + return ( +

+ {t('editor.draft.loading')} +

+ ) + } + const readOnly = mode !== 'edit' || recovery !== 'none' + return ( +
+ + + + + + +
+ +
+ +
+ ) +} + +function NoDraft({ sheetId }: { sheetId: string }) { + const t = useT() + return ( + + {t('editor.draft.none')} + + {t('editor.draft.overview_link')} + + + ) +} + +/** + * /app/admin/sheets/:sheetId/draft (§11.1, boards 04 and 05): the draft editor, level 1. + * Permission states in BDR-099 order: own grants loading, a `rights.*` answer, own grants + * unreadable, an unknown sheet; then the draft itself, or a notice with the way back. + */ +export default function AdminSheetDraftRoute() { + const { sheetId = '' } = useParams() + const t = useT() + const grantsStatus = useAuthStore((s) => s.catalogGrantsStatus) + const reloadAccess = useAuthStore((s) => s.reloadAccess) + const roles = useAuthStore((s) => s.roles) + const userId = useAuthStore((s) => s.user?.id ?? null) + const { editor } = useAdminPermissions() + const { state, refresh } = useAdminQuery(`draft:${sheetId}`, (client) => + getOfficialSheetAdmin(client, sheetId), + ) + + if (grantsStatus === 'loading') { + return ( +

+ {t('shell.loading_session')} +

+ ) + } + if (state.status === 'error' && isRightsRefusal(state.failure)) + return + if (grantsStatus === 'failed') { + const retry = () => { + void reloadAccess() + if (state.status === 'error') refresh() + } + return + } + if (state.status === 'error' && state.failure === 'not_found') + return + if (state.status === 'loading') { + return ( +

+ {t('editor.draft.loading')} +

+ ) + } + if (state.status === 'error') { + return ( +
+ {failureMessage(t, state.failure)} + +
+ ) + } + const sheet = state.data + if (!sheet.draft_version) return + if (!userId) return null + return ( + + ) +} diff --git a/apps/app/src/app/routes/app/admin/AdminSheetRoute.tsx b/apps/app/src/app/routes/app/admin/AdminSheetRoute.tsx index a3b6f3e9..7e93dc58 100644 --- a/apps/app/src/app/routes/app/admin/AdminSheetRoute.tsx +++ b/apps/app/src/app/routes/app/admin/AdminSheetRoute.tsx @@ -26,6 +26,8 @@ import { speciesLabel, } from '@/admin/labels' import { useAdminPermissions } from '@/admin/permissions' +import { draftEditable, hasEditRight } from '@/editor/mode' +import { useAuthStore } from '@/state/authStore' import { isRightsRefusal, useAdminQuery } from '@/admin/useAdminQuery' import { usePageHeading } from '@/app/usePageHeading' import type { Locale } from '@/i18n/types' @@ -190,7 +192,7 @@ function Section({ } /** One answer for an unknown id and a sheet this account may not see (M7 `not_found`). */ -function SheetNotFound() { +export function SheetNotFound() { const t = useT() const heading = usePageHeading() return ( @@ -215,8 +217,9 @@ function SheetNotFound() { /** * /app/admin/sheets/:sheetId (§11.1): the sheet, its versions and rounds. * « Créer une copie de travail » on the historical sheet for editors (W1); - * « Voir dans le catalogue » once a version is published. The editor link - * arrives with V1-2.6, deprecation and archive with V1-2.7. + * « Voir dans le catalogue » once a version is published. « Ouvrir le brouillon » + * (edit possible) or « Consulter le brouillon » opens the editor; deprecation and + * archive arrive with V1-2.7. */ export default function AdminSheetRoute() { const { sheetId = '' } = useParams() @@ -224,6 +227,7 @@ export default function AdminSheetRoute() { const heading = usePageHeading() const locale = useLocaleStore((s) => s.locale) const { editor } = useAdminPermissions() + const roles = useAuthStore((s) => s.roles) const { state, refresh } = useAdminQuery(`sheet:${sheetId}`, (client) => loadSheet(client, sheetId), ) @@ -294,6 +298,19 @@ export default function AdminSheetRoute() { copyActive={sheet.working_copy_active === true} /> )} + {sheet.draft_version && ( + + {t( + draftEditable(hasEditRight(editor, roles), sheet) + ? 'admin.overview.open_draft' + : 'admin.overview.view_draft', + )} + + )} {sheet.current_version && ( void + onCancel: () => void + pending?: boolean +} + +/** A question with its two answers; the cancel answer changes nothing. */ +export default function ConfirmDialog({ + open, + title, + body, + confirmLabel, + cancelLabel, + onConfirm, + onCancel, + pending = false, +}: ConfirmDialogProps) { + return ( + {body}

+ } + size="sm" + > +
+ + +
+
+ ) +} diff --git a/apps/app/src/components/editor/ConflictDialog.tsx b/apps/app/src/components/editor/ConflictDialog.tsx new file mode 100644 index 00000000..4c4921e5 --- /dev/null +++ b/apps/app/src/components/editor/ConflictDialog.tsx @@ -0,0 +1,231 @@ +import { useState } from 'react' +import Button from '@/components/ui/Button' +import Dialog from '@/components/ui/Dialog' +import Notice from '@/components/ui/Notice' +import { personName } from '@/admin/labels' +import { formatParisDateTime } from '@/editor/format' +import { loadFailureMessage, saveFailureMessage } from '@/editor/messages' +import { useEditorStore } from '@/editor/state/editorStore' +import type { + ConflictLastSave, + ConflictState, +} from '@/editor/state/editorTypes' +import type { Locale } from '@/i18n/types' +import { useLocaleStore } from '@/state/localeStore' +import { useT } from '@/i18n/useT' + +type Translate = ReturnType +type Step = 'choose' | 'reload' | 'keep' +type Known = Extract + +/** Who and when, only when the server tells it (never invented). */ +function whoAndWhen( + t: Translate, + locale: Locale, + last: ConflictLastSave | null, +) { + if (!last) return null + const date = formatParisDateTime(last.savedAt, locale) + if (last.byCaller) { + return { + line: t('editor.draft.conflict.by_you').replace('{date}', date), + who: null, + date, + } + } + const who = personName(t, last.savedBy) + const line = t('editor.draft.conflict.by_other') + .replace('{name}', who) + .replace('{date}', date) + return { line, who, date } +} + +function conflictTitle(t: Translate, conflict: ConflictState): string { + if (conflict.status === 'known') { + return t('editor.draft.conflict.known').replace( + '{revision}', + String(conflict.revision), + ) + } + return t( + conflict.status === 'reading' + ? 'editor.draft.conflict.reading_title' + : 'editor.draft.conflict.unknown', + ) +} + +function reloadQuestion(t: Translate, conflict: ConflictState): string { + if (conflict.status !== 'known') + return t('editor.draft.conflict.reload_unknown_ask') + return t('editor.draft.conflict.reload_ask').replace( + '{revision}', + String(conflict.revision), + ) +} + +function keepQuestion(t: Translate, locale: Locale, conflict: Known): string { + const info = whoAndWhen(t, locale, conflict.lastSave) + const revision = String(conflict.revision) + if (!info) + return t('editor.draft.conflict.keep_ask').replace('{revision}', revision) + const who = info.who ?? t('editor.draft.conflict.by_you_short') + return t('editor.draft.conflict.keep_ask_by') + .replace('{revision}', revision) + .replace('{who}', who) + .replace('{date}', info.date) +} + +/** + * The conflict dialog (C29): the page read the server draft after `draft_conflict`. The + * known variant names the revision N, and its author and time only when the server says; + * the unknown variant (failed read) offers « Recharger » and « Réessayer » only. Both + * overwrites ask first; the server's atomic revision check decides at write time. + */ +export default function ConflictDialog() { + const t = useT() + const conflict = useEditorStore((s) => s.conflict) + const dismiss = () => useEditorStore.getState().dismissConflict() + return ( + + {conflict && ( + + )} + + ) +} + +function ConflictBody({ conflict }: { conflict: ConflictState }) { + const t = useT() + const locale = useLocaleStore((s) => s.locale) + const [step, setStep] = useState('choose') + const [pending, setPending] = useState(false) + const [error, setError] = useState(null) + const store = useEditorStore + const known = conflict.status === 'known' + + const run = async (action: () => Promise) => { + setPending(true) + setError(null) + setError(await action()) + setPending(false) + } + const reload = () => + run(async () => { + const result = await store + .getState() + .reloadServerDraft({ confirmed: true }) + return !result.ok && result.reason === 'load' + ? loadFailureMessage(t, result.failure) + : null + }) + const keep = () => + run(async () => { + const result = await store.getState().keepMine({ confirmed: true }) + if ( + result.ok || + result.reason !== 'server' || + result.kind === 'draft_conflict' + ) + return null + const { unsaved, copyWritten } = store.getState() + return saveFailureMessage(t, result.kind, { unsaved, copyWritten }) + }) + + if (conflict.status === 'reading') { + return ( +

+ {t('editor.draft.conflict.reading')} +

+ ) + } + if (step !== 'choose') { + const ask = + step === 'reload' + ? reloadQuestion(t, conflict) + : keepQuestion(t, locale, conflict as Known) + return ( +
+

{ask}

+ {error && {error}} +
+ + +
+
+ ) + } + const info = known ? whoAndWhen(t, locale, conflict.lastSave) : null + return ( +
+ {info &&

{info.line}

} + {error && {error}} +
+ + {!known && ( + + )} + + +
+ {!known && ( +

+ {t('editor.draft.conflict.keep_hint')} +

+ )} +
+ ) +} diff --git a/apps/app/src/components/editor/CopyIssueNotice.tsx b/apps/app/src/components/editor/CopyIssueNotice.tsx new file mode 100644 index 00000000..41be8c9a --- /dev/null +++ b/apps/app/src/components/editor/CopyIssueNotice.tsx @@ -0,0 +1,115 @@ +import { useState } from 'react' +import { Link } from 'react-router-dom' +import Button from '@/components/ui/Button' +import Notice from '@/components/ui/Notice' +import { formatParisTime } from '@/editor/format' +import { copySheetId } from '@/editor/otherCopies' +import { useEditorStore } from '@/editor/state/editorStore' +import type { StoredCopyInfo } from '@/editor/state/recovery' +import type { Locale } from '@/i18n/types' +import { useLocaleStore } from '@/state/localeStore' +import { useT } from '@/i18n/useT' +import ConfirmDialog from './ConfirmDialog' + +type Translate = ReturnType + +/** « · révision R · », each part only when the copy tells it. */ +function copyLine(t: Translate, locale: Locale, copy: StoredCopyInfo): string { + return [ + copy.sheetName ?? t('editor.draft.copy.unreadable'), + copy.revision === null + ? null + : t('editor.draft.copy.revision').replace( + '{revision}', + String(copy.revision), + ), + copy.writtenAt === null ? null : formatParisTime(copy.writtenAt, locale), + ] + .filter(Boolean) + .join(' · ') +} + +/** + * The write failed (C28: cap of two other copies, or a full storage): the account's other + * copies are listed, each openable and abandonable (confirmed); abandoning writes the + * current copy again at once. Nothing is evicted by itself. + */ +export default function CopyIssueNotice() { + const t = useT() + const locale = useLocaleStore((s) => s.locale) + const issue = useEditorStore((s) => s.copyIssue) + const copies = useEditorStore((s) => s.otherCopies) + const userId = useEditorStore((s) => s.userId) + const [asking, setAsking] = useState(null) + if (issue === null) return null + + const abandon = () => { + if (asking) + useEditorStore + .getState() + .abandonOtherCopy(asking.versionId, { confirmed: true }) + setAsking(null) + } + return ( + <> + +

{t(`editor.draft.copy_issue.${issue}`)}

+
    + {copies.map((copy) => { + const sheetId = userId ? copySheetId(userId, copy.versionId) : null + return ( +
  • + {copyLine(t, locale, copy)} + {sheetId && ( + + {t('editor.draft.copy.open')} + + )} + +
  • + ) + })} +
+ {issue === 'quota' && ( + + )} +
+ setAsking(null)} + /> + + ) +} diff --git a/apps/app/src/components/editor/DraftHeader.tsx b/apps/app/src/components/editor/DraftHeader.tsx new file mode 100644 index 00000000..abc79e3c --- /dev/null +++ b/apps/app/src/components/editor/DraftHeader.tsx @@ -0,0 +1,167 @@ +import { useState } from 'react' +import { Link } from 'react-router-dom' +import type { OfficialSheetAdmin } from '@faunosteo/supabase' +import Badge from '@/components/ui/Badge' +import Button from '@/components/ui/Button' +import Icon from '@/components/ui/Icon' +import Notice from '@/components/ui/Notice' +import { localized } from '@/admin/labels' +import { loadFailureMessage } from '@/editor/messages' +import type { EditorMode } from '@/editor/mode' +import { useEditorStore } from '@/editor/state/editorStore' +import { usePageHeading } from '@/app/usePageHeading' +import { useLocaleStore } from '@/state/localeStore' +import { useT } from '@/i18n/useT' +import ConfirmDialog from './ConfirmDialog' + +type Translate = ReturnType + +interface Status { + copyIssue: 'cap' | 'quota' | null + saving: boolean + unsaved: boolean + revision: number +} + +/** Board 04's line; only the copy failures replace it (the copy is temporary, this tab's). */ +function statusText(t: Translate, status: Status): string { + if (status.copyIssue !== null) + return t(`editor.draft.status.copy_${status.copyIssue}`) + if (status.saving) return t('editor.draft.status.saving') + const revision = t('editor.draft.status.revision').replace( + '{revision}', + String(status.revision), + ) + return status.unsaved + ? `${revision} · ${t('editor.draft.status.unsaved')}` + : revision +} + +/** Breadcrumb of board 04: Administration › Fiches officielles › the sheet › the draft. */ +function Breadcrumb({ + sheet, + title, +}: { + sheet: OfficialSheetAdmin + title: string +}) { + const t = useT() + const locale = useLocaleStore((s) => s.locale) + const link = 'underline-offset-2 hover:underline' + return ( + + ) +} + +/** + * The draft's header: title and badges, the revision line with the unsaved state, and in + * edit mode « Annuler les modifications » (confirmed) and « Enregistrer ». « Annuler les + * modifications » is the store's `discardChanges`; with an older base it reloads. + */ +export default function DraftHeader({ + sheet, + mode, +}: { + sheet: OfficialSheetAdmin + mode: EditorMode +}) { + const t = useT() + const heading = usePageHeading() + const unsaved = useEditorStore((s) => s.unsaved) + const saving = useEditorStore((s) => s.saving) + const blocked = useEditorStore((s) => s.recovery !== 'none') + const revision = useEditorStore((s) => s.savedRevision) + const copyIssue = useEditorStore((s) => s.copyIssue) + const [asking, setAsking] = useState(false) + const [failure, setFailure] = useState(null) + const title = t('editor.draft.title').replace( + '{number}', + String(sheet.draft_version?.version_number ?? ''), + ) + + const discard = async () => { + setAsking(false) + const result = await useEditorStore + .getState() + .discardChanges({ confirmed: true }) + setFailure( + !result.ok && result.reason === 'load' + ? loadFailureMessage(t, result.failure) + : null, + ) + } + return ( +
+ +
+

+ {title} +

+ {t('admin.version_status.draft')} + {sheet.working_copy && {t('admin.badge.working_copy')}} + {mode !== 'edit' && ( + + + {t('editor.draft.read_only')} + + )} +

+ {statusText(t, { copyIssue, saving, unsaved, revision })} +

+ {mode === 'edit' && ( +
+ + +
+ )} +
+ {failure && {failure}} + void discard()} + onCancel={() => setAsking(false)} + /> +
+ ) +} diff --git a/apps/app/src/components/editor/EditorTabBody.tsx b/apps/app/src/components/editor/EditorTabBody.tsx new file mode 100644 index 00000000..e1feed58 --- /dev/null +++ b/apps/app/src/components/editor/EditorTabBody.tsx @@ -0,0 +1,28 @@ +import type { ComponentType } from 'react' +import type { EditorTabId, EditorTabProps } from '@/editor/tabs' +import AnnotationsTab from './tabs/AnnotationsTab' +import FindingsTab from './tabs/FindingsTab' +import GeneralTab from './tabs/GeneralTab' +import ReferencesTab from './tabs/ReferencesTab' +import VerificationTab from './tabs/VerificationTab' +import VertebraeTab from './tabs/VertebraeTab' +import ViewsTab from './tabs/ViewsTab' + +/** One component per tab (Lots F-J fill them); only the active one is mounted. */ +const BODIES: Record> = { + general: GeneralTab, + views: ViewsTab, + annotations: AnnotationsTab, + findings: FindingsTab, + references: ReferencesTab, + vertebrae: VertebraeTab, + verification: VerificationTab, +} + +export default function EditorTabBody({ + tab, + ...props +}: EditorTabProps & { tab: EditorTabId }) { + const Body = BODIES[tab] + return +} diff --git a/apps/app/src/components/editor/EditorTabs.tsx b/apps/app/src/components/editor/EditorTabs.tsx new file mode 100644 index 00000000..a211693b --- /dev/null +++ b/apps/app/src/components/editor/EditorTabs.tsx @@ -0,0 +1,110 @@ +import { useState, type KeyboardEvent } from 'react' +import { tabsFor, type EditorTabId } from '@/editor/tabs' +import type { TabTier } from '@/editor/useViewport' +import { useT } from '@/i18n/useT' + +export const PANEL_ID = 'editor-panel' +export const tabDomId = (tab: EditorTabId) => `editor-tab-${tab}` + +const BASE = + 'min-h-11 whitespace-nowrap border-b-2 px-3 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]' +const ACTIVE = + 'border-[var(--color-accent)] font-medium text-[var(--color-accent-strong)]' +const IDLE = + 'border-transparent text-[var(--color-ink-muted)] hover:text-[var(--color-ink)]' + +interface EditorTabsProps { + active: EditorTabId + tier: TabTier + onSelect: (tab: EditorTabId) => void +} + +/** + * The draft's tabs (boards 04 and 05): all seven wide, the static lists of 640 px and over + * and below it narrow, with « Plus » opening a disclosure of the others (no measurement). + */ +export default function EditorTabs({ + active, + tier, + onSelect, +}: EditorTabsProps) { + const t = useT() + const { shown, more } = tabsFor(tier) + const [open, setOpen] = useState(false) + const moreActive = more.includes(active) + + const onKeyDown = (event: KeyboardEvent) => { + const at = shown.indexOf(active) + const step = + event.key === 'ArrowRight' ? 1 : event.key === 'ArrowLeft' ? -1 : 0 + if (step === 0 || at < 0) return + event.preventDefault() + const next = shown[(at + step + shown.length) % shown.length] + onSelect(next) + document.getElementById(tabDomId(next))?.focus() + } + const pick = (tab: EditorTabId) => { + onSelect(tab) + setOpen(false) + } + + return ( +
+
+
+ {shown.map((tab) => ( + + ))} +
+ {more.length > 0 && ( + + )} +
+ {open && ( +
    + {more.map((tab) => ( +
  • + +
  • + ))} +
+ )} +
+ ) +} diff --git a/apps/app/src/components/editor/ModeNotice.tsx b/apps/app/src/components/editor/ModeNotice.tsx new file mode 100644 index 00000000..18bca718 --- /dev/null +++ b/apps/app/src/components/editor/ModeNotice.tsx @@ -0,0 +1,65 @@ +import { Link } from 'react-router-dom' +import Notice from '@/components/ui/Notice' +import { roundLabel } from '@/admin/labels' +import { freezingRound, type EditorMode } from '@/editor/mode' +import { useEditorStore } from '@/editor/state/editorStore' +import { useT } from '@/i18n/useT' +import type { OfficialSheetAdmin } from '@faunosteo/supabase' + +type Translate = ReturnType + +/** « Revue n° N · vérification en cours », else the round's status label. */ +function frozenText(t: Translate, sheet: OfficialSheetAdmin): string { + const round = freezingRound(sheet) + if (!round) return t('editor.draft.mode.frozen_generic') + const number = t('admin.overview.round').replace( + '{round}', + String(round.round), + ) + if (round.status === 'verifying') { + return t('editor.draft.mode.frozen_verifying').replace('{round}', number) + } + return `${number} · ${roundLabel(t, round).title}` +} + +function modeText( + t: Translate, + mode: EditorMode, + sheet: OfficialSheetAdmin, +): string { + return mode === 'frozen' + ? frozenText(t, sheet) + : t(`editor.draft.mode.${mode}`) +} + +/** + * Why the draft is read-only (boards 05): the reason alone, nothing repeated (L15). The + * frozen state links to the overview; a recovery copy that this state cannot use is named. + */ +export default function ModeNotice({ + mode, + sheet, +}: { + mode: EditorMode + sheet: OfficialSheetAdmin +}) { + const t = useT() + const unusableCopy = useEditorStore((s) => s.unusableCopy) + if (mode === 'edit') return null + return ( + +

{modeText(t, mode, sheet)}

+ {unusableCopy && ( +

{t('editor.draft.mode.unusable_copy')}

+ )} + {mode === 'frozen' && ( + + {t('editor.draft.overview_link')} + + )} +
+ ) +} diff --git a/apps/app/src/components/editor/RecoveryNotice.tsx b/apps/app/src/components/editor/RecoveryNotice.tsx new file mode 100644 index 00000000..4a1b0e3b --- /dev/null +++ b/apps/app/src/components/editor/RecoveryNotice.tsx @@ -0,0 +1,100 @@ +import { useState } from 'react' +import Button from '@/components/ui/Button' +import Notice from '@/components/ui/Notice' +import { formatParisTime } from '@/editor/format' +import { useEditorStore } from '@/editor/state/editorStore' +import type { RecoveryOffer } from '@/editor/state/editorTypes' +import type { Locale } from '@/i18n/types' +import { useLocaleStore } from '@/state/localeStore' +import { useT } from '@/i18n/useT' +import ConfirmDialog from './ConfirmDialog' + +type Translate = ReturnType + +function named(text: string, offer: RecoveryOffer, locale: Locale): string { + return text + .replace('{revision}', String(offer.revision)) + .replace('{time}', formatParisTime(offer.writtenAt, locale)) +} + +/** The notice text: unreadable (the loss named), refused by the core, or the offer. */ +function noticeText( + t: Translate, + locale: Locale, + offer: RecoveryOffer | null, + refused: string | null, +): string { + if (!offer || refused === 'unreadable') + return t('editor.draft.recovery.unreadable') + if (refused !== null) + return t('editor.draft.recovery.refused').replace('{kind}', refused) + const base = named(t('editor.draft.recovery.offer'), offer, locale) + if (offer.revision >= offer.serverRevision) return base + const older = t('editor.draft.recovery.older') + .replace('{revision}', String(offer.revision)) + .replace('{server}', String(offer.serverRevision)) + return `${base} ${older}` +} + +/** + * The blocking offer under the header (C13, C27, C28): a temporary copy of this tab, not a + * server save. The store refuses every change until « Ignorer la copie » or a restore; the + * page only phrases it. An unreadable copy offers « Ignorer la copie » alone, a copy the + * core refused shows « Restaurer la copie » disabled. + */ +export default function RecoveryNotice() { + const t = useT() + const locale = useLocaleStore((s) => s.locale) + const recovery = useEditorStore((s) => s.recovery) + const offer = useEditorStore((s) => s.offer) + const refused = useEditorStore((s) => s.refusedKind) + const [asking, setAsking] = useState(false) + if (recovery === 'none') return null + + const unreadable = !offer || refused === 'unreadable' + const busy = recovery === 'restoring' + const question = unreadable + ? t('editor.draft.recovery.ignore_unreadable_body') + : named(t('editor.draft.recovery.ignore_body'), offer, locale) + const ignore = () => { + useEditorStore.getState().ignoreCopy({ confirmed: true }) + setAsking(false) + } + return ( + <> + +

{noticeText(t, locale, offer, refused)}

+
+ {!unreadable && ( + + )} + +
+
+ setAsking(false)} + /> + + ) +} diff --git a/apps/app/src/components/editor/fields/ActionButton.tsx b/apps/app/src/components/editor/fields/ActionButton.tsx new file mode 100644 index 00000000..0218f86e --- /dev/null +++ b/apps/app/src/components/editor/fields/ActionButton.tsx @@ -0,0 +1,9 @@ +import Button, { type ButtonProps } from '@/components/ui/Button' + +/** An action of a panel: absent from the page while the panel is read-only. */ +export default function ActionButton({ + readOnly, + ...props +}: ButtonProps & { readOnly: boolean }) { + return readOnly ? null :