From 507d4255085dfac6cdab5d1763a3ab640566fa21 Mon Sep 17 00:00:00 2001 From: Rita Date: Thu, 7 Nov 2024 14:15:56 +0100 Subject: [PATCH] refactor(sanity): add locked style for document header --- .../core/releases/components/documentHeader/VersionChip.tsx | 5 +++++ .../documentHeader/contextMenu/VersionContextMenu.tsx | 4 +++- .../header/perspective/DocumentPerspectiveList.tsx | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/sanity/src/core/releases/components/documentHeader/VersionChip.tsx b/packages/sanity/src/core/releases/components/documentHeader/VersionChip.tsx index 774f561bb85..4d3199333a1 100644 --- a/packages/sanity/src/core/releases/components/documentHeader/VersionChip.tsx +++ b/packages/sanity/src/core/releases/components/documentHeader/VersionChip.tsx @@ -1,3 +1,4 @@ +import {LockIcon} from '@sanity/icons' import {type BadgeTone, useClickOutsideEvent, useGlobalKeyDown} from '@sanity/ui' import { memo, @@ -47,6 +48,7 @@ export const VersionChip = memo(function VersionChip(props: { onClick: () => void text: string tone: BadgeTone + locked?: boolean contextValues: { documentId: string releases: ReleaseDocument[] @@ -65,6 +67,7 @@ export const VersionChip = memo(function VersionChip(props: { onClick, text, tone, + locked = false, contextValues: { documentId, releases, @@ -174,6 +177,7 @@ export const VersionChip = memo(function VersionChip(props: { text={text} tone={tone} icon={} + iconRight={locked && LockIcon} onContextMenu={handleContextMenu} /> @@ -190,6 +194,7 @@ export const VersionChip = memo(function VersionChip(props: { onCreateRelease={openCreateReleaseDialog} disabled={contextMenuDisabled} onCreateVersion={handleAddVersion} + locked={locked} /> } fallbackPlacements={[]} diff --git a/packages/sanity/src/core/releases/components/documentHeader/contextMenu/VersionContextMenu.tsx b/packages/sanity/src/core/releases/components/documentHeader/contextMenu/VersionContextMenu.tsx index 4dc2a659c62..5b055ef4496 100644 --- a/packages/sanity/src/core/releases/components/documentHeader/contextMenu/VersionContextMenu.tsx +++ b/packages/sanity/src/core/releases/components/documentHeader/contextMenu/VersionContextMenu.tsx @@ -27,6 +27,7 @@ export const VersionContextMenu = memo(function VersionContextMenu(props: { onCreateRelease: () => void onCreateVersion: (targetId: string) => void disabled?: boolean + locked?: boolean }) { const { documentId, @@ -38,6 +39,7 @@ export const VersionContextMenu = memo(function VersionContextMenu(props: { onCreateRelease, onCreateVersion, disabled, + locked, } = props const {t} = useTranslation() const isPublished = isPublishedId(documentId) && !isVersion @@ -98,7 +100,7 @@ export const VersionContextMenu = memo(function VersionContextMenu(props: { icon={TrashIcon} onClick={onDiscard} text={t('release.action.discard-version')} - disabled={disabled} + disabled={disabled || locked} /> )} diff --git a/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/DocumentPerspectiveList.tsx b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/DocumentPerspectiveList.tsx index 28cf13b0aad..efe43d26e8e 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/DocumentPerspectiveList.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/DocumentPerspectiveList.tsx @@ -202,6 +202,7 @@ export const DocumentPerspectiveList = memo(function DocumentPerspectiveList() { onClick={handleBundleChange(release.name)} text={release.metadata.title || t('release.placeholder-untitled-release')} tone={getReleaseTone(release)} + locked={release.state === 'scheduled' || release.state === 'scheduling'} contextValues={{ documentId: displayed?._id || '', menuReleaseId: release._id,