From 90c24c8956539a68263763db08bdbfb9b1aa29da Mon Sep 17 00:00:00 2001 From: Pedro Bonamin <46196328+pedrobonamin@users.noreply.github.com> Date: Tue, 9 Jan 2024 13:12:54 +0100 Subject: [PATCH] feat(desk): add __experimental_formPreviewTitle to documents (#5452) * feat(desk): add __experimental_hide_form_title to documents * feat(desk): rename __experimental_hide_form_title to __experimental_form_preview_title * feat(desk): rename to __experimental_formPreviewTitle --- dev/test-studio/schema/playlist.ts | 2 ++ .../@sanity/types/src/schema/definition/type/document.ts | 5 +++++ packages/@sanity/types/src/schema/types.ts | 3 ++- .../document/documentPanel/documentViews/FormHeader.tsx | 8 ++++++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/dev/test-studio/schema/playlist.ts b/dev/test-studio/schema/playlist.ts index 1fd1cbb8821..9d89a777f9a 100644 --- a/dev/test-studio/schema/playlist.ts +++ b/dev/test-studio/schema/playlist.ts @@ -4,6 +4,8 @@ export default defineType({ name: 'playlist', title: 'Playlist', type: 'document', + // eslint-disable-next-line camelcase + __experimental_formPreviewTitle: false, liveEdit: true, fields: [ { diff --git a/packages/@sanity/types/src/schema/definition/type/document.ts b/packages/@sanity/types/src/schema/definition/type/document.ts index 3ccf4593e56..0792addce98 100644 --- a/packages/@sanity/types/src/schema/definition/type/document.ts +++ b/packages/@sanity/types/src/schema/definition/type/document.ts @@ -28,4 +28,9 @@ export interface DocumentDefinition extends Omit { __experimental_search?: {path: string; weight: number; mapWith?: string}[] /** @alpha */ __experimental_omnisearch_visibility?: boolean + /** + * Determines whether the large preview title is displayed in the document pane form + * @alpha + * */ + __experimental_formPreviewTitle?: boolean } diff --git a/packages/@sanity/types/src/schema/types.ts b/packages/@sanity/types/src/schema/types.ts index a62582d409c..48806d81146 100644 --- a/packages/@sanity/types/src/schema/types.ts +++ b/packages/@sanity/types/src/schema/types.ts @@ -380,7 +380,8 @@ export interface ObjectSchemaType extends BaseSchemaType { __experimental_omnisearch_visibility?: boolean /** @alpha */ __experimental_actions?: string[] - + /** @alpha */ + __experimental_formPreviewTitle?: boolean /** * @beta */ diff --git a/packages/sanity/src/structure/panes/document/documentPanel/documentViews/FormHeader.tsx b/packages/sanity/src/structure/panes/document/documentPanel/documentViews/FormHeader.tsx index 29b2b1f9ca4..f6338fb4c49 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/documentViews/FormHeader.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/documentViews/FormHeader.tsx @@ -1,4 +1,4 @@ -import {SchemaType} from '@sanity/types' +import {ObjectSchemaType, SchemaType} from '@sanity/types' import {Heading, Stack, Text} from '@sanity/ui' import {useTranslation} from 'react-i18next' import styled, {css} from 'styled-components' @@ -6,7 +6,7 @@ import {structureLocaleNamespace} from '../../../../i18n' interface DocumentHeaderProps { documentId: string - schemaType: SchemaType + schemaType: ObjectSchemaType title?: string } @@ -61,6 +61,10 @@ export const FormHeader = ({documentId, schemaType, title}: DocumentHeaderProps) const isSingleton = documentId === schemaType.name const {t} = useTranslation(structureLocaleNamespace) + if (schemaType.__experimental_formPreviewTitle === false) { + return null + } + return ( {!isSingleton && (