Skip to content

Commit 8fb3f7f

Browse files
authored
refactor(core): remove publish2 and confirm-2 (#8685)
1 parent df7bf58 commit 8fb3f7f

File tree

5 files changed

+12
-72
lines changed

5 files changed

+12
-72
lines changed

packages/sanity/src/core/releases/store/__tests__/createReleaseOperationsStore.test.ts

+1-18
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,9 @@ describe('createReleaseOperationsStore', () => {
6363
})
6464
})
6565

66-
it('should publish a release using new publish', async () => {
67-
const store = createStore()
68-
await store.publishRelease('_.releases.release-id', true)
69-
expect(mockClient.request).toHaveBeenCalledWith({
70-
uri: '/data/actions/test-dataset',
71-
method: 'POST',
72-
body: {
73-
actions: [
74-
{
75-
actionType: 'sanity.action.release.publish2',
76-
releaseId: 'release-id',
77-
},
78-
],
79-
},
80-
})
81-
})
82-
8366
it('should publish a release using stable publish', async () => {
8467
const store = createStore()
85-
await store.publishRelease('_.releases.release-id', false)
68+
await store.publishRelease('_.releases.release-id')
8669
expect(mockClient.request).toHaveBeenCalledWith({
8770
uri: '/data/actions/test-dataset',
8871
method: 'POST',

packages/sanity/src/core/releases/store/createReleaseOperationStore.ts

+4-14
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ interface operationsOptions {
1818
skipCrossDatasetValidation?: boolean
1919
}
2020
export interface ReleaseOperationsStore {
21-
publishRelease: (
22-
releaseId: string,
23-
useUnstableAction?: boolean,
24-
opts?: operationsOptions,
25-
) => Promise<void>
21+
publishRelease: (releaseId: string, opts?: operationsOptions) => Promise<void>
2622
schedule: (releaseId: string, date: Date, opts?: operationsOptions) => Promise<void>
2723
//todo: reschedule: (releaseId: string, newDate: Date) => Promise<void>
2824
unschedule: (releaseId: string, opts?: operationsOptions) => Promise<void>
@@ -94,18 +90,12 @@ export function createReleaseOperationsStore(options: {
9490
)
9591
}
9692

97-
const handlePublishRelease = (
98-
releaseId: string,
99-
useUnstableAction?: boolean,
100-
opts?: operationsOptions,
101-
) =>
93+
const handlePublishRelease = (releaseId: string, opts?: operationsOptions) =>
10294
requestAction(
10395
client,
10496
[
10597
{
106-
actionType: useUnstableAction
107-
? 'sanity.action.release.publish2'
108-
: 'sanity.action.release.publish',
98+
actionType: 'sanity.action.release.publish',
10999
releaseId: getReleaseIdFromReleaseDocumentId(releaseId),
110100
},
111101
],
@@ -285,7 +275,7 @@ interface ScheduleApiAction {
285275
}
286276

287277
interface PublishApiAction {
288-
actionType: 'sanity.action.release.publish' | 'sanity.action.release.publish2'
278+
actionType: 'sanity.action.release.publish'
289279
releaseId: string
290280
}
291281

packages/sanity/src/core/releases/tool/components/releaseCTAButtons/ReleasePublishAllButton.tsx

+6-38
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {ToneIcon} from '../../../../../ui-components/toneIcon/ToneIcon'
88
import {Translate, useTranslation} from '../../../../i18n'
99
import {usePerspective} from '../../../../perspective/usePerspective'
1010
import {useSetPerspective} from '../../../../perspective/useSetPerspective'
11-
import {supportsLocalStorage} from '../../../../util/supportsLocalStorage'
1211
import {PublishedRelease} from '../../../__telemetry__/releases.telemetry'
1312
import {releasesLocaleNamespace} from '../../../i18n'
1413
import {isReleaseDocument, type ReleaseDocument} from '../../../index'
@@ -34,16 +33,10 @@ export const ReleasePublishAllButton = ({
3433
const perspective = usePerspective()
3534
const setPerspective = useSetPerspective()
3635
const telemetry = useTelemetry()
37-
const publish2 = useMemo(() => {
38-
if (supportsLocalStorage) {
39-
return localStorage.getItem('publish2') === 'true'
40-
}
41-
return false
42-
}, [])
4336

44-
const [publishBundleStatus, setPublishBundleStatus] = useState<
45-
'idle' | 'confirm' | 'confirm-2' | 'publishing'
46-
>('idle')
37+
const [publishBundleStatus, setPublishBundleStatus] = useState<'idle' | 'confirm' | 'publishing'>(
38+
'idle',
39+
)
4740

4841
const [publishPermission, setPublishPermission] = useState<boolean>(false)
4942

@@ -52,26 +45,19 @@ export const ReleasePublishAllButton = ({
5245

5346
const isPublishButtonDisabled =
5447
disabled || isValidatingDocuments || hasDocumentValidationErrors || !publishPermission
55-
const useUnstableAction = publishBundleStatus === 'confirm-2'
5648

5749
useEffect(() => {
58-
checkWithPermissionGuard(publishRelease, release._id, false).then((hasPermission) =>
50+
checkWithPermissionGuard(publishRelease, release._id).then((hasPermission) =>
5951
setPublishPermission(hasPermission),
6052
)
61-
}, [
62-
checkWithPermissionGuard,
63-
publishRelease,
64-
release._id,
65-
release.metadata.intendedPublishAt,
66-
useUnstableAction,
67-
])
53+
}, [checkWithPermissionGuard, publishRelease, release._id, release.metadata.intendedPublishAt])
6854

6955
const handleConfirmPublishAll = useCallback(async () => {
7056
if (!release) return
7157

7258
try {
7359
setPublishBundleStatus('publishing')
74-
await publishRelease(release._id, useUnstableAction)
60+
await publishRelease(release._id)
7561
telemetry.log(PublishedRelease)
7662
toast.push({
7763
closable: true,
@@ -112,7 +98,6 @@ export const ReleasePublishAllButton = ({
11298
}, [
11399
release,
114100
publishRelease,
115-
useUnstableAction,
116101
telemetry,
117102
toast,
118103
t,
@@ -187,23 +172,6 @@ export const ReleasePublishAllButton = ({
187172

188173
return (
189174
<>
190-
{publish2 && (
191-
<Button
192-
tooltipProps={{
193-
disabled: !isPublishButtonDisabled,
194-
content: publishTooltipContent,
195-
placement: 'bottom',
196-
}}
197-
icon={PublishIcon}
198-
disabled={isPublishButtonDisabled || publishBundleStatus === 'publishing'}
199-
// eslint-disable-next-line @sanity/i18n/no-attribute-string-literals
200-
text={'Unstable Publish'}
201-
onClick={() => setPublishBundleStatus('confirm-2')}
202-
loading={publishBundleStatus === 'publishing'}
203-
data-testid="publish-all-button"
204-
tone="suggest"
205-
/>
206-
)}
207175
<Button
208176
tooltipProps={{
209177
disabled: !isPublishButtonDisabled,

packages/sanity/src/core/releases/tool/detail/ReleaseDashboardDetails.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function ReleaseDashboardDetails({release}: {release: ReleaseDocument}) {
4747
useEffect(() => {
4848
// only run if the release is active
4949
if (isActive) {
50-
checkWithPermissionGuard(publishRelease, release._id, false).then((hasPermission) => {
50+
checkWithPermissionGuard(publishRelease, release._id).then((hasPermission) => {
5151
setShouldDisplayPermissionWarning(!hasPermission)
5252
})
5353

packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseDetail.test.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ describe('after releases have loaded', () => {
267267

268268
expect(useReleaseOperationsMockReturn.publishRelease).toHaveBeenCalledWith(
269269
activeASAPRelease._id,
270-
false,
271270
)
272271
})
273272
})

0 commit comments

Comments
 (0)