Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(structure): allow sanity.previewUrlSecret in document lists #5733

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.1",
"@sanity/portable-text-editor": "3.29.1",
"@sanity/preview-url-secret": "^1.6.1",
"@sanity/react-loader": "^1.8.3",
"@sanity/tsdoc": "1.0.0-alpha.38",
"@sanity/types": "3.29.1",
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
5 changes: 3 additions & 2 deletions 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 isIgnoredType = (type: SchemaType): boolean =>
type.name.startsWith('sanity.') && type.name !== 'sanity.previewUrlSecret'

/**
* @internal
Expand All @@ -16,4 +17,4 @@ export const getSearchableTypes = (schema: Schema): ObjectSchemaType[] =>
.map((typeName) => schema.get(typeName))
.filter(isNonNullable)
.filter((schemaType) => isDocumentType(schemaType))
.filter((type) => !isSanityType(type)) as ObjectSchemaType[]
.filter((type) => !isIgnoredType(type)) as ObjectSchemaType[]
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
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading