From 3057e2b540c45eb76097dbca56ea5cceee9c4041 Mon Sep 17 00:00:00 2001 From: Snorre Eskeland Brekke Date: Tue, 26 Nov 2024 15:51:28 +0100 Subject: [PATCH 1/4] feat: Start in Create button is now enabled by default (#7884) --- dev/test-create-integration-studio/sanity.config.ts | 3 ++- packages/sanity/src/core/config/prepareConfig.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dev/test-create-integration-studio/sanity.config.ts b/dev/test-create-integration-studio/sanity.config.ts index 146861de727..c63985d74eb 100644 --- a/dev/test-create-integration-studio/sanity.config.ts +++ b/dev/test-create-integration-studio/sanity.config.ts @@ -15,7 +15,8 @@ export default defineConfig({ beta: { create: { - startInCreateEnabled: true, + // defaults to true + //startInCreateEnabled: true, fallbackStudioOrigin: 'create-integration-test.sanity.studio', }, }, diff --git a/packages/sanity/src/core/config/prepareConfig.ts b/packages/sanity/src/core/config/prepareConfig.ts index 7b771f7596c..a24529afbca 100644 --- a/packages/sanity/src/core/config/prepareConfig.ts +++ b/packages/sanity/src/core/config/prepareConfig.ts @@ -660,7 +660,7 @@ function resolveSource({ enabled: false, }, create: { - startInCreateEnabled: startInCreateEnabledReducer({config, initialValue: false}), + startInCreateEnabled: startInCreateEnabledReducer({config, initialValue: true}), fallbackStudioOrigin: createFallbackOriginReducer(config), }, }, From 25eb4f26d8f8359fb94ef1781d61fa0cb07e9c12 Mon Sep 17 00:00:00 2001 From: Snorre Eskeland Brekke Date: Tue, 26 Nov 2024 16:20:57 +0100 Subject: [PATCH 2/4] Revert "feat: Start in Create button is now enabled by default (#7884)" This reverts commit 3057e2b540c45eb76097dbca56ea5cceee9c4041. --- dev/test-create-integration-studio/sanity.config.ts | 3 +-- packages/sanity/src/core/config/prepareConfig.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/dev/test-create-integration-studio/sanity.config.ts b/dev/test-create-integration-studio/sanity.config.ts index c63985d74eb..146861de727 100644 --- a/dev/test-create-integration-studio/sanity.config.ts +++ b/dev/test-create-integration-studio/sanity.config.ts @@ -15,8 +15,7 @@ export default defineConfig({ beta: { create: { - // defaults to true - //startInCreateEnabled: true, + startInCreateEnabled: true, fallbackStudioOrigin: 'create-integration-test.sanity.studio', }, }, diff --git a/packages/sanity/src/core/config/prepareConfig.ts b/packages/sanity/src/core/config/prepareConfig.ts index a24529afbca..7b771f7596c 100644 --- a/packages/sanity/src/core/config/prepareConfig.ts +++ b/packages/sanity/src/core/config/prepareConfig.ts @@ -660,7 +660,7 @@ function resolveSource({ enabled: false, }, create: { - startInCreateEnabled: startInCreateEnabledReducer({config, initialValue: true}), + startInCreateEnabled: startInCreateEnabledReducer({config, initialValue: false}), fallbackStudioOrigin: createFallbackOriginReducer(config), }, }, From 12b308deac438695f23c7ab114e840fb33fccced Mon Sep 17 00:00:00 2001 From: Jordan Lawrence Date: Tue, 26 Nov 2024 17:39:15 +0000 Subject: [PATCH 3/4] fix: when selected perspective is not active, remove perspective from sticky param --- .../src/core/releases/hooks/usePerspective.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/sanity/src/core/releases/hooks/usePerspective.tsx b/packages/sanity/src/core/releases/hooks/usePerspective.tsx index 146a58f2232..47248b456b0 100644 --- a/packages/sanity/src/core/releases/hooks/usePerspective.tsx +++ b/packages/sanity/src/core/releases/hooks/usePerspective.tsx @@ -1,4 +1,4 @@ -import {useCallback, useMemo} from 'react' +import {useCallback, useEffect, useMemo} from 'react' import {useRouter} from 'sanity/router' import {resolveBundlePerspective} from '../../util/resolvePerspective' @@ -50,7 +50,7 @@ const EMPTY_ARRAY: string[] = [] */ export function usePerspective(): PerspectiveValue { const router = useRouter() - const {data: releases} = useReleases() + const {data: releases, archivedReleases} = useReleases() // TODO: Actually validate the perspective value, if it's not a valid perspective, we should fallback to undefined const perspective = router.stickyParams.perspective as | 'published' @@ -84,11 +84,21 @@ export function usePerspective(): PerspectiveValue { const selectedBundle = perspective && releases ? releases.find( - (release: ReleaseDocument) => - `bundle.${getBundleIdFromReleaseDocumentId(release._id)}` === perspective, + (release) => `bundle.${getBundleIdFromReleaseDocumentId(release._id)}` === perspective, ) : LATEST + // clear the perspective param when it is not an active release + useEffect(() => { + if ( + archivedReleases?.find( + (release) => `bundle.${getBundleIdFromReleaseDocumentId(release._id)}` === perspective, + ) + ) { + setPerspective(LATEST._id) + } + }, [archivedReleases, perspective, selectedBundle, setPerspective]) + // TODO: Improve naming; this may not be global. const currentGlobalBundle: CurrentPerspective = useMemo( () => (perspective === 'published' ? perspective : selectedBundle || LATEST), From e1b455e2dabc38214613a802b9120f5b63c98298 Mon Sep 17 00:00:00 2001 From: Jordan Lawrence Date: Tue, 26 Nov 2024 17:55:17 +0000 Subject: [PATCH 4/4] fix: resolving ts error on DocumentStatusLine --- .../panes/document/statusBar/DocumentStatusBar.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/sanity/src/structure/panes/document/statusBar/DocumentStatusBar.tsx b/packages/sanity/src/structure/panes/document/statusBar/DocumentStatusBar.tsx index 7a52efbe547..2f567612e30 100644 --- a/packages/sanity/src/structure/panes/document/statusBar/DocumentStatusBar.tsx +++ b/packages/sanity/src/structure/panes/document/statusBar/DocumentStatusBar.tsx @@ -84,11 +84,7 @@ export function DocumentStatusBar(props: DocumentStatusBarProps) { > - {showingRevision ? ( - - ) : ( - - )} + {showingRevision ? : }