From 42b26e63fa77a618f6af83721d2f7018021c07d2 Mon Sep 17 00:00:00 2001 From: pedrobonamin Date: Wed, 11 Dec 2024 16:09:50 +0100 Subject: [PATCH 1/3] feat(core): add unstable publish to releases --- .../store/createReleaseOperationStore.ts | 10 ++++--- .../ReleasePublishAllButton.tsx | 26 +++++++++++++++---- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/packages/sanity/src/core/releases/store/createReleaseOperationStore.ts b/packages/sanity/src/core/releases/store/createReleaseOperationStore.ts index 7f34340f126..6cdd6889c7e 100644 --- a/packages/sanity/src/core/releases/store/createReleaseOperationStore.ts +++ b/packages/sanity/src/core/releases/store/createReleaseOperationStore.ts @@ -10,7 +10,7 @@ import {getReleaseIdFromReleaseDocumentId, type ReleaseDocument} from '../index' import {type EditableReleaseDocument} from './types' export interface ReleaseOperationsStore { - publishRelease: (releaseId: string) => Promise + publishRelease: (releaseId: string, useUnstableAction?: boolean) => Promise schedule: (releaseId: string, date: Date) => Promise //todo: reschedule: (releaseId: string, newDate: Date) => Promise unschedule: (releaseId: string) => Promise @@ -60,10 +60,12 @@ export function createReleaseOperationsStore(options: { }) } - const handlePublishRelease = (releaseId: string) => + const handlePublishRelease = (releaseId: string, useUnstableAction?: boolean) => requestAction(client, [ { - actionType: 'sanity.action.release.publish', + actionType: useUnstableAction + ? 'sanity.action.release.publish2' + : 'sanity.action.release.publish', releaseId: getReleaseIdFromReleaseDocumentId(releaseId), }, ]) @@ -179,7 +181,7 @@ interface ScheduleApiAction { } interface PublishApiAction { - actionType: 'sanity.action.release.publish' + actionType: 'sanity.action.release.publish' | 'sanity.action.release.publish2' releaseId: string } diff --git a/packages/sanity/src/core/releases/tool/components/releaseCTAButtons/ReleasePublishAllButton.tsx b/packages/sanity/src/core/releases/tool/components/releaseCTAButtons/ReleasePublishAllButton.tsx index 78f9e19ff48..abbd955a433 100644 --- a/packages/sanity/src/core/releases/tool/components/releaseCTAButtons/ReleasePublishAllButton.tsx +++ b/packages/sanity/src/core/releases/tool/components/releaseCTAButtons/ReleasePublishAllButton.tsx @@ -31,9 +31,9 @@ export const ReleasePublishAllButton = ({ const {t} = useTranslation(releasesLocaleNamespace) const perspective = usePerspective() const telemetry = useTelemetry() - const [publishBundleStatus, setPublishBundleStatus] = useState<'idle' | 'confirm' | 'publishing'>( - 'idle', - ) + const [publishBundleStatus, setPublishBundleStatus] = useState< + 'idle' | 'confirm' | 'confirm-2' | 'publishing' + >('idle') const isValidatingDocuments = documents.some(({validation}) => validation.isValidating) const hasDocumentValidationErrors = documents.some(({validation}) => validation.hasError) @@ -44,8 +44,9 @@ export const ReleasePublishAllButton = ({ if (!release) return try { + const useUnstableAction = publishBundleStatus === 'confirm-2' setPublishBundleStatus('publishing') - await publishRelease(release._id) + await publishRelease(release._id, useUnstableAction) telemetry.log(PublishedRelease) toast.push({ closable: true, @@ -85,7 +86,7 @@ export const ReleasePublishAllButton = ({ } finally { setPublishBundleStatus('idle') } - }, [release, publishRelease, telemetry, toast, t, router, perspective]) + }, [release, publishBundleStatus, publishRelease, telemetry, toast, t, router, perspective]) const confirmPublishDialog = useMemo(() => { if (publishBundleStatus === 'idle') return null @@ -150,6 +151,21 @@ export const ReleasePublishAllButton = ({ return ( <> +