Constats opens each element in one modal dialog (view, edit with a local draft, creation) driven by the editor view layer of the browser history. The citations panel becomes a modal side sheet stacked over it; its geometry, exit machinery and page inertness are removed. Back and Forward restore the layers, a dirty form asks first.
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { vi } from 'vitest'
|
|
import CitationsSheet from '@/components/editor/references/CitationsSheet'
|
|
import FindingsTab from '@/components/editor/tabs/FindingsTab'
|
|
import { findingLayerOf } from '@/editor/findingLayer'
|
|
import { citationsOfView } from '@/editor/navigation'
|
|
import { useEditorNavigation } from '@/editor/useEditorNavigation'
|
|
import { ReadOnlyContext } from '@/editor/editingContext'
|
|
|
|
/**
|
|
* Constats with the navigation that drives its dialog and the sheet over it (what the
|
|
* workspace gives it), without the rest of the editor.
|
|
*/
|
|
export default function FindingsHost({
|
|
readOnly = false,
|
|
}: {
|
|
readOnly?: boolean
|
|
}) {
|
|
const nav = useEditorNavigation('findings')
|
|
return (
|
|
<ReadOnlyContext value={readOnly}>
|
|
<FindingsTab
|
|
readOnly={readOnly}
|
|
navigate={vi.fn()}
|
|
reloadSheet={vi.fn()}
|
|
layer={findingLayerOf(nav)}
|
|
/>
|
|
<CitationsSheet
|
|
citedBy={citationsOfView(nav.state)}
|
|
readOnly={readOnly}
|
|
guards={nav.guards}
|
|
onClose={nav.closeCitations}
|
|
onShowAll={nav.showAllReferences}
|
|
navigate={nav.navigate}
|
|
returnFocus={nav.citationsTrigger}
|
|
/>
|
|
</ReadOnlyContext>
|
|
)
|
|
}
|