test(editor): reference dialog, filter and the owner journey, specs follow the dialog
This commit is contained in:
1 parent
7a64daf251
commit
8b42816270
20 files changed
+1546
-1171
No files matched your search
@@ -28,10 +28,10 @@ export default function FindingsHost({
|
||||
<CitationsSheet
|
||||
citedBy={citationsOfView(nav.state)}
|
||||
readOnly={readOnly}
|
||||
guards={nav.guards}
|
||||
onClose={nav.closeCitations}
|
||||
onShowAll={nav.showAllReferences}
|
||||
onShowAll={() => undefined}
|
||||
navigate={nav.navigate}
|
||||
onEdit={nav.references.open}
|
||||
returnFocus={nav.citationsTrigger}
|
||||
/>
|
||||
</ReadOnlyContext>
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import { vi } from 'vitest'
|
||||
import ReferenceDialog from '@/components/editor/references/ReferenceDialog'
|
||||
import ReferencesTab from '@/components/editor/tabs/ReferencesTab'
|
||||
import { ReadOnlyContext } from '@/editor/editingContext'
|
||||
import { referenceLayerOf } from '@/editor/findingLayer'
|
||||
import { AnnounceContext } from '@/editor/focusRequest'
|
||||
import { defaultView, type EditorView } from '@/editor/navigation'
|
||||
import type { EditorPlaceProps } from '@/editor/tabs'
|
||||
import {
|
||||
useEditorNavigation,
|
||||
type EditorNavigation,
|
||||
} from '@/editor/useEditorNavigation'
|
||||
|
||||
interface Props extends Partial<EditorPlaceProps> {
|
||||
/** The view the editor starts on (a filter, a dialog); the References tab by default. */
|
||||
view?: EditorView
|
||||
/** Reads the navigation each render, for a test that drives or inspects it. */
|
||||
onNav?: (nav: EditorNavigation) => void
|
||||
/** Renders the polite live region (the workspace's), for a test that reads announcements. */
|
||||
live?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* The References tab with the navigation that drives its dialog and its filter (what the
|
||||
* workspace gives it), without the rest of the editor.
|
||||
*/
|
||||
export default function ReferencesHost({
|
||||
readOnly = false,
|
||||
view,
|
||||
onNav,
|
||||
live = false,
|
||||
...extra
|
||||
}: Props) {
|
||||
const nav = useEditorNavigation(
|
||||
'references',
|
||||
view ?? defaultView('references'),
|
||||
)
|
||||
onNav?.(nav)
|
||||
const references = referenceLayerOf(nav)
|
||||
return (
|
||||
<ReadOnlyContext value={readOnly}>
|
||||
<AnnounceContext value={nav.announce}>
|
||||
<ReferencesTab
|
||||
readOnly={readOnly}
|
||||
navigate={vi.fn()}
|
||||
reloadSheet={vi.fn()}
|
||||
{...extra}
|
||||
references={references}
|
||||
/>
|
||||
<ReferenceDialog layer={references} readOnly={readOnly} />
|
||||
</AnnounceContext>
|
||||
{live && <p aria-live="polite">{nav.live}</p>}
|
||||
</ReadOnlyContext>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user