feat(editor): browser history for tabs, sections and Aller a
EditorView held by the navigation reducer (restore_view), a history adapter hook mounted in EditorWorkspace (push, replace, back, mount rule, ownership, write budget, scroll map, refused POP), a guard stack by layer, an announcer queue joined after open dialogs.
This commit is contained in:
1 parent
69e225ca7a
commit
792394d3b2
11 files changed
+1268
-40
No files matched your search
@@ -1,6 +1,15 @@
|
||||
import { StrictMode } from 'react'
|
||||
import { render } from '@testing-library/react'
|
||||
import { MemoryRouter, Route, Routes } from 'react-router-dom'
|
||||
import {
|
||||
MemoryRouter,
|
||||
Route,
|
||||
Routes,
|
||||
useLocation,
|
||||
useNavigate,
|
||||
type InitialEntry,
|
||||
type Location,
|
||||
type NavigateFunction,
|
||||
} from 'react-router-dom'
|
||||
import {
|
||||
SheetFailure,
|
||||
type OwnCatalogGrant,
|
||||
@@ -92,6 +101,16 @@ export interface MountOptions {
|
||||
adminFailure?: SheetFailureKind
|
||||
/** Renders inside <StrictMode>: effects run twice on mount, as in development. */
|
||||
strict?: boolean
|
||||
/** The router's history before the draft: the draft is the last entry (default: only it). */
|
||||
entries?: InitialEntry[]
|
||||
/** Called on every render with the router's navigate and location: Back, Forward, state. */
|
||||
probe?: (navigate: NavigateFunction, location: Location) => void
|
||||
}
|
||||
|
||||
/** Hands the router to a test: MemoryRouter listens to no popstate, a test calls navigate(-1). */
|
||||
function RouterProbe({ probe }: { probe: NonNullable<MountOptions['probe']> }) {
|
||||
probe(useNavigate(), useLocation())
|
||||
return null
|
||||
}
|
||||
|
||||
/** Mounts the draft route as an editor with the admin role, at a wide screen, by default. */
|
||||
@@ -115,7 +134,11 @@ export function mountDraft(options: MountOptions = {}) {
|
||||
)
|
||||
}
|
||||
const page = (
|
||||
<MemoryRouter initialEntries={[`/app/admin/sheets/${SHEET}/draft`]}>
|
||||
<MemoryRouter
|
||||
initialEntries={options.entries ?? [`/app/admin/sheets/${SHEET}/draft`]}
|
||||
initialIndex={options.entries ? options.entries.length - 1 : undefined}
|
||||
>
|
||||
{options.probe && <RouterProbe probe={options.probe} />}
|
||||
<Routes>
|
||||
<Route
|
||||
path="/app/admin/sheets/:sheetId/draft"
|
||||
|
||||
Reference in new issue
Block a user