diff --git a/packages/sanity/src/core/releases/__fixtures__/release.fixture.ts b/packages/sanity/src/core/releases/__fixtures__/release.fixture.ts
index 90aafcc034b..74f64fd6559 100644
--- a/packages/sanity/src/core/releases/__fixtures__/release.fixture.ts
+++ b/packages/sanity/src/core/releases/__fixtures__/release.fixture.ts
@@ -67,11 +67,9 @@ export const publishedASAPRelease: ReleaseDocument = {
_createdAt: '2023-10-10T08:00:00Z',
_updatedAt: '2023-10-10T09:00:00Z',
state: 'published',
- publishAt: '2023-10-10T09:00:00Z',
metadata: {
title: 'published Release',
releaseType: 'asap',
- intendedPublishAt: '2023-10-10T09:00:00Z',
description: 'archived Release description',
},
}
diff --git a/packages/sanity/src/core/releases/i18n/resources.ts b/packages/sanity/src/core/releases/i18n/resources.ts
index 40fa620f7aa..eafb48ec6af 100644
--- a/packages/sanity/src/core/releases/i18n/resources.ts
+++ b/packages/sanity/src/core/releases/i18n/resources.ts
@@ -42,10 +42,6 @@ const releasesLocaleStrings = {
'action.immediate-revert-release': 'Revert now',
/** Label for unarchiving a release */
'action.unarchive': 'Unarchive release',
- /** Header for the dialog confirming the archive of a release */
- 'archive-dialog.confirm-archive-header':
- "Are you sure you want to archive the '{{title}}' release?",
-
/* The text for the activity event when a document is added to a release */
'activity.event.add-document': 'added a document version',
/* The text for the activity event when the release is archived */
@@ -75,6 +71,9 @@ const releasesLocaleStrings = {
/** The title for the activity panel shown in the releases detail screen */
'activity.panel.title': 'Activity',
+ /** Header for the dialog confirming the archive of a release */
+ 'archive-dialog.confirm-archive-header':
+ "Are you sure you want to archive the '{{title}}' release?",
/** Title for the dialog confirming the archive of a release */
'archive-dialog.confirm-archive-title':
"Are you sure you want to archive the '{{title}}' release?",
@@ -91,7 +90,9 @@ const releasesLocaleStrings = {
/** Text for when a release / document was created */
'created': 'Created ',
- /** Text for the releases detail screen when a release was published */
+ /** Text for the releases detail screen when a release was published ASAP */
+ 'dashboard.details.published-asap': 'Published',
+ /** Text for the releases detail screen when a release was published from scheduling */
'dashboard.details.published-on': 'Published on {{date}}',
/** Text for the releases detail screen in the pin release button. */
@@ -304,6 +305,11 @@ const releasesLocaleStrings = {
'toast.unschedule.error': "Failed to unscheduled '{{title}}': {{error}}",
/** Text for toast when release has been unschedule */
'toast.unschedule.success': "The '{{title}}' release was unscheduled.",
+ /** Text for toast when release has been unarchived */
+ 'toast.unarchive.success': "The '{{title}}' release was unarchived.",
+ /** Text for toast when release failed to unarchive */
+ 'toast.unarchive.error': "Failed to unarchive '{{title}}': {{error}}",
+ /** Description for toast when release deletion failed */
/** Text for tooltip when a release has been scheduled */
'type-picker.tooltip.scheduled': 'The release is scheduled, unschedule it to change type',
/** Text for toast when release failed to revert */
diff --git a/packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/ReleaseMenuButton.tsx b/packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/ReleaseMenuButton.tsx
index 13898f9162a..28c08ec93d6 100644
--- a/packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/ReleaseMenuButton.tsx
+++ b/packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/ReleaseMenuButton.tsx
@@ -7,7 +7,7 @@ import {
} from '@sanity/icons'
import {type DefinedTelemetryLog, useTelemetry} from '@sanity/telemetry/react'
import {Menu, Spinner, Text, useToast} from '@sanity/ui'
-import {useCallback, useMemo, useState} from 'react'
+import {type MouseEventHandler, useCallback, useMemo, useState} from 'react'
import {useRouter} from 'sanity/router'
import {Button, Dialog, MenuButton, MenuItem} from '../../../../../ui-components'
@@ -15,6 +15,7 @@ import {Translate, useTranslation} from '../../../../i18n'
import {
ArchivedRelease,
DeletedRelease,
+ UnarchivedRelease,
UnscheduledRelease,
} from '../../../__telemetry__/releases.telemetry'
import {releasesLocaleNamespace} from '../../../i18n'
@@ -32,7 +33,7 @@ export type ReleaseMenuButtonProps = {
release: ReleaseDocument
}
-type ReleaseAction = 'archive' | 'delete' | 'unschedule'
+type ReleaseAction = 'archive' | 'unarchive' | 'delete' | 'unschedule'
interface BaseReleaseActionsMap {
toastSuccessI18nKey: string
@@ -78,6 +79,12 @@ const RELEASE_ACTION_MAP: Record<
toastFailureI18nKey: 'toast.archive.error',
telemetry: ArchivedRelease,
},
+ unarchive: {
+ confirmDialog: false,
+ toastSuccessI18nKey: 'toast.unarchive.success',
+ toastFailureI18nKey: 'toast.unarchive.error',
+ telemetry: UnarchivedRelease,
+ },
unschedule: {
confirmDialog: false,
toastSuccessI18nKey: 'toast.unschedule.success',
@@ -89,7 +96,7 @@ const RELEASE_ACTION_MAP: Record<
export const ReleaseMenuButton = ({ignoreCTA, release}: ReleaseMenuButtonProps) => {
const toast = useToast()
const router = useRouter()
- const {archive, deleteRelease, unschedule} = useReleaseOperations()
+ const {archive, unarchive, deleteRelease, unschedule} = useReleaseOperations()
const {loading: isLoadingReleaseDocuments, results: releaseDocuments} = useBundleDocuments(
getReleaseIdFromReleaseDocumentId(release._id),
)
@@ -116,6 +123,7 @@ export const ReleaseMenuButton = ({ignoreCTA, release}: ReleaseMenuButtonProps)
const actionLookup = {
delete: handleDelete,
archive,
+ unarchive,
unschedule,
}
const actionValues = RELEASE_ACTION_MAP[action]
@@ -160,6 +168,7 @@ export const ReleaseMenuButton = ({ignoreCTA, release}: ReleaseMenuButtonProps)
releaseMenuDisabled,
handleDelete,
archive,
+ unarchive,
unschedule,
release._id,
telemetry,
@@ -169,11 +178,6 @@ export const ReleaseMenuButton = ({ignoreCTA, release}: ReleaseMenuButtonProps)
],
)
- const handleUnarchive = async () => {
- // noop
- // TODO: similar to handleArchive - complete once server action exists
- }
-
const confirmActionDialog = useMemo(() => {
if (!selectedAction) return null
@@ -224,8 +228,10 @@ export const ReleaseMenuButton = ({ignoreCTA, release}: ReleaseMenuButtonProps)
t,
])
- const handleOnInitiateAction = useCallback(
- (action: ReleaseAction) => {
+ const handleOnInitiateAction = useCallback>(
+ (event) => {
+ const action = event.currentTarget.getAttribute('data-value') as ReleaseAction
+
if (releaseDocuments.length > 0 && RELEASE_ACTION_MAP[action].confirmDialog) {
setSelectedAction(action)
} else {
@@ -241,9 +247,8 @@ export const ReleaseMenuButton = ({ignoreCTA, release}: ReleaseMenuButtonProps)
if (release.state === 'archived')
return (