diff --git a/dev/test-studio/sanity.config.ts b/dev/test-studio/sanity.config.ts index 8b85fb5ead5..273b3b42da4 100644 --- a/dev/test-studio/sanity.config.ts +++ b/dev/test-studio/sanity.config.ts @@ -153,7 +153,7 @@ const sharedSettings = definePlugin({ ], }) -const defaultWorkspace = { +const defaultWorkspace = defineConfig({ name: 'default', title: 'Test Studio', projectId: 'ppsg7ml5', @@ -179,7 +179,7 @@ const defaultWorkspace = { tasks: { enabled: true, }, -} +}) export default defineConfig([ defaultWorkspace, diff --git a/packages/sanity/src/core/config/configPropertyReducers.ts b/packages/sanity/src/core/config/configPropertyReducers.ts index ce9c2d888cf..1fcc613e510 100644 --- a/packages/sanity/src/core/config/configPropertyReducers.ts +++ b/packages/sanity/src/core/config/configPropertyReducers.ts @@ -364,6 +364,29 @@ export const internalTasksReducer = (opts: { return result } +export const serverDocumentActionsReducer = (opts: { + config: PluginOptions + initialValue: boolean | undefined +}): boolean | undefined => { + const {config, initialValue} = opts + const flattenedConfig = flattenConfig(config, []) + + const result = flattenedConfig.reduce((acc: boolean | undefined, {config: innerConfig}) => { + const enabled = innerConfig.__internal_serverDocumentActions?.enabled + + if (typeof enabled === 'undefined') return acc + if (typeof enabled === 'boolean') return enabled + + throw new Error( + `Expected \`__internal_serverDocumentActions\` to be a boolean, but received ${getPrintableType( + enabled, + )}`, + ) + }, initialValue) + + return result +} + export const partialIndexingEnabledReducer = (opts: { config: PluginOptions initialValue: boolean diff --git a/packages/sanity/src/core/config/prepareConfig.tsx b/packages/sanity/src/core/config/prepareConfig.tsx index a85c9d74cc5..f9b7c4966c2 100644 --- a/packages/sanity/src/core/config/prepareConfig.tsx +++ b/packages/sanity/src/core/config/prepareConfig.tsx @@ -39,6 +39,7 @@ import { resolveProductionUrlReducer, schemaTemplatesReducer, searchStrategyReducer, + serverDocumentActionsReducer, startInCreateEnabledReducer, toolsReducer, } from './configPropertyReducers' @@ -209,8 +210,6 @@ export function prepareConfig( __internal: { sources: resolvedSources, }, - // eslint-disable-next-line camelcase - __internal_serverDocumentActions: rawWorkspace.__internal_serverDocumentActions, ...defaultPluginsOptions, } preparedWorkspaces.set(rawWorkspace, workspaceSummary) @@ -655,6 +654,10 @@ function resolveSource({ fallbackStudioOrigin: createFallbackOriginReducer(config), }, }, + // eslint-disable-next-line camelcase + __internal_serverDocumentActions: { + enabled: serverDocumentActionsReducer({config, initialValue: undefined}), + }, announcements: { enabled: announcementsEnabledReducer({config, initialValue: true}), diff --git a/packages/sanity/src/core/config/types.ts b/packages/sanity/src/core/config/types.ts index f41df2bdfd8..656de9a7c94 100644 --- a/packages/sanity/src/core/config/types.ts +++ b/packages/sanity/src/core/config/types.ts @@ -407,6 +407,9 @@ export interface PluginOptions { enableLegacySearch?: boolean } + /** @internal */ + __internal_serverDocumentActions?: WorkspaceOptions['__internal_serverDocumentActions'] + /** Configuration for studio beta features. * @internal */ @@ -862,7 +865,6 @@ export interface WorkspaceSummary extends DefaultPluginsWorkspaceOptions { source: Observable }> } - __internal_serverDocumentActions: WorkspaceOptions['__internal_serverDocumentActions'] } /**