diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 89685003ac6..1b2be812bbd 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -164,7 +164,7 @@ const config = { // Ignore i18n in releases files. TODO: Remove this before moving releases to GA. { - files: ['**/*/core/releases/**/*'], + files: ['**/*/core/releases/**/*', '**/*/core/versions/**/*'], rules: { 'i18next/no-literal-string': 'off', '@sanity/i18n/no-attribute-string-literals': 'off', diff --git a/packages/sanity/src/_singletons/context/VersionContext.tsx b/packages/sanity/src/_singletons/context/VersionContext.tsx index 0c5347a1286..19e98b7376c 100644 --- a/packages/sanity/src/_singletons/context/VersionContext.tsx +++ b/packages/sanity/src/_singletons/context/VersionContext.tsx @@ -4,14 +4,15 @@ // eslint-disable-next-line import/consistent-type-specifier-style import {createContext, type ReactElement} from 'react' -import type {Version} from '../../../core/versions/types' -import {BUNDLES, LATEST} from '../../../core/versions/util/const' +import {useBundlesStore} from '../../../core/store/bundles' +import type {BundleDocument} from '../../../core/store/bundles/types' +import {LATEST} from '../../../core/versions/util/const' import {useRouter} from '../../../router' export interface VersionContextValue { - currentVersion: Version + currentVersion: Partial isDraft: boolean - setCurrentVersion: (version: Version) => void + setCurrentVersion: (bundle: Partial) => void } export const VersionContext = createContext({ @@ -27,7 +28,9 @@ interface VersionProviderProps { export function VersionProvider({children}: VersionProviderProps): JSX.Element { const router = useRouter() - const setCurrentVersion = (version: Version) => { + const {data: bundles} = useBundlesStore() + + const setCurrentVersion = (version: Partial) => { const {name} = version if (name === 'drafts') { router.navigateStickyParam('perspective', '') @@ -35,14 +38,15 @@ export function VersionProvider({children}: VersionProviderProps): JSX.Element { router.navigateStickyParam('perspective', `bundle.${name}`) } } - const selectedVersion = router.stickyParams?.perspective - ? BUNDLES.find((bundle) => { - return ( - `bundle.${bundle.name}`.toLocaleLowerCase() === - router.stickyParams.perspective?.toLocaleLowerCase() - ) - }) - : LATEST + const selectedVersion = + router.stickyParams?.perspective && bundles + ? bundles.find((bundle) => { + return ( + `bundle.${bundle.name}`.toLocaleLowerCase() === + router.stickyParams.perspective?.toLocaleLowerCase() + ) + }) + : LATEST const currentVersion = selectedVersion || LATEST diff --git a/packages/sanity/src/core/releases/components/BundlesTable/BundleRow.tsx b/packages/sanity/src/core/releases/components/BundlesTable/BundleRow.tsx index 0d07558de41..149e13c720f 100644 --- a/packages/sanity/src/core/releases/components/BundlesTable/BundleRow.tsx +++ b/packages/sanity/src/core/releases/components/BundlesTable/BundleRow.tsx @@ -3,7 +3,7 @@ import {RelativeTime} from 'sanity' import {useRouter} from 'sanity/router' import {type BundleDocument} from '../../../store/bundles/types' -import {VersionBadge} from '../../../versions/components/VersionBadge' +import {BundleBadge} from '../../../versions/components/BundleBadge' import {BundleMenuButton} from '../BundleMenuButton/BundleMenuButton' type Props = { @@ -26,7 +26,7 @@ export function BundleRow({bundle}: Props) { > - + diff --git a/packages/sanity/src/core/store/bundles/__workshop__/BundlesStoreStory.tsx b/packages/sanity/src/core/store/bundles/__workshop__/BundlesStoreStory.tsx index 8e482dda7d4..240173ec6e7 100644 --- a/packages/sanity/src/core/store/bundles/__workshop__/BundlesStoreStory.tsx +++ b/packages/sanity/src/core/store/bundles/__workshop__/BundlesStoreStory.tsx @@ -4,10 +4,10 @@ import {type ComponentType, type FormEvent, useCallback, useState} from 'react' import {Button} from '../../../../ui-components' import {LoadingBlock} from '../../../components/loadingBlock/LoadingBlock' import {AddonDatasetProvider} from '../../../studio/addonDataset/AddonDatasetProvider' +import {BundleForm} from '../../../versions/components/dialog/BundleForm' import {BundlesProvider, useBundles} from '../BundlesProvider' import {type BundleDocument} from '../types' import {useBundleOperations} from '../useBundleOperations' -import {ReleaseForm} from './ReleaseForm' const WithAddonDatasetProvider =

(Component: ComponentType

): React.FC

=> { const WrappedComponent: React.FC

= (props) => ( @@ -66,7 +66,7 @@ const BundlesStoreStory = () => {

Create a new release - +