Skip to content

Commit

Permalink
fix(structure): allow sanity.previewUrlSecret in document lists
Browse files Browse the repository at this point in the history
Signed-off-by: Fred Carlsen <fred@sjelfull.no>
  • Loading branch information
sjelfull authored and stipsan committed Feb 14, 2024
1 parent 928eeec commit 8184399
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
7 changes: 4 additions & 3 deletions dev/test-studio/.depcheckignore.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
"//": "https://github.com/depcheck/depcheck/pull/756",
"ignore": [
"https:",
"@portabletext/react",
"@sanity/client",
"@vercel/stega",
"@sanity/visual-editing",
"@sanity/preview-url-secret",
"@sanity/react-loader",
"@portabletext/react"
"@sanity/visual-editing",
"@vercel/stega"
]
}
1 change: 1 addition & 0 deletions dev/test-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@sanity/logos": "^2.1.2",
"@sanity/migrate": "3.29.0",
"@sanity/portable-text-editor": "3.29.0",
"@sanity/preview-url-secret": "^1.6.1",
"@sanity/react-loader": "^1.8.3",
"@sanity/tsdoc": "1.0.0-alpha.38",
"@sanity/types": "3.29.0",
Expand Down
8 changes: 8 additions & 0 deletions dev/test-studio/plugins/router-debug/RouterDebug.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {createPreviewSecret} from '@sanity/preview-url-secret/create-secret'
import {Button, Card, Code, Flex, Stack, Text} from '@sanity/ui'
import {useClient} from 'sanity'
import {IntentLink, RouteScope, StateLink, useRouter, useStateLink} from 'sanity/router'

export function RouterDebug() {
Expand All @@ -11,10 +13,16 @@ export function RouterDebug() {
},
})

const client = useClient()

return (
<Card sizing="border" padding={5}>
<Flex>
<Stack space={4}>
<Button onClick={() => createPreviewSecret(client, 'test-studio', location.href)}>
Create Secret
</Button>

<StateLink state={{}}>Tool home</StateLink>
<StateLink
state={{
Expand Down
2 changes: 2 additions & 0 deletions dev/test-studio/sanity.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {nnNOLocale} from '@sanity/locale-nn-no'
import {ptPTLocale} from '@sanity/locale-pt-pt'
import {svSELocale} from '@sanity/locale-sv-se'
import {SanityMonogram} from '@sanity/logos'
import {debugSecrets} from '@sanity/preview-url-secret/sanity-plugin-debug-secrets'
import {tsdoc} from '@sanity/tsdoc/studio'
import {visionTool} from '@sanity/vision'
import {defineConfig, definePlugin} from 'sanity'
Expand Down Expand Up @@ -284,6 +285,7 @@ export default defineConfig([
projectId: 'ppsg7ml5',
dataset: 'playground',
plugins: [
debugSecrets(),
presentationTool({
previewUrl: '/preview/index.html',
}),
Expand Down
3 changes: 2 additions & 1 deletion packages/sanity/src/core/search/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {isNonNullable} from '../../util/isNonNullable'
const isDocumentType = (type: SchemaType): type is ObjectSchemaType =>
Boolean(type.type && type.type.name === 'document')

const isSanityType = (type: SchemaType): boolean => type.name.startsWith('sanity.')
const isSanityType = (type: SchemaType): boolean =>
type.name.startsWith('sanity.') && type.name !== 'sanity.previewUrlSecret'

/**
* @internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function listenSearchQuery(options: ListenQueryOptions): Observable<Sanit
mergeMap((typeNames: string[]) => {
const types = getSearchTypesWithMaxDepth(
getSearchableTypes(schema).filter((type) => {
return typeNames.includes(type.name) || type.name === 'sanity.previewUrlSecret'
return typeNames.includes(type.name)
}),
maxFieldDepth,
)
Expand Down

0 comments on commit 8184399

Please sign in to comment.