feat(editor): four tabs, Annotations sections, references from the header

U1 Lot B1. Four tabs (Général, Annotations, Constats, Vérification); views,
categories and regions become full-width Annotations sections opened from the
overview panel; references move to a header-toggled panel (minimal, Lot D
completes it); « Aller à » goes through EditorTarget and the navigation hook.
EditorWorkspace owns the navigation; DraftHeader split in HeaderActions and
SaveLine; EditorTabs split in TabList and MoreTabs.

R-24, assertions removed or rewritten (file: old -> new):
unit
- editor-route.test: seven tab names -> four; « Plus » at 800 px with
  Références clicked -> no « Plus »; below 640 px five others -> Général,
  Constats, and Constats opens the findings tab; + references panel cases
- editor-route-recovery.test: tab Références + editor-tab-references label ->
  header button + editor-references-panel labelled by its heading
- editor-mode.test: small tier `more` of five -> [general, findings]
- editor-focus-request.test: {key,serial} -> {target,serial}; ReferencesTab and
  VertebraeTab -> ReferencesPanel and RegionsSection; issueTarget tab/key ->
  target place/section/key (vertebrae tab -> annotations/regions); consumed
  context (serial) -> (serial, outcome); annotation case adds heading focus
- editor-verification.test: onGoTo('annotations', key) -> navigate(targetOfKey
  (key), opener); props onSelectTab/onGoTo -> navigate
- editor-annotations-tab.test: props onSelectTab -> navigate + section props;
  no_category text « (onglet Général) » -> « (Annotations, section
  Catégories) »
- editor-tabs-general.test: categories cases render GeneralTab ->
  CategoriesSection(doc); + Général holds no categories editor
- editor-tabs-lists.test: tab imports -> panel and section; read-only
  references « no button » -> only « Fermer les références »
- editor-tabs-views, editor-drawing-upload, editor-repair.test: ViewsTab ->
  ViewsSection import, assertions kept; editor-findings.test: navigate prop
e2e
- support/editor selectTab: exact name -> pattern (error badge in the name);
  + place, openSection, showDrawing, backToDrawing, openReferences, TABS
- support/warm-up: seven tabs -> four + sections + references panel
- editor-access: seven-tab axe loops -> four tabs + three sections + panel
  (edit and read-only); narrow widths add panel overflow and axe
- editor-drawings: tab Vues -> openSection views; tab Annotations ->
  showDrawing
- editor-structures: tab Général (categories) -> openSection categories, axe
  label « general tab » -> « categories section »; tab Références ->
  openReferences/closeReferences; tab Vertèbres -> openSection regions; tab
  Annotations -> showDrawing
- editor-geometry: three tab Vues -> openSection views
- editor-equine: tab Général (categories add) -> openSection categories; five
  tabs loop -> two tabs + sections + panel; tab Annotations -> showDrawing
- editor-journey: tab Vues, tab Général (category), tab Annotations ->
  openSection views/categories, showDrawing; frozen axe scrolls to the header
- lan/trial-lan (not run): tab Vues -> Annotations tab + views entry

Verified: typecheck, lint, vitest 107 files / 1125 tests, whole shell suite on
the sandbox 151 passed, 49 skipped, 0 failed.
This commit is contained in:
bchanot committed 2026-11-06 20:25:35 +01:00
1 parent 95b1b7e461
commit bc2dba7c14
56 files changed
+2419 -699

No files matched your search

@@ -0,0 +1,115 @@
import type { OfficialSheetAdmin } from '@faunosteo/supabase'
import Notice from '@/components/ui/Notice'
import {
AnnounceContext,
FocusConsumedContext,
ownedBy,
type PlaceName,
} from '@/editor/focusRequest'
import { saveFailureMessage } from '@/editor/messages'
import type { EditorMode } from '@/editor/mode'
import type { NavigationState } from '@/editor/navigation'
import { useEditorStore } from '@/editor/state/editorStore'
import { initialTab } from '@/editor/tabs'
import { useEditorNavigation } from '@/editor/useEditorNavigation'
import type { TabTier } from '@/editor/useViewport'
import { useT } from '@/i18n/useT'
import ConflictDialog from './ConflictDialog'
import CopyIssueNotice from './CopyIssueNotice'
import DraftHeader from './DraftHeader'
import EditorTabBody from './EditorTabBody'
import EditorTabs from './EditorTabs'
import ModeNotice from './ModeNotice'
import RecoveryNotice from './RecoveryNotice'
import ReferencesPanel from './references/ReferencesPanel'
interface Props {
sheet: OfficialSheetAdmin
mode: EditorMode
/** Not editable now: a mode that cannot save, or a recovery offer not answered yet. */
readOnly: boolean
tier: TabTier
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 (
<Notice tone="error">
{saveFailureMessage(t, failure, { unsaved, copyWritten })}
</Notice>
)
}
/** The `data-place` the shown tab and section name. */
function shownPlace({ tab, section }: NavigationState): PlaceName {
return tab === 'annotations' ? `annotations.${section}` : tab
}
/**
* The draft page once the version is ready: header, notices, tab row, the references
* panel and the shown place. Owns the navigation state, so the first tab is known at
* mount (`initialTab`) and later edits never move the user off their tab.
*/
export default function EditorWorkspace(props: Props) {
const { sheet, mode, readOnly, tier, reloadSheet } = props
const previewState = useEditorStore((s) => s.previewState)
const nav = useEditorNavigation(
previewState ? initialTab(previewState, tier) : 'annotations',
)
const { state } = nav
const toggleReferences = (opener: HTMLElement) =>
state.references.open
? nav.closeReferences()
: nav.openReferences(null, opener)
return (
<div className="space-y-4">
<DraftHeader
sheet={sheet}
mode={mode}
referencesOpen={state.references.open}
onToggleReferences={toggleReferences}
/>
<ModeNotice mode={mode} sheet={sheet} />
<SaveFailureNotice />
<RecoveryNotice />
<CopyIssueNotice />
<EditorTabs active={state.tab} tier={tier} onSelect={nav.selectTab} />
<FocusConsumedContext value={nav.consumed}>
<AnnounceContext value={nav.announce}>
{state.referencesMounted && (
<ReferencesPanel
readOnly={readOnly}
focus={ownedBy(state.focus, 'references')}
open={state.references.open}
onClose={nav.closeReferences}
/>
)}
<EditorTabBody
tab={state.tab}
readOnly={readOnly}
navigate={nav.navigate}
focus={ownedBy(state.focus, shownPlace(state))}
reloadSheet={reloadSheet}
annotations={{
section: state.section,
onOpenSection: nav.openSection,
onBack: nav.backToDrawing,
}}
/>
</AnnounceContext>
</FocusConsumedContext>
<p aria-live="polite" className="sr-only">
{nav.live}
</p>
<ConflictDialog />
</div>
)
}