Skip to content

Commit 4d350c5

Browse files
authored
fix: broken sanity schema extract (#416)
1 parent 08f2d5f commit 4d350c5

File tree

6 files changed

+9
-55
lines changed

6 files changed

+9
-55
lines changed

src/components/VideoDetails/DeleteDialog.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {SanityDocument} from 'sanity'
66
import {deleteAsset} from '../../actions/assets'
77
import {useClient} from '../../hooks/useClient'
88
import {DIALOGS_Z_INDEX} from '../../util/constants'
9-
import type {PluginPlacement, VideoAssetDocument} from '../../util/types'
9+
import type {VideoAssetDocument} from '../../util/types'
1010
import SpinnerBox from '../SpinnerBox'
1111
import VideoReferences from './VideoReferences'
1212

@@ -15,11 +15,9 @@ export default function DeleteDialog({
1515
references,
1616
referencesLoading,
1717
cancelDelete,
18-
placement,
1918
succeededDeleting,
2019
}: {
2120
asset: VideoAssetDocument
22-
placement: PluginPlacement
2321
references?: SanityDocument[]
2422
referencesLoading: boolean
2523
cancelDelete: () => void
@@ -95,11 +93,7 @@ export default function DeleteDialog({
9593
pointing to this video. Remove their references to this file or delete them before
9694
proceeding.
9795
</Text>
98-
<VideoReferences
99-
references={references}
100-
isLoaded={!referencesLoading}
101-
placement={placement}
102-
/>
96+
<VideoReferences references={references} isLoaded={!referencesLoading} />
10397
</>
10498
)}
10599
{state === 'confirm' && (

src/components/VideoDetails/VideoDetails.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ const VideoDetails: React.FC<VideoDetailsProps> = (props) => {
127127
<DeleteDialog
128128
asset={props.asset}
129129
cancelDelete={() => setState('idle')}
130-
placement={props.placement}
131130
referencesLoading={referencesLoading}
132131
references={references}
133132
succeededDeleting={() => {
@@ -295,11 +294,7 @@ const VideoDetails: React.FC<VideoDetailsProps> = (props) => {
295294
id="references-panel"
296295
hidden={tab !== 'references'}
297296
>
298-
<VideoReferences
299-
references={references}
300-
isLoaded={!referencesLoading}
301-
placement={props.placement}
302-
/>
297+
<VideoReferences references={references} isLoaded={!referencesLoading} />
303298
</TabPanel>
304299
</Stack>
305300
</Flex>

src/components/VideoDetails/VideoReferences.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {Box, Card, Text} from '@sanity/ui'
33
import {collate, useSchema} from 'sanity'
44
import {styled} from 'styled-components'
55

6-
import type {PluginPlacement} from '../../util/types'
76
import {DocumentPreview} from '../documentPreview/DocumentPreview'
87
import SpinnerBox from '../SpinnerBox'
98

@@ -22,7 +21,6 @@ const Container = styled(Box)`
2221
const VideoReferences: React.FC<{
2322
references?: SanityDocument[]
2423
isLoaded: boolean
25-
placement: PluginPlacement
2624
}> = (props) => {
2725
const schema = useSchema()
2826
if (!props.isLoaded) {
@@ -53,11 +51,7 @@ const VideoReferences: React.FC<{
5351
style={{overflow: 'hidden'}}
5452
>
5553
<Box>
56-
<DocumentPreview
57-
documentPair={documentPair}
58-
schemaType={schemaType}
59-
placement={props.placement}
60-
/>
54+
<DocumentPreview documentPair={documentPair} schemaType={schemaType} />
6155
</Box>
6256
</Card>
6357
)

src/components/VideoDetails/useVideoDetails.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import {useDocumentStore} from 'sanity'
55
import {useClient} from '../../hooks/useClient'
66
import useDocReferences from '../../hooks/useDocReferences'
77
import getVideoMetadata from '../../util/getVideoMetadata'
8-
import {PluginPlacement, VideoAssetDocument} from '../../util/types'
8+
import {VideoAssetDocument} from '../../util/types'
99

1010
export interface VideoDetailsProps {
11-
placement: PluginPlacement
1211
closeDialog: () => void
1312
asset: VideoAssetDocument & {autoPlay?: boolean}
1413
}

src/components/VideosBrowser.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,7 @@ export default function VideosBrowser({onSelect}: VideosBrowserProps) {
7575
)}
7676
</Stack>
7777
{freshEditedAsset && (
78-
<VideoDetails
79-
closeDialog={() => setEditedAsset(null)}
80-
asset={freshEditedAsset}
81-
placement={placement}
82-
/>
78+
<VideoDetails closeDialog={() => setEditedAsset(null)} asset={freshEditedAsset} />
8379
)}
8480
</>
8581
)

src/components/documentPreview/DocumentPreview.tsx

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,16 @@
33
import {DocumentIcon} from '@sanity/icons'
44
import type {PropsWithChildren} from 'react'
55
import React, {useMemo} from 'react'
6-
import type {SanityDocument} from 'sanity'
7-
import type {CollatedHit, FIXME, SchemaType} from 'sanity'
6+
import type {CollatedHit, FIXME, SanityDocument, SchemaType} from 'sanity'
87
import {PreviewCard, useDocumentPresence, useDocumentPreviewStore, useSchema} from 'sanity'
9-
import {usePaneRouter} from 'sanity/desk'
108
import {IntentLink} from 'sanity/router'
119

12-
import {PluginPlacement} from '../../util/types'
1310
import {MissingSchemaType} from './MissingSchemaType'
1411
import {PaneItemPreview} from './PaneItemPreview'
1512

1613
interface DocumentPreviewProps {
1714
schemaType?: SchemaType
1815
documentPair: CollatedHit<SanityDocument>
19-
placement?: PluginPlacement
2016
}
2117

2218
/**
@@ -35,23 +31,7 @@ export function getIconWithFallback(
3531
return icon || ((schemaType && schemaType.icon) as any) || defaultIcon || false
3632
}
3733

38-
/** When inside the field input, we can open the reference on a child pane */
39-
function DocumentPreviewInInput(props: PropsWithChildren<DocumentPreviewProps>) {
40-
const {ChildLink} = usePaneRouter()
41-
42-
return (linkProps: PropsWithChildren) => (
43-
<ChildLink
44-
childId={props.documentPair.id}
45-
// Pass the schemaType of the document so `paneChild` in `buildPagesStructure` can access it
46-
childParameters={{type: props.documentPair.type}}
47-
>
48-
{linkProps.children}
49-
</ChildLink>
50-
)
51-
}
52-
53-
/** When inside the tool, we must use a regular intent link to take users to the desk tool */
54-
function DocumentPreviewInRool(props: DocumentPreviewProps) {
34+
function DocumentPreviewLink(props: DocumentPreviewProps) {
5535
return (linkProps: PropsWithChildren) => (
5636
<IntentLink intent="edit" params={{id: props.documentPair.id}}>
5737
{linkProps.children}
@@ -90,11 +70,7 @@ export function DocumentPreview(props: DocumentPreviewProps) {
9070
return (
9171
<PreviewCard
9272
__unstable_focusRing
93-
as={
94-
(props.placement === 'input'
95-
? DocumentPreviewInInput(props)
96-
: DocumentPreviewInRool(props)) as FIXME
97-
}
73+
as={DocumentPreviewLink(props) as FIXME}
9874
data-as="a"
9975
data-ui="PaneItem"
10076
padding={2}

0 commit comments

Comments
 (0)