Skip to content

Commit

Permalink
feat(sanity): add perspectiveOverride prop to `DocumentPaneProvider…
Browse files Browse the repository at this point in the history
…` component
  • Loading branch information
juice49 committed Dec 4, 2024
1 parent cca9390 commit 3adf9ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import {usePreviewUrl} from './usePreviewUrl'
*/
// eslint-disable-next-line complexity, max-statements
export const DocumentPaneProvider = memo((props: DocumentPaneProviderProps) => {
const {children, index, pane, paneKey, onFocusPath} = props
const {children, index, pane, paneKey, onFocusPath, perspectiveOverride} = props
const schema = useSchema()
const templates = useTemplates()
const {setDocumentMeta} = useCopyPaste()
Expand Down Expand Up @@ -105,7 +105,7 @@ export const DocumentPaneProvider = memo((props: DocumentPaneProviderProps) => {
const params = useUnique(paneRouter.params) || EMPTY_PARAMS
const {perspective, currentGlobalBundle} = usePerspective()

const bundlePerspective = resolveBundlePerspective(perspective)
const bundlePerspective = perspectiveOverride ?? resolveBundlePerspective(perspective)

/* Version and the global perspective should match.
* If user clicks on add document, and then switches to another version, he should click again on create document.
Expand Down
5 changes: 5 additions & 0 deletions packages/sanity/src/structure/panes/document/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ export type TimelineMode = 'since' | 'rev' | 'closed'
export type DocumentPaneProviderProps = {
children?: React.ReactNode
onFocusPath?: (path: Path) => void
/**
* The perspective is normally determined by the router. The `perspectiveOverride` prop can be
* used to explicitly set the perspective, overriding the perspective provided by the router.
*/
perspectiveOverride?: string
} & BaseStructureToolPaneProps<'document'>

0 comments on commit 3adf9ed

Please sign in to comment.