From 3eae7e74741887036949b1db9d35eb93c5e18190 Mon Sep 17 00:00:00 2001 From: Jordan Lawrence Date: Wed, 11 Sep 2024 14:45:55 +0100 Subject: [PATCH 01/10] chore(releases): moving releases/components to releases/tool/components --- .../_singletons/context/ReleasesTableContext.ts | 2 +- .../core/releases/{ => tool}/components/Chip.tsx | 0 .../components/ReleaseDocumentPreview.tsx | 10 +++++----- .../ReleaseMenuButton/ReleaseMenuButton.tsx | 14 +++++++------- .../__tests__/ReleaseMenuButton.test.tsx | 10 +++++----- .../ReleasePublishAllButton.tsx | 12 ++++++------ .../useObserveDocumentRevisions.ts | 0 .../releases/{ => tool}/components/Table/Table.tsx | 4 ++-- .../{ => tool}/components/Table/TableHeader.tsx | 2 +- .../{ => tool}/components/Table/TableProvider.tsx | 0 .../releases/{ => tool}/components/Table/types.ts | 0 .../core/releases/tool/detail/ReleaseDetail.tsx | 4 ++-- .../core/releases/tool/detail/ReleaseSummary.tsx | 4 ++-- .../tool/detail/__tests__/ReleaseDetail.test.tsx | 2 +- .../documentTable/DocumentTableColumnDefs.tsx | 6 +++--- .../tool/detail/review/DocumentReviewHeader.tsx | 4 ++-- .../releases/tool/overview/ReleasesOverview.tsx | 6 +++--- .../tool/overview/ReleasesOverviewColumnDefs.tsx | 6 +++--- 18 files changed, 43 insertions(+), 43 deletions(-) rename packages/sanity/src/core/releases/{ => tool}/components/Chip.tsx (100%) rename packages/sanity/src/core/releases/{ => tool}/components/ReleaseDocumentPreview.tsx (88%) rename packages/sanity/src/core/releases/{ => tool}/components/ReleaseMenuButton/ReleaseMenuButton.tsx (92%) rename packages/sanity/src/core/releases/{ => tool}/components/ReleaseMenuButton/__tests__/ReleaseMenuButton.test.tsx (93%) rename packages/sanity/src/core/releases/{ => tool}/components/ReleasePublishAllButton/ReleasePublishAllButton.tsx (91%) rename packages/sanity/src/core/releases/{ => tool}/components/ReleasePublishAllButton/useObserveDocumentRevisions.ts (100%) rename packages/sanity/src/core/releases/{ => tool}/components/Table/Table.tsx (98%) rename packages/sanity/src/core/releases/{ => tool}/components/Table/TableHeader.tsx (96%) rename packages/sanity/src/core/releases/{ => tool}/components/Table/TableProvider.tsx (100%) rename packages/sanity/src/core/releases/{ => tool}/components/Table/types.ts (100%) diff --git a/packages/sanity/src/_singletons/context/ReleasesTableContext.ts b/packages/sanity/src/_singletons/context/ReleasesTableContext.ts index 8d35e73535b..64f9023bb61 100644 --- a/packages/sanity/src/_singletons/context/ReleasesTableContext.ts +++ b/packages/sanity/src/_singletons/context/ReleasesTableContext.ts @@ -1,6 +1,6 @@ import {createContext} from 'sanity/_createContext' -import type {TableContextValue} from '../../core/releases/components/Table/TableProvider' +import type {TableContextValue} from '../../core/releases/tool/components/Table/TableProvider' /** * @internal diff --git a/packages/sanity/src/core/releases/components/Chip.tsx b/packages/sanity/src/core/releases/tool/components/Chip.tsx similarity index 100% rename from packages/sanity/src/core/releases/components/Chip.tsx rename to packages/sanity/src/core/releases/tool/components/Chip.tsx diff --git a/packages/sanity/src/core/releases/components/ReleaseDocumentPreview.tsx b/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx similarity index 88% rename from packages/sanity/src/core/releases/components/ReleaseDocumentPreview.tsx rename to packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx index 132b6b25b09..f6502b9c6fa 100644 --- a/packages/sanity/src/core/releases/components/ReleaseDocumentPreview.tsx +++ b/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx @@ -5,11 +5,11 @@ import {type ForwardedRef, forwardRef, useMemo} from 'react' import {DocumentPreviewPresence, useDocumentPresence} from 'sanity' import {IntentLink} from 'sanity/router' -import {Tooltip} from '../../../ui-components' -import {useTranslation} from '../../i18n' -import {SanityDefaultPreview} from '../../preview/components/SanityDefaultPreview' -import {getPublishedId} from '../../util/draftUtils' -import {releasesLocaleNamespace} from '../i18n' +import {Tooltip} from '../../../../ui-components' +import {useTranslation} from '../../../i18n' +import {SanityDefaultPreview} from '../../../preview/components/SanityDefaultPreview' +import {getPublishedId} from '../../../util/draftUtils' +import {releasesLocaleNamespace} from '../../i18n' interface ReleaseDocumentPreviewProps { documentId: string diff --git a/packages/sanity/src/core/releases/components/ReleaseMenuButton/ReleaseMenuButton.tsx b/packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/ReleaseMenuButton.tsx similarity index 92% rename from packages/sanity/src/core/releases/components/ReleaseMenuButton/ReleaseMenuButton.tsx rename to packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/ReleaseMenuButton.tsx index 8b0485c2ff8..e923859c91e 100644 --- a/packages/sanity/src/core/releases/components/ReleaseMenuButton/ReleaseMenuButton.tsx +++ b/packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/ReleaseMenuButton.tsx @@ -10,17 +10,17 @@ import {Menu, Spinner, Text, useToast} from '@sanity/ui' import {useState} from 'react' import {useRouter} from 'sanity/router' -import {Button, Dialog, MenuButton, MenuItem} from '../../../../ui-components' +import {Button, Dialog, MenuButton, MenuItem} from '../../../../../ui-components' import { ArchivedRelease, DeletedRelease, UnarchivedRelease, -} from '../../../bundles/__telemetry__/releases.telemetry' -import {ReleaseDetailsDialog} from '../../../bundles/components/dialog/ReleaseDetailsDialog' -import {Translate, useTranslation} from '../../../i18n' -import {type BundleDocument} from '../../../store/bundles/types' -import {useBundleOperations} from '../../../store/bundles/useBundleOperations' -import {releasesLocaleNamespace} from '../../i18n' +} from '../../../../bundles/__telemetry__/releases.telemetry' +import {ReleaseDetailsDialog} from '../../../../bundles/components/dialog/ReleaseDetailsDialog' +import {Translate, useTranslation} from '../../../../i18n' +import {type BundleDocument} from '../../../../store/bundles/types' +import {useBundleOperations} from '../../../../store/bundles/useBundleOperations' +import {releasesLocaleNamespace} from '../../../i18n' export type ReleaseMenuButtonProps = { disabled?: boolean diff --git a/packages/sanity/src/core/releases/components/ReleaseMenuButton/__tests__/ReleaseMenuButton.test.tsx b/packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/__tests__/ReleaseMenuButton.test.tsx similarity index 93% rename from packages/sanity/src/core/releases/components/ReleaseMenuButton/__tests__/ReleaseMenuButton.test.tsx rename to packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/__tests__/ReleaseMenuButton.test.tsx index 24e715510ad..cf45f419b83 100644 --- a/packages/sanity/src/core/releases/components/ReleaseMenuButton/__tests__/ReleaseMenuButton.test.tsx +++ b/packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/__tests__/ReleaseMenuButton.test.tsx @@ -3,17 +3,17 @@ import {fireEvent, render, screen} from '@testing-library/react' import {act} from 'react' import {useRouter} from 'sanity/router' -import {createTestProvider} from '../../../../../../test/testUtils/TestProvider' -import {type BundleDocument} from '../../../../store/bundles/types' -import {useBundleOperations} from '../../../../store/bundles/useBundleOperations' -import {releasesUsEnglishLocaleBundle} from '../../../i18n' +import {createTestProvider} from '../../../../../../../test/testUtils/TestProvider' +import {type BundleDocument} from '../../../../../store/bundles/types' +import {useBundleOperations} from '../../../../../store/bundles/useBundleOperations' +import {releasesUsEnglishLocaleBundle} from '../../../../i18n' import {ReleaseMenuButton, type ReleaseMenuButtonProps} from '../ReleaseMenuButton' jest.mock('sanity', () => ({ useTranslation: jest.fn().mockReturnValue({t: jest.fn()}), })) -jest.mock('../../../../store/bundles/useBundleOperations', () => ({ +jest.mock('../../../../../store/bundles/useBundleOperations', () => ({ useBundleOperations: jest.fn().mockReturnValue({ deleteBundle: jest.fn(), updateBundle: jest.fn(), diff --git a/packages/sanity/src/core/releases/components/ReleasePublishAllButton/ReleasePublishAllButton.tsx b/packages/sanity/src/core/releases/tool/components/ReleasePublishAllButton/ReleasePublishAllButton.tsx similarity index 91% rename from packages/sanity/src/core/releases/components/ReleasePublishAllButton/ReleasePublishAllButton.tsx rename to packages/sanity/src/core/releases/tool/components/ReleasePublishAllButton/ReleasePublishAllButton.tsx index b9f65f16c2f..b242dd64cd5 100644 --- a/packages/sanity/src/core/releases/components/ReleasePublishAllButton/ReleasePublishAllButton.tsx +++ b/packages/sanity/src/core/releases/tool/components/ReleasePublishAllButton/ReleasePublishAllButton.tsx @@ -4,12 +4,12 @@ import {Flex, Text, useToast} from '@sanity/ui' import {useCallback, useMemo, useState} from 'react' import {type BundleDocument} from 'sanity' -import {Button, Dialog} from '../../../../ui-components' -import {PublishedRelease} from '../../../bundles/__telemetry__/releases.telemetry' -import {Translate, useTranslation} from '../../../i18n' -import {useBundleOperations} from '../../../store/bundles/useBundleOperations' -import {releasesLocaleNamespace} from '../../i18n' -import {type DocumentInBundleResult} from '../../tool/detail/useBundleDocuments' +import {Button, Dialog} from '../../../../../ui-components' +import {PublishedRelease} from '../../../../bundles/__telemetry__/releases.telemetry' +import {Translate, useTranslation} from '../../../../i18n' +import {useBundleOperations} from '../../../../store/bundles/useBundleOperations' +import {releasesLocaleNamespace} from '../../../i18n' +import {type DocumentInBundleResult} from '../../../tool/detail/useBundleDocuments' import {useObserveDocumentRevisions} from './useObserveDocumentRevisions' interface ReleasePublishAllButtonProps { diff --git a/packages/sanity/src/core/releases/components/ReleasePublishAllButton/useObserveDocumentRevisions.ts b/packages/sanity/src/core/releases/tool/components/ReleasePublishAllButton/useObserveDocumentRevisions.ts similarity index 100% rename from packages/sanity/src/core/releases/components/ReleasePublishAllButton/useObserveDocumentRevisions.ts rename to packages/sanity/src/core/releases/tool/components/ReleasePublishAllButton/useObserveDocumentRevisions.ts diff --git a/packages/sanity/src/core/releases/components/Table/Table.tsx b/packages/sanity/src/core/releases/tool/components/Table/Table.tsx similarity index 98% rename from packages/sanity/src/core/releases/components/Table/Table.tsx rename to packages/sanity/src/core/releases/tool/components/Table/Table.tsx index 7478c1a5665..0d65198931d 100644 --- a/packages/sanity/src/core/releases/components/Table/Table.tsx +++ b/packages/sanity/src/core/releases/tool/components/Table/Table.tsx @@ -17,8 +17,8 @@ import { } from 'react' import {styled} from 'styled-components' -import {TooltipDelayGroupProvider} from '../../../../ui-components' -import {LoadingBlock} from '../../../components' +import {TooltipDelayGroupProvider} from '../../../../../ui-components' +import {LoadingBlock} from '../../../../components' import {TableHeader} from './TableHeader' import {TableProvider, type TableSort, useTableContext} from './TableProvider' import {type Column} from './types' diff --git a/packages/sanity/src/core/releases/components/Table/TableHeader.tsx b/packages/sanity/src/core/releases/tool/components/Table/TableHeader.tsx similarity index 96% rename from packages/sanity/src/core/releases/components/Table/TableHeader.tsx rename to packages/sanity/src/core/releases/tool/components/Table/TableHeader.tsx index 620eebfa2ad..ef73a358fec 100644 --- a/packages/sanity/src/core/releases/components/Table/TableHeader.tsx +++ b/packages/sanity/src/core/releases/tool/components/Table/TableHeader.tsx @@ -1,7 +1,7 @@ import {ArrowDownIcon, ArrowUpIcon, SearchIcon} from '@sanity/icons' import {Card, Flex, Stack, TextInput} from '@sanity/ui' -import {Button, type ButtonProps} from '../../../../ui-components' +import {Button, type ButtonProps} from '../../../../../ui-components' import {useTableContext} from './TableProvider' import {type HeaderProps, type TableHeaderProps} from './types' diff --git a/packages/sanity/src/core/releases/components/Table/TableProvider.tsx b/packages/sanity/src/core/releases/tool/components/Table/TableProvider.tsx similarity index 100% rename from packages/sanity/src/core/releases/components/Table/TableProvider.tsx rename to packages/sanity/src/core/releases/tool/components/Table/TableProvider.tsx diff --git a/packages/sanity/src/core/releases/components/Table/types.ts b/packages/sanity/src/core/releases/tool/components/Table/types.ts similarity index 100% rename from packages/sanity/src/core/releases/components/Table/types.ts rename to packages/sanity/src/core/releases/tool/components/Table/types.ts diff --git a/packages/sanity/src/core/releases/tool/detail/ReleaseDetail.tsx b/packages/sanity/src/core/releases/tool/detail/ReleaseDetail.tsx index 768e01585ad..64568bcebdb 100644 --- a/packages/sanity/src/core/releases/tool/detail/ReleaseDetail.tsx +++ b/packages/sanity/src/core/releases/tool/detail/ReleaseDetail.tsx @@ -7,10 +7,10 @@ import {type RouterContextValue, useRouter} from 'sanity/router' import {Button} from '../../../../ui-components' import {Translate, useTranslation} from '../../../i18n' import {useBundles} from '../../../store/bundles' -import {ReleaseMenuButton} from '../../components/ReleaseMenuButton/ReleaseMenuButton' -import {ReleasePublishAllButton} from '../../components/ReleasePublishAllButton/ReleasePublishAllButton' import {releasesLocaleNamespace} from '../../i18n' import {type ReleasesRouterState} from '../../types/router' +import {ReleaseMenuButton} from '../components/ReleaseMenuButton/ReleaseMenuButton' +import {ReleasePublishAllButton} from '../components/ReleasePublishAllButton/ReleasePublishAllButton' import {useReleaseHistory} from './documentTable/useReleaseHistory' import {ReleaseReview} from './ReleaseReview' import {ReleaseSummary} from './ReleaseSummary' diff --git a/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx b/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx index fc85fb86b81..f89429effed 100644 --- a/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx +++ b/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx @@ -11,9 +11,9 @@ import {UserAvatar} from '../../../components/userAvatar/UserAvatar' import {Translate, useTranslation} from '../../../i18n' import {type BundleDocument} from '../../../store/bundles/types' import {useBundleOperations} from '../../../store/bundles/useBundleOperations' -import {Chip} from '../../components/Chip' -import {Table, type TableProps} from '../../components/Table/Table' import {releasesLocaleNamespace} from '../../i18n' +import {Chip} from '../components/Chip' +import {Table, type TableProps} from '../components/Table/Table' import {DocumentActions} from './documentTable/DocumentActions' import {getDocumentTableColumnDefs} from './documentTable/DocumentTableColumnDefs' import {type DocumentHistory} from './documentTable/useReleaseHistory' diff --git a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseDetail.test.tsx b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseDetail.test.tsx index 55a36a852a2..380eccd5e1d 100644 --- a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseDetail.test.tsx +++ b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseDetail.test.tsx @@ -32,7 +32,7 @@ jest.mock('sanity', () => ({ useTranslation: jest.fn().mockReturnValue({t: jest.fn()}), })) -jest.mock('../../../components/ReleasePublishAllButton/useObserveDocumentRevisions', () => ({ +jest.mock('../../components/ReleasePublishAllButton/useObserveDocumentRevisions', () => ({ useObserveDocumentRevisions: jest.fn().mockReturnValue({ '123': 'mock revision id', }), diff --git a/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx b/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx index 94f3c5c60cb..6b0abd90b73 100644 --- a/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx +++ b/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx @@ -3,9 +3,9 @@ import {memo} from 'react' import {type TFunction, UserAvatar} from 'sanity' import {RelativeTime} from '../../../../components/RelativeTime' -import {ReleaseDocumentPreview} from '../../../components/ReleaseDocumentPreview' -import {Headers} from '../../../components/Table/TableHeader' -import {type Column} from '../../../components/Table/types' +import {ReleaseDocumentPreview} from '../../components/ReleaseDocumentPreview' +import {Headers} from '../../components/Table/TableHeader' +import {type Column} from '../../components/Table/types' import {type BundleDocumentRow} from '../ReleaseSummary' import {type DocumentInBundleResult} from '../useBundleDocuments' diff --git a/packages/sanity/src/core/releases/tool/detail/review/DocumentReviewHeader.tsx b/packages/sanity/src/core/releases/tool/detail/review/DocumentReviewHeader.tsx index 2dd171ee6b6..3b33e4b7342 100644 --- a/packages/sanity/src/core/releases/tool/detail/review/DocumentReviewHeader.tsx +++ b/packages/sanity/src/core/releases/tool/detail/review/DocumentReviewHeader.tsx @@ -6,9 +6,9 @@ import {Translate, useTranslation} from 'sanity' import {Button} from '../../../../../ui-components' import {RelativeTime} from '../../../../components/RelativeTime' import {UserAvatar} from '../../../../components/userAvatar/UserAvatar' -import {Chip} from '../../../components/Chip' -import {ReleaseDocumentPreview} from '../../../components/ReleaseDocumentPreview' import {releasesLocaleNamespace} from '../../../i18n' +import {Chip} from '../../components/Chip' +import {ReleaseDocumentPreview} from '../../components/ReleaseDocumentPreview' import {type DocumentValidationStatus} from '../useBundleDocuments' export function DocumentReviewHeader({ diff --git a/packages/sanity/src/core/releases/tool/overview/ReleasesOverview.tsx b/packages/sanity/src/core/releases/tool/overview/ReleasesOverview.tsx index 98233ae6bd2..e93d024f589 100644 --- a/packages/sanity/src/core/releases/tool/overview/ReleasesOverview.tsx +++ b/packages/sanity/src/core/releases/tool/overview/ReleasesOverview.tsx @@ -7,11 +7,11 @@ import {Button, Button as StudioButton} from '../../../../ui-components' import {ReleaseDetailsDialog} from '../../../bundles/components/dialog/ReleaseDetailsDialog' import {useTranslation} from '../../../i18n' import {type BundleDocument, useBundles} from '../../../store' -import {ReleaseMenuButton} from '../../components/ReleaseMenuButton/ReleaseMenuButton' -import {Table, type TableProps} from '../../components/Table/Table' -import {type TableSort} from '../../components/Table/TableProvider' import {releasesLocaleNamespace} from '../../i18n' import {containsBundles} from '../../types/bundle' +import {ReleaseMenuButton} from '../components/ReleaseMenuButton/ReleaseMenuButton' +import {Table, type TableProps} from '../components/Table/Table' +import {type TableSort} from '../components/Table/TableProvider' import {type BundlesMetadata, useBundlesMetadata} from '../useBundlesMetadata' import {releasesOverviewColumnDefs} from './ReleasesOverviewColumnDefs' diff --git a/packages/sanity/src/core/releases/tool/overview/ReleasesOverviewColumnDefs.tsx b/packages/sanity/src/core/releases/tool/overview/ReleasesOverviewColumnDefs.tsx index 9bf6263c364..adf92f21f7d 100644 --- a/packages/sanity/src/core/releases/tool/overview/ReleasesOverviewColumnDefs.tsx +++ b/packages/sanity/src/core/releases/tool/overview/ReleasesOverviewColumnDefs.tsx @@ -5,10 +5,10 @@ import {useRouter} from 'sanity/router' import {Tooltip} from '../../../../ui-components' import {ReleaseBadge} from '../../../bundles' import {RelativeTime, UserAvatar} from '../../../components' -import {type TableRowProps} from '../../components/Table/Table' -import {Headers} from '../../components/Table/TableHeader' -import {type Column} from '../../components/Table/types' import {releasesLocaleNamespace} from '../../i18n' +import {type TableRowProps} from '../components/Table/Table' +import {Headers} from '../components/Table/TableHeader' +import {type Column} from '../components/Table/types' import {type TableBundle} from './ReleasesOverview' const ReleaseNameCell: Column['cell'] = ({cellProps, datum: bundle}) => { From 3ba98840c0bc2907c7b7049116c21a82837866b3 Mon Sep 17 00:00:00 2001 From: Jordan Lawrence Date: Wed, 11 Sep 2024 15:14:20 +0100 Subject: [PATCH 02/10] chore(releases): moving bundles/components to releases/components --- packages/sanity/src/core/bundles/index.ts | 1 - .../components/ReleaseBadge.tsx | 0 .../components/ReleasesMenu.tsx | 6 +++--- .../components/__tests__/ReleasesMenu.test.tsx | 8 ++++---- .../components/dialog/ReleaseDetailsDialog.tsx | 10 +++++----- .../components/dialog/ReleaseForm.tsx | 0 .../dialog/ReleaseIconEditorPicker.tsx | 0 .../__tests__/ReleaseDetailsDialog.test.tsx | 4 ++-- .../dialog/__tests__/ReleaseForm.test.tsx | 0 .../__tests__/ReleaseIconEditorPicker.test.tsx | 0 .../{bundles => releases}/components/index.ts | 0 .../components/panes/ReleaseActions.tsx | 2 +- .../ReleaseMenuButton/ReleaseMenuButton.tsx | 2 +- .../core/releases/tool/detail/ReleaseSummary.tsx | 8 ++++---- .../tool/detail/__tests__/ReleaseReview.test.tsx | 2 +- .../detail/__tests__/ReleaseSummary.test.tsx | 2 +- .../releases/tool/overview/ReleasesOverview.tsx | 2 +- .../tool/overview/ReleasesOverviewColumnDefs.tsx | 2 +- .../navbar/perspective/GlobalPerspectiveMenu.tsx | 6 +++--- .../perspective/DocumentPerspectiveMenu.tsx | 9 ++------- .../__tests__}/DocumentHeaderTitle.test.tsx | 16 ++++++++-------- .../__tests__/DocumentPerspectiveMenu.test.tsx | 2 +- 22 files changed, 38 insertions(+), 44 deletions(-) rename packages/sanity/src/core/{bundles => releases}/components/ReleaseBadge.tsx (100%) rename packages/sanity/src/core/{bundles => releases}/components/ReleasesMenu.tsx (97%) rename packages/sanity/src/core/{bundles => releases}/components/__tests__/ReleasesMenu.test.tsx (97%) rename packages/sanity/src/core/{bundles => releases}/components/dialog/ReleaseDetailsDialog.tsx (94%) rename packages/sanity/src/core/{bundles => releases}/components/dialog/ReleaseForm.tsx (100%) rename packages/sanity/src/core/{bundles => releases}/components/dialog/ReleaseIconEditorPicker.tsx (100%) rename packages/sanity/src/core/{bundles => releases}/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx (97%) rename packages/sanity/src/core/{bundles => releases}/components/dialog/__tests__/ReleaseForm.test.tsx (100%) rename packages/sanity/src/core/{bundles => releases}/components/dialog/__tests__/ReleaseIconEditorPicker.test.tsx (100%) rename packages/sanity/src/core/{bundles => releases}/components/index.ts (100%) rename packages/sanity/src/core/{bundles => releases}/components/panes/ReleaseActions.tsx (98%) rename packages/sanity/src/structure/panes/document/documentPanel/header/{ => perspective/__tests__}/DocumentHeaderTitle.test.tsx (91%) diff --git a/packages/sanity/src/core/bundles/index.ts b/packages/sanity/src/core/bundles/index.ts index e0b00846683..0e98b141969 100644 --- a/packages/sanity/src/core/bundles/index.ts +++ b/packages/sanity/src/core/bundles/index.ts @@ -1,4 +1,3 @@ -export * from './components' export * from './hooks' export * from './util/const' export * from './util/util' diff --git a/packages/sanity/src/core/bundles/components/ReleaseBadge.tsx b/packages/sanity/src/core/releases/components/ReleaseBadge.tsx similarity index 100% rename from packages/sanity/src/core/bundles/components/ReleaseBadge.tsx rename to packages/sanity/src/core/releases/components/ReleaseBadge.tsx diff --git a/packages/sanity/src/core/bundles/components/ReleasesMenu.tsx b/packages/sanity/src/core/releases/components/ReleasesMenu.tsx similarity index 97% rename from packages/sanity/src/core/bundles/components/ReleasesMenu.tsx rename to packages/sanity/src/core/releases/components/ReleasesMenu.tsx index 84ea89f21bf..aff20843690 100644 --- a/packages/sanity/src/core/bundles/components/ReleasesMenu.tsx +++ b/packages/sanity/src/core/releases/components/ReleasesMenu.tsx @@ -5,12 +5,12 @@ import {memo, type ReactElement, useCallback, useMemo} from 'react' import {styled} from 'styled-components' import {MenuButton, Tooltip} from '../../../ui-components' +import {usePerspective} from '../../bundles/hooks' +import {LATEST} from '../../bundles/util/const' +import {isDraftOrPublished} from '../../bundles/util/util' import {useTranslation} from '../../i18n' import {type BundleDocument} from '../../store/bundles/types' import {useBundles} from '../../store/bundles/useBundles' -import {usePerspective} from '../hooks' -import {LATEST} from '../util/const' -import {isDraftOrPublished} from '../util/util' import {ReleaseBadge} from './ReleaseBadge' const StyledMenu = styled(Menu)` diff --git a/packages/sanity/src/core/bundles/components/__tests__/ReleasesMenu.test.tsx b/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx similarity index 97% rename from packages/sanity/src/core/bundles/components/__tests__/ReleasesMenu.test.tsx rename to packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx index 27a8816fb9e..5aae16ea49a 100644 --- a/packages/sanity/src/core/bundles/components/__tests__/ReleasesMenu.test.tsx +++ b/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx @@ -6,18 +6,18 @@ import {type BundleDocument, useBundles} from 'sanity' import {createTestProvider} from '../../../../../test/testUtils/TestProvider' import {Button} from '../../../../ui-components' -import {usePerspective} from '../../hooks/usePerspective' -import {LATEST} from '../../util/const' +import {usePerspective} from '../../../bundles/hooks/usePerspective' +import {LATEST} from '../../../bundles/util/const' import {ReleasesMenu} from '../ReleasesMenu' -jest.mock('../../hooks/usePerspective', () => ({ +jest.mock('../../../bundles/hooks/usePerspective', () => ({ usePerspective: jest.fn().mockReturnValue({ currentGlobalBundle: {}, setPerspective: jest.fn(), }), })) -jest.mock('../../util/util', () => ({ +jest.mock('../../../bundles/util/util', () => ({ isDraftOrPublished: jest.fn(), })) diff --git a/packages/sanity/src/core/bundles/components/dialog/ReleaseDetailsDialog.tsx b/packages/sanity/src/core/releases/components/dialog/ReleaseDetailsDialog.tsx similarity index 94% rename from packages/sanity/src/core/bundles/components/dialog/ReleaseDetailsDialog.tsx rename to packages/sanity/src/core/releases/components/dialog/ReleaseDetailsDialog.tsx index 6a0f8524d25..0f32cd1308c 100644 --- a/packages/sanity/src/core/bundles/components/dialog/ReleaseDetailsDialog.tsx +++ b/packages/sanity/src/core/releases/components/dialog/ReleaseDetailsDialog.tsx @@ -5,15 +5,15 @@ import {type FormEvent, useCallback, useState} from 'react' import {type FormBundleDocument, useTranslation} from 'sanity' import {Button, Dialog} from '../../../../ui-components' -import {type BundleDocument} from '../../../store/bundles/types' -import {useBundleOperations} from '../../../store/bundles/useBundleOperations' import { CreatedRelease, type OriginInfo, UpdatedRelease, -} from '../../__telemetry__/releases.telemetry' -import {usePerspective} from '../../hooks/usePerspective' -import {createReleaseId} from '../../util/createReleaseId' +} from '../../../bundles/__telemetry__/releases.telemetry' +import {usePerspective} from '../../../bundles/hooks/usePerspective' +import {createReleaseId} from '../../../bundles/util/createReleaseId' +import {type BundleDocument} from '../../../store/bundles/types' +import {useBundleOperations} from '../../../store/bundles/useBundleOperations' import {ReleaseForm} from './ReleaseForm' interface ReleaseDetailsDialogProps { diff --git a/packages/sanity/src/core/bundles/components/dialog/ReleaseForm.tsx b/packages/sanity/src/core/releases/components/dialog/ReleaseForm.tsx similarity index 100% rename from packages/sanity/src/core/bundles/components/dialog/ReleaseForm.tsx rename to packages/sanity/src/core/releases/components/dialog/ReleaseForm.tsx diff --git a/packages/sanity/src/core/bundles/components/dialog/ReleaseIconEditorPicker.tsx b/packages/sanity/src/core/releases/components/dialog/ReleaseIconEditorPicker.tsx similarity index 100% rename from packages/sanity/src/core/bundles/components/dialog/ReleaseIconEditorPicker.tsx rename to packages/sanity/src/core/releases/components/dialog/ReleaseIconEditorPicker.tsx diff --git a/packages/sanity/src/core/bundles/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx b/packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx similarity index 97% rename from packages/sanity/src/core/bundles/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx rename to packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx index 64e664f0cea..aa1958b442d 100644 --- a/packages/sanity/src/core/bundles/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx +++ b/packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx @@ -3,8 +3,8 @@ import {fireEvent, render, screen, waitFor, within} from '@testing-library/react import {type BundleDocument, useBundles} from 'sanity' import {createTestProvider} from '../../../../../../test/testUtils/TestProvider' +import {usePerspective} from '../../../../bundles/hooks/usePerspective' import {useBundleOperations} from '../../../../store/bundles/useBundleOperations' -import {usePerspective} from '../../../hooks/usePerspective' import {ReleaseDetailsDialog} from '../ReleaseDetailsDialog' /*jest.mock('../../../../../core/hooks/useDateTimeFormat', () => ({ @@ -22,7 +22,7 @@ jest.mock('../../../../store/bundles/useBundleOperations', () => ({ }), })) -jest.mock('../../../hooks/usePerspective', () => ({ +jest.mock('../../../../bundles/hooks/usePerspective', () => ({ usePerspective: jest.fn().mockReturnValue({ setPerspective: jest.fn(), }), diff --git a/packages/sanity/src/core/bundles/components/dialog/__tests__/ReleaseForm.test.tsx b/packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseForm.test.tsx similarity index 100% rename from packages/sanity/src/core/bundles/components/dialog/__tests__/ReleaseForm.test.tsx rename to packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseForm.test.tsx diff --git a/packages/sanity/src/core/bundles/components/dialog/__tests__/ReleaseIconEditorPicker.test.tsx b/packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseIconEditorPicker.test.tsx similarity index 100% rename from packages/sanity/src/core/bundles/components/dialog/__tests__/ReleaseIconEditorPicker.test.tsx rename to packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseIconEditorPicker.test.tsx diff --git a/packages/sanity/src/core/bundles/components/index.ts b/packages/sanity/src/core/releases/components/index.ts similarity index 100% rename from packages/sanity/src/core/bundles/components/index.ts rename to packages/sanity/src/core/releases/components/index.ts diff --git a/packages/sanity/src/core/bundles/components/panes/ReleaseActions.tsx b/packages/sanity/src/core/releases/components/panes/ReleaseActions.tsx similarity index 98% rename from packages/sanity/src/core/bundles/components/panes/ReleaseActions.tsx rename to packages/sanity/src/core/releases/components/panes/ReleaseActions.tsx index bbc7a6c29c0..a3cd4172849 100644 --- a/packages/sanity/src/core/bundles/components/panes/ReleaseActions.tsx +++ b/packages/sanity/src/core/releases/components/panes/ReleaseActions.tsx @@ -17,8 +17,8 @@ import { } from 'sanity' import {Button} from '../../../../ui-components' +import {AddedVersion} from '../../../bundles/__telemetry__/releases.telemetry' import {type BundleDocument} from '../../../store/bundles/types' -import {AddedVersion} from '../../__telemetry__/releases.telemetry' interface ReleaseActionsProps { currentGlobalBundle: BundleDocument 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 e923859c91e..67acd5601d5 100644 --- a/packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/ReleaseMenuButton.tsx +++ b/packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/ReleaseMenuButton.tsx @@ -16,10 +16,10 @@ import { DeletedRelease, UnarchivedRelease, } from '../../../../bundles/__telemetry__/releases.telemetry' -import {ReleaseDetailsDialog} from '../../../../bundles/components/dialog/ReleaseDetailsDialog' import {Translate, useTranslation} from '../../../../i18n' import {type BundleDocument} from '../../../../store/bundles/types' import {useBundleOperations} from '../../../../store/bundles/useBundleOperations' +import {ReleaseDetailsDialog} from '../../../components/dialog/ReleaseDetailsDialog' import {releasesLocaleNamespace} from '../../../i18n' export type ReleaseMenuButtonProps = { diff --git a/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx b/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx index f89429effed..06ededa46ee 100644 --- a/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx +++ b/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx @@ -2,15 +2,15 @@ import {DocumentsIcon} from '@sanity/icons' import {AvatarStack, Box, Flex, Heading, Stack, Text, useToast} from '@sanity/ui' import {type RefObject, useCallback, useEffect, useMemo, useState} from 'react' -import { - ReleaseIconEditorPicker, - type ReleaseIconEditorPickerValue, -} from '../../../bundles/components/dialog/ReleaseIconEditorPicker' import {RelativeTime} from '../../../components/RelativeTime' import {UserAvatar} from '../../../components/userAvatar/UserAvatar' import {Translate, useTranslation} from '../../../i18n' import {type BundleDocument} from '../../../store/bundles/types' import {useBundleOperations} from '../../../store/bundles/useBundleOperations' +import { + ReleaseIconEditorPicker, + type ReleaseIconEditorPickerValue, +} from '../../components/dialog/ReleaseIconEditorPicker' import {releasesLocaleNamespace} from '../../i18n' import {Chip} from '../components/Chip' import {Table, type TableProps} from '../components/Table/Table' diff --git a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx index 4d9226ff358..fc7cd250dda 100644 --- a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx +++ b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx @@ -131,7 +131,7 @@ jest.mock('sanity/router', () => ({ }), })) -jest.mock('../../../../bundles/components/ReleasesMenu', () => ({ +jest.mock('../../../components/ReleasesMenu', () => ({ ReleasesMenu: () =>
ReleasesMenu
, })) diff --git a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx index 4d16bf0136c..67f858fd06c 100644 --- a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx +++ b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx @@ -23,7 +23,7 @@ jest.mock('../../../../user-color', () => ({ useUserColor: jest.fn().mockReturnValue('red'), })) -jest.mock('../../../../bundles/components/ReleasesMenu', () => ({ +jest.mock('../../../components/ReleasesMenu', () => ({ ReleasesMenu: () =>
ReleasesMenu
, })) diff --git a/packages/sanity/src/core/releases/tool/overview/ReleasesOverview.tsx b/packages/sanity/src/core/releases/tool/overview/ReleasesOverview.tsx index e93d024f589..cccb44ba505 100644 --- a/packages/sanity/src/core/releases/tool/overview/ReleasesOverview.tsx +++ b/packages/sanity/src/core/releases/tool/overview/ReleasesOverview.tsx @@ -4,9 +4,9 @@ import {isBefore} from 'date-fns' import {type MouseEventHandler, useCallback, useEffect, useMemo, useRef, useState} from 'react' import {Button, Button as StudioButton} from '../../../../ui-components' -import {ReleaseDetailsDialog} from '../../../bundles/components/dialog/ReleaseDetailsDialog' import {useTranslation} from '../../../i18n' import {type BundleDocument, useBundles} from '../../../store' +import {ReleaseDetailsDialog} from '../../components/dialog/ReleaseDetailsDialog' import {releasesLocaleNamespace} from '../../i18n' import {containsBundles} from '../../types/bundle' import {ReleaseMenuButton} from '../components/ReleaseMenuButton/ReleaseMenuButton' diff --git a/packages/sanity/src/core/releases/tool/overview/ReleasesOverviewColumnDefs.tsx b/packages/sanity/src/core/releases/tool/overview/ReleasesOverviewColumnDefs.tsx index adf92f21f7d..d55c81e087e 100644 --- a/packages/sanity/src/core/releases/tool/overview/ReleasesOverviewColumnDefs.tsx +++ b/packages/sanity/src/core/releases/tool/overview/ReleasesOverviewColumnDefs.tsx @@ -3,8 +3,8 @@ import {type TFunction, Translate, useTranslation} from 'sanity' import {useRouter} from 'sanity/router' import {Tooltip} from '../../../../ui-components' -import {ReleaseBadge} from '../../../bundles' import {RelativeTime, UserAvatar} from '../../../components' +import {ReleaseBadge} from '../../components/ReleaseBadge' import {releasesLocaleNamespace} from '../../i18n' import {type TableRowProps} from '../components/Table/Table' import {Headers} from '../components/Table/TableHeader' diff --git a/packages/sanity/src/core/studio/components/navbar/perspective/GlobalPerspectiveMenu.tsx b/packages/sanity/src/core/studio/components/navbar/perspective/GlobalPerspectiveMenu.tsx index 3fb7550c32e..8670f83ebce 100644 --- a/packages/sanity/src/core/studio/components/navbar/perspective/GlobalPerspectiveMenu.tsx +++ b/packages/sanity/src/core/studio/components/navbar/perspective/GlobalPerspectiveMenu.tsx @@ -5,10 +5,10 @@ import {useCallback, useMemo, useState} from 'react' import {useTranslation} from 'sanity' import {MenuItem} from '../../../../../ui-components' -import {ReleaseDetailsDialog} from '../../../../bundles/components/dialog/ReleaseDetailsDialog' -import {ReleaseBadge} from '../../../../bundles/components/ReleaseBadge' -import {ReleasesMenu} from '../../../../bundles/components/ReleasesMenu' import {usePerspective} from '../../../../bundles/hooks/usePerspective' +import {ReleaseDetailsDialog} from '../../../../releases/components/dialog/ReleaseDetailsDialog' +import {ReleaseBadge} from '../../../../releases/components/ReleaseBadge' +import {ReleasesMenu} from '../../../../releases/components/ReleasesMenu' import {useBundles} from '../../../../store/bundles' export function GlobalPerspectiveMenu(): JSX.Element { diff --git a/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/DocumentPerspectiveMenu.tsx b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/DocumentPerspectiveMenu.tsx index 43422c38fe2..6d279529dc4 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/DocumentPerspectiveMenu.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/DocumentPerspectiveMenu.tsx @@ -4,16 +4,11 @@ import {Box, Button} from '@sanity/ui' // eslint-disable-next-line camelcase import {getTheme_v2} from '@sanity/ui/theme' import {memo, useMemo} from 'react' -import { - type BundleDocument, - ReleaseBadge, - ReleasesMenu, - usePerspective, - useTranslation, -} from 'sanity' +import {type BundleDocument, usePerspective, useTranslation} from 'sanity' import {IntentLink} from 'sanity/router' import {css, styled} from 'styled-components' +import {ReleaseBadge, ReleasesMenu} from '../../../../../../core/releases/components' import {Button as StudioButton} from '../../../../../../ui-components' import {usePaneRouter} from '../../../../../components' import {useDocumentPane} from '../../../useDocumentPane' diff --git a/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.test.tsx b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentHeaderTitle.test.tsx similarity index 91% rename from packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.test.tsx rename to packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentHeaderTitle.test.tsx index adaa472e521..6ae083755b0 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.test.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentHeaderTitle.test.tsx @@ -9,12 +9,12 @@ import { } from 'sanity' import {useRouter} from 'sanity/router' -import {createMockSanityClient} from '../../../../../../test/mocks/mockSanityClient' -import {createTestProvider} from '../../../../../../test/testUtils/TestProvider' -import {structureUsEnglishLocaleBundle} from '../../../../i18n' -import {type DocumentPaneContextValue} from '../../DocumentPaneContext' -import {useDocumentPane} from '../../useDocumentPane' -import {DocumentHeaderTitle} from './DocumentHeaderTitle' +import {createMockSanityClient} from '../../../../../../../../test/mocks/mockSanityClient' +import {createTestProvider} from '../../../../../../../../test/testUtils/TestProvider' +import {structureUsEnglishLocaleBundle} from '../../../../../../i18n' +import {type DocumentPaneContextValue} from '../../../../DocumentPaneContext' +import {useDocumentPane} from '../../../../useDocumentPane' +import {DocumentHeaderTitle} from '../../DocumentHeaderTitle' function createWrapperComponent(client: SanityClient) { const config = defineConfig({ @@ -29,7 +29,7 @@ function createWrapperComponent(client: SanityClient) { }) } -jest.mock('../../useDocumentPane') +jest.mock('../../../../useDocumentPane') jest.mock('sanity', () => { // eslint-disable-next-line @typescript-eslint/consistent-type-imports @@ -43,7 +43,7 @@ jest.mock('sanity', () => { jest.mock('sanity/router') -jest.mock('../../../../../core/store/bundles/useBundles', () => ({ +jest.mock('../../../../../../../core/store/bundles/useBundles', () => ({ useBundles: jest.fn(), })) diff --git a/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentPerspectiveMenu.test.tsx b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentPerspectiveMenu.test.tsx index 987fe8588c0..7476efe06e4 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentPerspectiveMenu.test.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentPerspectiveMenu.test.tsx @@ -80,7 +80,7 @@ describe('DocumentPerspectiveMenu', () => { }) }) - it('should render the bundle badge if the document exists in the global bundle', async () => { + it.only('should render the bundle badge if the document exists in the global bundle', async () => { mockUseDocumentPane.mockReturnValue({ documentVersions: [ { From 6e16a0a11e555f324c787ee9b3268d1fcb86a1b1 Mon Sep 17 00:00:00 2001 From: Jordan Lawrence Date: Wed, 11 Sep 2024 15:58:37 +0100 Subject: [PATCH 03/10] chore(releases): moving bundles/hooks to releases/hooks --- packages/sanity/src/core/bundles/index.ts | 1 - packages/sanity/src/core/index.ts | 12 +++--------- .../core/preview/components/SanityDefaultPreview.tsx | 1 + .../src/core/releases/components/ReleasesMenu.tsx | 2 +- .../components/__tests__/ReleasesMenu.test.tsx | 4 ++-- .../components/dialog/ReleaseDetailsDialog.tsx | 2 +- .../dialog/__tests__/ReleaseDetailsDialog.test.tsx | 4 ++-- .../hooks/__tests__/useDocumentVersions.test.tsx | 0 .../src/core/{bundles => releases}/hooks/index.ts | 0 .../hooks/useDocumentVersions.tsx | 0 .../{bundles => releases}/hooks/usePerspective.tsx | 2 +- .../tool/components/ReleaseDocumentPreview.tsx | 2 ++ .../src/core/releases/tool/detail/ReleaseSummary.tsx | 2 ++ .../tool/detail/__tests__/ReleaseSummary.test.tsx | 2 +- .../detail/documentTable/DocumentTableColumnDefs.tsx | 1 + .../navbar/perspective/GlobalPerspectiveMenu.tsx | 2 +- .../__tests__/DeletedDocumentBanners.test.tsx | 2 +- 17 files changed, 19 insertions(+), 20 deletions(-) rename packages/sanity/src/core/{bundles => releases}/hooks/__tests__/useDocumentVersions.test.tsx (100%) rename packages/sanity/src/core/{bundles => releases}/hooks/index.ts (100%) rename packages/sanity/src/core/{bundles => releases}/hooks/useDocumentVersions.tsx (100%) rename packages/sanity/src/core/{bundles => releases}/hooks/usePerspective.tsx (97%) diff --git a/packages/sanity/src/core/bundles/index.ts b/packages/sanity/src/core/bundles/index.ts index 0e98b141969..2828dfc1cf2 100644 --- a/packages/sanity/src/core/bundles/index.ts +++ b/packages/sanity/src/core/bundles/index.ts @@ -1,3 +1,2 @@ -export * from './hooks' export * from './util/const' export * from './util/util' diff --git a/packages/sanity/src/core/index.ts b/packages/sanity/src/core/index.ts index 9f60475c962..73e217dcd57 100644 --- a/packages/sanity/src/core/index.ts +++ b/packages/sanity/src/core/index.ts @@ -1,12 +1,4 @@ -export { - getDocumentIsInPerspective, - LATEST, - ReleaseActions, - ReleaseBadge, - ReleasesMenu, - useDocumentVersions, - usePerspective, -} from './bundles' +export {getDocumentIsInPerspective, LATEST} from './bundles' export * from './changeIndicators' export { CommentInput, @@ -30,6 +22,8 @@ export * from './hooks' export * from './i18n' export * from './presence' export * from './preview' +export {ReleaseActions, ReleaseBadge, ReleasesMenu} from './releases/components' +export {useDocumentVersions, usePerspective} from './releases/hooks' export * from './scheduledPublishing' export * from './schema' export type {SearchFactoryOptions, SearchOptions, SearchSort, SearchTerms} from './search' diff --git a/packages/sanity/src/core/preview/components/SanityDefaultPreview.tsx b/packages/sanity/src/core/preview/components/SanityDefaultPreview.tsx index 247e059e083..4968f4e17d9 100644 --- a/packages/sanity/src/core/preview/components/SanityDefaultPreview.tsx +++ b/packages/sanity/src/core/preview/components/SanityDefaultPreview.tsx @@ -122,6 +122,7 @@ export function SanityDefaultPreview(props: SanityDefaultPreviewProps): ReactEle const layoutComponent = _previewComponents[layout || 'default'] + console.log('MICHAEL', _previewComponents, layout) const children = createElement( layoutComponent as ComponentType>, previewProps, diff --git a/packages/sanity/src/core/releases/components/ReleasesMenu.tsx b/packages/sanity/src/core/releases/components/ReleasesMenu.tsx index aff20843690..afe6613fb85 100644 --- a/packages/sanity/src/core/releases/components/ReleasesMenu.tsx +++ b/packages/sanity/src/core/releases/components/ReleasesMenu.tsx @@ -5,12 +5,12 @@ import {memo, type ReactElement, useCallback, useMemo} from 'react' import {styled} from 'styled-components' import {MenuButton, Tooltip} from '../../../ui-components' -import {usePerspective} from '../../bundles/hooks' import {LATEST} from '../../bundles/util/const' import {isDraftOrPublished} from '../../bundles/util/util' import {useTranslation} from '../../i18n' import {type BundleDocument} from '../../store/bundles/types' import {useBundles} from '../../store/bundles/useBundles' +import {usePerspective} from '../hooks' import {ReleaseBadge} from './ReleaseBadge' const StyledMenu = styled(Menu)` diff --git a/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx b/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx index 5aae16ea49a..bc750767a98 100644 --- a/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx +++ b/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx @@ -6,11 +6,11 @@ import {type BundleDocument, useBundles} from 'sanity' import {createTestProvider} from '../../../../../test/testUtils/TestProvider' import {Button} from '../../../../ui-components' -import {usePerspective} from '../../../bundles/hooks/usePerspective' import {LATEST} from '../../../bundles/util/const' +import {usePerspective} from '../../hooks' import {ReleasesMenu} from '../ReleasesMenu' -jest.mock('../../../bundles/hooks/usePerspective', () => ({ +jest.mock('../../hooks', () => ({ usePerspective: jest.fn().mockReturnValue({ currentGlobalBundle: {}, setPerspective: jest.fn(), diff --git a/packages/sanity/src/core/releases/components/dialog/ReleaseDetailsDialog.tsx b/packages/sanity/src/core/releases/components/dialog/ReleaseDetailsDialog.tsx index 0f32cd1308c..1611a47498d 100644 --- a/packages/sanity/src/core/releases/components/dialog/ReleaseDetailsDialog.tsx +++ b/packages/sanity/src/core/releases/components/dialog/ReleaseDetailsDialog.tsx @@ -10,10 +10,10 @@ import { type OriginInfo, UpdatedRelease, } from '../../../bundles/__telemetry__/releases.telemetry' -import {usePerspective} from '../../../bundles/hooks/usePerspective' import {createReleaseId} from '../../../bundles/util/createReleaseId' import {type BundleDocument} from '../../../store/bundles/types' import {useBundleOperations} from '../../../store/bundles/useBundleOperations' +import {usePerspective} from '../../hooks' import {ReleaseForm} from './ReleaseForm' interface ReleaseDetailsDialogProps { diff --git a/packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx b/packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx index aa1958b442d..8d4dcc6ec54 100644 --- a/packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx +++ b/packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx @@ -3,8 +3,8 @@ import {fireEvent, render, screen, waitFor, within} from '@testing-library/react import {type BundleDocument, useBundles} from 'sanity' import {createTestProvider} from '../../../../../../test/testUtils/TestProvider' -import {usePerspective} from '../../../../bundles/hooks/usePerspective' import {useBundleOperations} from '../../../../store/bundles/useBundleOperations' +import {usePerspective} from '../../../hooks' import {ReleaseDetailsDialog} from '../ReleaseDetailsDialog' /*jest.mock('../../../../../core/hooks/useDateTimeFormat', () => ({ @@ -22,7 +22,7 @@ jest.mock('../../../../store/bundles/useBundleOperations', () => ({ }), })) -jest.mock('../../../../bundles/hooks/usePerspective', () => ({ +jest.mock('../../../hooks', () => ({ usePerspective: jest.fn().mockReturnValue({ setPerspective: jest.fn(), }), diff --git a/packages/sanity/src/core/bundles/hooks/__tests__/useDocumentVersions.test.tsx b/packages/sanity/src/core/releases/hooks/__tests__/useDocumentVersions.test.tsx similarity index 100% rename from packages/sanity/src/core/bundles/hooks/__tests__/useDocumentVersions.test.tsx rename to packages/sanity/src/core/releases/hooks/__tests__/useDocumentVersions.test.tsx diff --git a/packages/sanity/src/core/bundles/hooks/index.ts b/packages/sanity/src/core/releases/hooks/index.ts similarity index 100% rename from packages/sanity/src/core/bundles/hooks/index.ts rename to packages/sanity/src/core/releases/hooks/index.ts diff --git a/packages/sanity/src/core/bundles/hooks/useDocumentVersions.tsx b/packages/sanity/src/core/releases/hooks/useDocumentVersions.tsx similarity index 100% rename from packages/sanity/src/core/bundles/hooks/useDocumentVersions.tsx rename to packages/sanity/src/core/releases/hooks/useDocumentVersions.tsx diff --git a/packages/sanity/src/core/bundles/hooks/usePerspective.tsx b/packages/sanity/src/core/releases/hooks/usePerspective.tsx similarity index 97% rename from packages/sanity/src/core/bundles/hooks/usePerspective.tsx rename to packages/sanity/src/core/releases/hooks/usePerspective.tsx index b9618b1ada5..51d10526496 100644 --- a/packages/sanity/src/core/bundles/hooks/usePerspective.tsx +++ b/packages/sanity/src/core/releases/hooks/usePerspective.tsx @@ -1,8 +1,8 @@ import {useRouter} from 'sanity/router' +import {LATEST} from '../../bundles' import {useBundles} from '../../store/bundles' import {type BundleDocument} from '../../store/bundles/types' -import {LATEST} from '../util/const' /** * @internal diff --git a/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx b/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx index f6502b9c6fa..7106e1618f2 100644 --- a/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx +++ b/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx @@ -31,6 +31,8 @@ export function ReleaseDocumentPreview({ const documentPresence = useDocumentPresence(documentId) const {t} = useTranslation(releasesLocaleNamespace) + console.log('JOJAMES', SanityDefaultPreview) + const LinkComponent = useMemo( () => // eslint-disable-next-line @typescript-eslint/no-shadow diff --git a/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx b/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx index 06ededa46ee..bf6a2df7b0b 100644 --- a/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx +++ b/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx @@ -101,6 +101,8 @@ export function ReleaseSummary(props: ReleaseSummaryProps) { [], ) + console.log({documentTableColumnDefs}) + return ( <> diff --git a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx index 67f858fd06c..39798344146 100644 --- a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx +++ b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx @@ -56,7 +56,7 @@ const releaseDocuments: DocumentInBundleResult[] = [ }, }, { - memoKey: 'key123', + memoKey: 'key456', document: { _id: '456', _type: 'document', diff --git a/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx b/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx index 6b0abd90b73..fe0dc93e0db 100644 --- a/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx +++ b/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx @@ -17,6 +17,7 @@ const MemoReleaseDocumentPreview = memo( item: DocumentInBundleResult releaseSlug: string }) { + console.log('BANANAS', ReleaseDocumentPreview) return ( ({ useDocumentPane: jest.fn(), })) -jest.mock('../../../../../../core/bundles/hooks/usePerspective', () => ({ +jest.mock('../../../../../../core/releases/hooks/usePerspective', () => ({ usePerspective: jest.fn(), })) From d580e56e2d05399d86f1cd4be7b6958959cf8eb5 Mon Sep 17 00:00:00 2001 From: Jordan Lawrence Date: Thu, 12 Sep 2024 10:39:44 +0100 Subject: [PATCH 04/10] chore(releases): moving rest of bundles to releases --- packages/sanity/src/core/index.ts | 2 +- .../src/core/preview/components/SanityDefaultPreview.tsx | 1 - .../src/core/preview/components/_previewComponents.ts | 2 ++ .../__telemetry__/releases.telemetry.ts | 0 .../sanity/src/core/releases/components/ReleasesMenu.tsx | 4 ++-- .../releases/components/__tests__/ReleasesMenu.test.tsx | 4 ++-- .../releases/components/dialog/ReleaseDetailsDialog.tsx | 8 ++++---- .../src/core/releases/components/panes/ReleaseActions.tsx | 2 +- .../sanity/src/core/releases/hooks/usePerspective.tsx | 2 +- packages/sanity/src/core/{bundles => releases}/index.ts | 2 ++ .../components/ReleaseMenuButton/ReleaseMenuButton.tsx | 8 ++++---- .../ReleasePublishAllButton/ReleasePublishAllButton.tsx | 2 +- .../src/core/releases/tool/detail/ReleaseSummary.tsx | 2 -- .../sanity/src/core/{bundles => releases}/util/const.ts | 0 .../core/{bundles => releases}/util/createReleaseId.ts | 0 .../src/core/{bundles => releases}/util/util.test.ts | 0 .../sanity/src/core/{bundles => releases}/util/util.ts | 0 17 files changed, 20 insertions(+), 19 deletions(-) rename packages/sanity/src/core/{bundles => releases}/__telemetry__/releases.telemetry.ts (100%) rename packages/sanity/src/core/{bundles => releases}/index.ts (51%) rename packages/sanity/src/core/{bundles => releases}/util/const.ts (100%) rename packages/sanity/src/core/{bundles => releases}/util/createReleaseId.ts (100%) rename packages/sanity/src/core/{bundles => releases}/util/util.test.ts (100%) rename packages/sanity/src/core/{bundles => releases}/util/util.ts (100%) diff --git a/packages/sanity/src/core/index.ts b/packages/sanity/src/core/index.ts index 73e217dcd57..ace7a4f8f18 100644 --- a/packages/sanity/src/core/index.ts +++ b/packages/sanity/src/core/index.ts @@ -1,4 +1,3 @@ -export {getDocumentIsInPerspective, LATEST} from './bundles' export * from './changeIndicators' export { CommentInput, @@ -22,6 +21,7 @@ export * from './hooks' export * from './i18n' export * from './presence' export * from './preview' +export {getDocumentIsInPerspective, LATEST} from './releases' export {ReleaseActions, ReleaseBadge, ReleasesMenu} from './releases/components' export {useDocumentVersions, usePerspective} from './releases/hooks' export * from './scheduledPublishing' diff --git a/packages/sanity/src/core/preview/components/SanityDefaultPreview.tsx b/packages/sanity/src/core/preview/components/SanityDefaultPreview.tsx index 4968f4e17d9..247e059e083 100644 --- a/packages/sanity/src/core/preview/components/SanityDefaultPreview.tsx +++ b/packages/sanity/src/core/preview/components/SanityDefaultPreview.tsx @@ -122,7 +122,6 @@ export function SanityDefaultPreview(props: SanityDefaultPreviewProps): ReactEle const layoutComponent = _previewComponents[layout || 'default'] - console.log('MICHAEL', _previewComponents, layout) const children = createElement( layoutComponent as ComponentType>, previewProps, diff --git a/packages/sanity/src/core/preview/components/_previewComponents.ts b/packages/sanity/src/core/preview/components/_previewComponents.ts index ec878b3f305..8c64e2b82f7 100644 --- a/packages/sanity/src/core/preview/components/_previewComponents.ts +++ b/packages/sanity/src/core/preview/components/_previewComponents.ts @@ -8,6 +8,8 @@ import { MediaPreview, } from '../../components' +console.log('_PREVCOMP', DefaultPreview) + export const _previewComponents = { block: BlockPreview, blockImage: BlockImagePreview, diff --git a/packages/sanity/src/core/bundles/__telemetry__/releases.telemetry.ts b/packages/sanity/src/core/releases/__telemetry__/releases.telemetry.ts similarity index 100% rename from packages/sanity/src/core/bundles/__telemetry__/releases.telemetry.ts rename to packages/sanity/src/core/releases/__telemetry__/releases.telemetry.ts diff --git a/packages/sanity/src/core/releases/components/ReleasesMenu.tsx b/packages/sanity/src/core/releases/components/ReleasesMenu.tsx index afe6613fb85..84ea89f21bf 100644 --- a/packages/sanity/src/core/releases/components/ReleasesMenu.tsx +++ b/packages/sanity/src/core/releases/components/ReleasesMenu.tsx @@ -5,12 +5,12 @@ import {memo, type ReactElement, useCallback, useMemo} from 'react' import {styled} from 'styled-components' import {MenuButton, Tooltip} from '../../../ui-components' -import {LATEST} from '../../bundles/util/const' -import {isDraftOrPublished} from '../../bundles/util/util' import {useTranslation} from '../../i18n' import {type BundleDocument} from '../../store/bundles/types' import {useBundles} from '../../store/bundles/useBundles' import {usePerspective} from '../hooks' +import {LATEST} from '../util/const' +import {isDraftOrPublished} from '../util/util' import {ReleaseBadge} from './ReleaseBadge' const StyledMenu = styled(Menu)` diff --git a/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx b/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx index bc750767a98..b414b544132 100644 --- a/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx +++ b/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx @@ -6,8 +6,8 @@ import {type BundleDocument, useBundles} from 'sanity' import {createTestProvider} from '../../../../../test/testUtils/TestProvider' import {Button} from '../../../../ui-components' -import {LATEST} from '../../../bundles/util/const' import {usePerspective} from '../../hooks' +import {LATEST} from '../../util/const' import {ReleasesMenu} from '../ReleasesMenu' jest.mock('../../hooks', () => ({ @@ -17,7 +17,7 @@ jest.mock('../../hooks', () => ({ }), })) -jest.mock('../../../bundles/util/util', () => ({ +jest.mock('../..//util/util', () => ({ isDraftOrPublished: jest.fn(), })) diff --git a/packages/sanity/src/core/releases/components/dialog/ReleaseDetailsDialog.tsx b/packages/sanity/src/core/releases/components/dialog/ReleaseDetailsDialog.tsx index 1611a47498d..7bb892e0932 100644 --- a/packages/sanity/src/core/releases/components/dialog/ReleaseDetailsDialog.tsx +++ b/packages/sanity/src/core/releases/components/dialog/ReleaseDetailsDialog.tsx @@ -5,15 +5,15 @@ import {type FormEvent, useCallback, useState} from 'react' import {type FormBundleDocument, useTranslation} from 'sanity' import {Button, Dialog} from '../../../../ui-components' +import {type BundleDocument} from '../../../store/bundles/types' +import {useBundleOperations} from '../../../store/bundles/useBundleOperations' import { CreatedRelease, type OriginInfo, UpdatedRelease, -} from '../../../bundles/__telemetry__/releases.telemetry' -import {createReleaseId} from '../../../bundles/util/createReleaseId' -import {type BundleDocument} from '../../../store/bundles/types' -import {useBundleOperations} from '../../../store/bundles/useBundleOperations' +} from '../../__telemetry__/releases.telemetry' import {usePerspective} from '../../hooks' +import {createReleaseId} from '../../util/createReleaseId' import {ReleaseForm} from './ReleaseForm' interface ReleaseDetailsDialogProps { diff --git a/packages/sanity/src/core/releases/components/panes/ReleaseActions.tsx b/packages/sanity/src/core/releases/components/panes/ReleaseActions.tsx index a3cd4172849..bbc7a6c29c0 100644 --- a/packages/sanity/src/core/releases/components/panes/ReleaseActions.tsx +++ b/packages/sanity/src/core/releases/components/panes/ReleaseActions.tsx @@ -17,8 +17,8 @@ import { } from 'sanity' import {Button} from '../../../../ui-components' -import {AddedVersion} from '../../../bundles/__telemetry__/releases.telemetry' import {type BundleDocument} from '../../../store/bundles/types' +import {AddedVersion} from '../../__telemetry__/releases.telemetry' interface ReleaseActionsProps { currentGlobalBundle: BundleDocument diff --git a/packages/sanity/src/core/releases/hooks/usePerspective.tsx b/packages/sanity/src/core/releases/hooks/usePerspective.tsx index 51d10526496..31f43bcb235 100644 --- a/packages/sanity/src/core/releases/hooks/usePerspective.tsx +++ b/packages/sanity/src/core/releases/hooks/usePerspective.tsx @@ -1,6 +1,6 @@ import {useRouter} from 'sanity/router' -import {LATEST} from '../../bundles' +import {LATEST} from '../../releases' import {useBundles} from '../../store/bundles' import {type BundleDocument} from '../../store/bundles/types' diff --git a/packages/sanity/src/core/bundles/index.ts b/packages/sanity/src/core/releases/index.ts similarity index 51% rename from packages/sanity/src/core/bundles/index.ts rename to packages/sanity/src/core/releases/index.ts index 2828dfc1cf2..e0b00846683 100644 --- a/packages/sanity/src/core/bundles/index.ts +++ b/packages/sanity/src/core/releases/index.ts @@ -1,2 +1,4 @@ +export * from './components' +export * from './hooks' export * from './util/const' export * from './util/util' 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 67acd5601d5..64e07dbe256 100644 --- a/packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/ReleaseMenuButton.tsx +++ b/packages/sanity/src/core/releases/tool/components/ReleaseMenuButton/ReleaseMenuButton.tsx @@ -11,14 +11,14 @@ import {useState} from 'react' import {useRouter} from 'sanity/router' import {Button, Dialog, MenuButton, MenuItem} from '../../../../../ui-components' +import {Translate, useTranslation} from '../../../../i18n' +import {type BundleDocument} from '../../../../store/bundles/types' +import {useBundleOperations} from '../../../../store/bundles/useBundleOperations' import { ArchivedRelease, DeletedRelease, UnarchivedRelease, -} from '../../../../bundles/__telemetry__/releases.telemetry' -import {Translate, useTranslation} from '../../../../i18n' -import {type BundleDocument} from '../../../../store/bundles/types' -import {useBundleOperations} from '../../../../store/bundles/useBundleOperations' +} from '../../../__telemetry__/releases.telemetry' import {ReleaseDetailsDialog} from '../../../components/dialog/ReleaseDetailsDialog' import {releasesLocaleNamespace} from '../../../i18n' diff --git a/packages/sanity/src/core/releases/tool/components/ReleasePublishAllButton/ReleasePublishAllButton.tsx b/packages/sanity/src/core/releases/tool/components/ReleasePublishAllButton/ReleasePublishAllButton.tsx index b242dd64cd5..21eaec5db51 100644 --- a/packages/sanity/src/core/releases/tool/components/ReleasePublishAllButton/ReleasePublishAllButton.tsx +++ b/packages/sanity/src/core/releases/tool/components/ReleasePublishAllButton/ReleasePublishAllButton.tsx @@ -5,9 +5,9 @@ import {useCallback, useMemo, useState} from 'react' import {type BundleDocument} from 'sanity' import {Button, Dialog} from '../../../../../ui-components' -import {PublishedRelease} from '../../../../bundles/__telemetry__/releases.telemetry' import {Translate, useTranslation} from '../../../../i18n' import {useBundleOperations} from '../../../../store/bundles/useBundleOperations' +import {PublishedRelease} from '../../../__telemetry__/releases.telemetry' import {releasesLocaleNamespace} from '../../../i18n' import {type DocumentInBundleResult} from '../../../tool/detail/useBundleDocuments' import {useObserveDocumentRevisions} from './useObserveDocumentRevisions' diff --git a/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx b/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx index bf6a2df7b0b..06ededa46ee 100644 --- a/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx +++ b/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx @@ -101,8 +101,6 @@ export function ReleaseSummary(props: ReleaseSummaryProps) { [], ) - console.log({documentTableColumnDefs}) - return ( <> diff --git a/packages/sanity/src/core/bundles/util/const.ts b/packages/sanity/src/core/releases/util/const.ts similarity index 100% rename from packages/sanity/src/core/bundles/util/const.ts rename to packages/sanity/src/core/releases/util/const.ts diff --git a/packages/sanity/src/core/bundles/util/createReleaseId.ts b/packages/sanity/src/core/releases/util/createReleaseId.ts similarity index 100% rename from packages/sanity/src/core/bundles/util/createReleaseId.ts rename to packages/sanity/src/core/releases/util/createReleaseId.ts diff --git a/packages/sanity/src/core/bundles/util/util.test.ts b/packages/sanity/src/core/releases/util/util.test.ts similarity index 100% rename from packages/sanity/src/core/bundles/util/util.test.ts rename to packages/sanity/src/core/releases/util/util.test.ts diff --git a/packages/sanity/src/core/bundles/util/util.ts b/packages/sanity/src/core/releases/util/util.ts similarity index 100% rename from packages/sanity/src/core/bundles/util/util.ts rename to packages/sanity/src/core/releases/util/util.ts From 12914d573810cb45d3b12bc420736900f509730e Mon Sep 17 00:00:00 2001 From: Jordan Lawrence Date: Thu, 12 Sep 2024 11:45:27 +0100 Subject: [PATCH 05/10] chore(releases): fixing various test imports --- packages/sanity/src/core/index.ts | 12 +++++++++--- .../components/__tests__/ReleasesMenu.test.tsx | 2 +- .../tool/detail/__tests__/ReleaseReview.test.tsx | 2 +- .../tool/detail/__tests__/ReleaseSummary.test.tsx | 2 +- .../header/perspective/DocumentPerspectiveMenu.tsx | 9 +++++++-- .../__tests__/DocumentPerspectiveMenu.test.tsx | 4 +++- 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/packages/sanity/src/core/index.ts b/packages/sanity/src/core/index.ts index ace7a4f8f18..a50d54a9f95 100644 --- a/packages/sanity/src/core/index.ts +++ b/packages/sanity/src/core/index.ts @@ -21,9 +21,15 @@ export * from './hooks' export * from './i18n' export * from './presence' export * from './preview' -export {getDocumentIsInPerspective, LATEST} from './releases' -export {ReleaseActions, ReleaseBadge, ReleasesMenu} from './releases/components' -export {useDocumentVersions, usePerspective} from './releases/hooks' +export { + getDocumentIsInPerspective, + LATEST, + ReleaseActions, + ReleaseBadge, + ReleasesMenu, + useDocumentVersions, + usePerspective, +} from './releases' export * from './scheduledPublishing' export * from './schema' export type {SearchFactoryOptions, SearchOptions, SearchSort, SearchTerms} from './search' diff --git a/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx b/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx index b414b544132..7d20cb36901 100644 --- a/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx +++ b/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx @@ -17,7 +17,7 @@ jest.mock('../../hooks', () => ({ }), })) -jest.mock('../..//util/util', () => ({ +jest.mock('../../util/util', () => ({ isDraftOrPublished: jest.fn(), })) diff --git a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx index fc7cd250dda..55de5f74dcb 100644 --- a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx +++ b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx @@ -157,7 +157,7 @@ async function createReleaseReviewWrapper() { }) } -describe('ReleaseReview', () => { +describe.skip('ReleaseReview', () => { describe('when loading baseDocument', () => { beforeEach(async () => { mockedUseObserveDocument.mockReturnValue({ diff --git a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx index 39798344146..6d2c542917d 100644 --- a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx +++ b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx @@ -145,7 +145,7 @@ const renderTest = async (props: Partial) => { ) } -describe('ReleaseSummary', () => { +describe.skip('ReleaseSummary', () => { beforeEach(async () => { jest.clearAllMocks() diff --git a/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/DocumentPerspectiveMenu.tsx b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/DocumentPerspectiveMenu.tsx index 6d279529dc4..43422c38fe2 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/DocumentPerspectiveMenu.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/DocumentPerspectiveMenu.tsx @@ -4,11 +4,16 @@ import {Box, Button} from '@sanity/ui' // eslint-disable-next-line camelcase import {getTheme_v2} from '@sanity/ui/theme' import {memo, useMemo} from 'react' -import {type BundleDocument, usePerspective, useTranslation} from 'sanity' +import { + type BundleDocument, + ReleaseBadge, + ReleasesMenu, + usePerspective, + useTranslation, +} from 'sanity' import {IntentLink} from 'sanity/router' import {css, styled} from 'styled-components' -import {ReleaseBadge, ReleasesMenu} from '../../../../../../core/releases/components' import {Button as StudioButton} from '../../../../../../ui-components' import {usePaneRouter} from '../../../../../components' import {useDocumentPane} from '../../../useDocumentPane' diff --git a/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentPerspectiveMenu.test.tsx b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentPerspectiveMenu.test.tsx index 7476efe06e4..c8ded857e57 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentPerspectiveMenu.test.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentPerspectiveMenu.test.tsx @@ -80,7 +80,7 @@ describe('DocumentPerspectiveMenu', () => { }) }) - it.only('should render the bundle badge if the document exists in the global bundle', async () => { + it('should render the bundle badge if the document exists in the global bundle', async () => { mockUseDocumentPane.mockReturnValue({ documentVersions: [ { @@ -101,6 +101,8 @@ describe('DocumentPerspectiveMenu', () => { const wrapper = await createTestProvider() render(, {wrapper}) + screen.debug() + const linkButton = screen.getByRole('link', {name: 'Spring Drop'}) expect(linkButton).toBeInTheDocument() expect(linkButton).toHaveAttribute('href', '/intent/release/id=spring-drop') From 342ef30ab6269a4ecca6f8ee63c5ad39625627cf Mon Sep 17 00:00:00 2001 From: Jordan Lawrence Date: Thu, 12 Sep 2024 11:56:52 +0100 Subject: [PATCH 06/10] chore(releases): fixing various test imports --- .../core/releases/components/__tests__/ReleasesMenu.test.tsx | 4 ++-- .../core/releases/components/dialog/ReleaseDetailsDialog.tsx | 2 +- .../components/dialog/__tests__/ReleaseDetailsDialog.test.tsx | 4 ++-- packages/sanity/src/core/releases/hooks/usePerspective.tsx | 2 +- .../releases/tool/detail/__tests__/ReleaseReview.test.tsx | 2 +- .../releases/tool/detail/__tests__/ReleaseSummary.test.tsx | 2 +- .../perspective/__tests__/DocumentPerspectiveMenu.test.tsx | 2 -- 7 files changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx b/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx index 7d20cb36901..27a8816fb9e 100644 --- a/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx +++ b/packages/sanity/src/core/releases/components/__tests__/ReleasesMenu.test.tsx @@ -6,11 +6,11 @@ import {type BundleDocument, useBundles} from 'sanity' import {createTestProvider} from '../../../../../test/testUtils/TestProvider' import {Button} from '../../../../ui-components' -import {usePerspective} from '../../hooks' +import {usePerspective} from '../../hooks/usePerspective' import {LATEST} from '../../util/const' import {ReleasesMenu} from '../ReleasesMenu' -jest.mock('../../hooks', () => ({ +jest.mock('../../hooks/usePerspective', () => ({ usePerspective: jest.fn().mockReturnValue({ currentGlobalBundle: {}, setPerspective: jest.fn(), diff --git a/packages/sanity/src/core/releases/components/dialog/ReleaseDetailsDialog.tsx b/packages/sanity/src/core/releases/components/dialog/ReleaseDetailsDialog.tsx index 7bb892e0932..6a0f8524d25 100644 --- a/packages/sanity/src/core/releases/components/dialog/ReleaseDetailsDialog.tsx +++ b/packages/sanity/src/core/releases/components/dialog/ReleaseDetailsDialog.tsx @@ -12,7 +12,7 @@ import { type OriginInfo, UpdatedRelease, } from '../../__telemetry__/releases.telemetry' -import {usePerspective} from '../../hooks' +import {usePerspective} from '../../hooks/usePerspective' import {createReleaseId} from '../../util/createReleaseId' import {ReleaseForm} from './ReleaseForm' diff --git a/packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx b/packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx index 8d4dcc6ec54..64e664f0cea 100644 --- a/packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx +++ b/packages/sanity/src/core/releases/components/dialog/__tests__/ReleaseDetailsDialog.test.tsx @@ -4,7 +4,7 @@ import {type BundleDocument, useBundles} from 'sanity' import {createTestProvider} from '../../../../../../test/testUtils/TestProvider' import {useBundleOperations} from '../../../../store/bundles/useBundleOperations' -import {usePerspective} from '../../../hooks' +import {usePerspective} from '../../../hooks/usePerspective' import {ReleaseDetailsDialog} from '../ReleaseDetailsDialog' /*jest.mock('../../../../../core/hooks/useDateTimeFormat', () => ({ @@ -22,7 +22,7 @@ jest.mock('../../../../store/bundles/useBundleOperations', () => ({ }), })) -jest.mock('../../../hooks', () => ({ +jest.mock('../../../hooks/usePerspective', () => ({ usePerspective: jest.fn().mockReturnValue({ setPerspective: jest.fn(), }), diff --git a/packages/sanity/src/core/releases/hooks/usePerspective.tsx b/packages/sanity/src/core/releases/hooks/usePerspective.tsx index 31f43bcb235..b9618b1ada5 100644 --- a/packages/sanity/src/core/releases/hooks/usePerspective.tsx +++ b/packages/sanity/src/core/releases/hooks/usePerspective.tsx @@ -1,8 +1,8 @@ import {useRouter} from 'sanity/router' -import {LATEST} from '../../releases' import {useBundles} from '../../store/bundles' import {type BundleDocument} from '../../store/bundles/types' +import {LATEST} from '../util/const' /** * @internal diff --git a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx index 55de5f74dcb..fc7cd250dda 100644 --- a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx +++ b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx @@ -157,7 +157,7 @@ async function createReleaseReviewWrapper() { }) } -describe.skip('ReleaseReview', () => { +describe('ReleaseReview', () => { describe('when loading baseDocument', () => { beforeEach(async () => { mockedUseObserveDocument.mockReturnValue({ diff --git a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx index 6d2c542917d..39798344146 100644 --- a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx +++ b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx @@ -145,7 +145,7 @@ const renderTest = async (props: Partial) => { ) } -describe.skip('ReleaseSummary', () => { +describe('ReleaseSummary', () => { beforeEach(async () => { jest.clearAllMocks() diff --git a/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentPerspectiveMenu.test.tsx b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentPerspectiveMenu.test.tsx index c8ded857e57..987fe8588c0 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentPerspectiveMenu.test.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentPerspectiveMenu.test.tsx @@ -101,8 +101,6 @@ describe('DocumentPerspectiveMenu', () => { const wrapper = await createTestProvider() render(, {wrapper}) - screen.debug() - const linkButton = screen.getByRole('link', {name: 'Spring Drop'}) expect(linkButton).toBeInTheDocument() expect(linkButton).toHaveAttribute('href', '/intent/release/id=spring-drop') From 25d6ef63d7fc77d80cb81b78ca80d0184c40f2e6 Mon Sep 17 00:00:00 2001 From: Jordan Lawrence Date: Thu, 12 Sep 2024 13:41:57 +0100 Subject: [PATCH 07/10] chore(releases): fixing various test imports --- .../preview/components/_previewComponents.ts | 6 +- .../components/ReleaseDocumentPreview.tsx | 15 +-- .../releases/tool/detail/ReleaseReview.tsx | 2 + .../detail/__tests__/ReleaseReview.test.tsx | 15 ++- .../operators/assetOperators.test.ts | 64 ++++++++----- .../definitions/operators/assetOperators.ts | 95 ++++++++++--------- 6 files changed, 120 insertions(+), 77 deletions(-) diff --git a/packages/sanity/src/core/preview/components/_previewComponents.ts b/packages/sanity/src/core/preview/components/_previewComponents.ts index 8c64e2b82f7..f5f721f7307 100644 --- a/packages/sanity/src/core/preview/components/_previewComponents.ts +++ b/packages/sanity/src/core/preview/components/_previewComponents.ts @@ -8,7 +8,11 @@ import { MediaPreview, } from '../../components' -console.log('_PREVCOMP', DefaultPreview) +if (DefaultPreview) { + console.log('_PREVCOMP', DefaultPreview) +} else { + console.log('_PREVCOMP', 'DefaultPreview not found') +} export const _previewComponents = { block: BlockPreview, diff --git a/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx b/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx index 7106e1618f2..126611d6a7a 100644 --- a/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx +++ b/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx @@ -1,14 +1,17 @@ import {ErrorOutlineIcon} from '@sanity/icons' -import {type PreviewValue} from '@sanity/types' import {Card, Text} from '@sanity/ui' import {type ForwardedRef, forwardRef, useMemo} from 'react' -import {DocumentPreviewPresence, useDocumentPresence} from 'sanity' +import {useTranslation} from 'react-i18next' +import { + DocumentPreviewPresence, + getPublishedId, + type PreviewValue, + SanityDefaultPreview, + useDocumentPresence, +} from 'sanity' import {IntentLink} from 'sanity/router' import {Tooltip} from '../../../../ui-components' -import {useTranslation} from '../../../i18n' -import {SanityDefaultPreview} from '../../../preview/components/SanityDefaultPreview' -import {getPublishedId} from '../../../util/draftUtils' import {releasesLocaleNamespace} from '../../i18n' interface ReleaseDocumentPreviewProps { @@ -31,8 +34,6 @@ export function ReleaseDocumentPreview({ const documentPresence = useDocumentPresence(documentId) const {t} = useTranslation(releasesLocaleNamespace) - console.log('JOJAMES', SanityDefaultPreview) - const LinkComponent = useMemo( () => // eslint-disable-next-line @typescript-eslint/no-shadow diff --git a/packages/sanity/src/core/releases/tool/detail/ReleaseReview.tsx b/packages/sanity/src/core/releases/tool/detail/ReleaseReview.tsx index 582142e76c2..08534b71668 100644 --- a/packages/sanity/src/core/releases/tool/detail/ReleaseReview.tsx +++ b/packages/sanity/src/core/releases/tool/detail/ReleaseReview.tsx @@ -1,3 +1,4 @@ +/* eslint-disable unused-imports/no-unused-imports */ import {SearchIcon} from '@sanity/icons' import {Box, Container, Flex, Text, TextInput} from '@sanity/ui' import {useVirtualizer} from '@tanstack/react-virtual' @@ -6,6 +7,7 @@ import {useTranslation} from 'sanity' import {styled} from 'styled-components' import {type BundleDocument} from '../../../store/bundles/types' +import {SearchButtonValueReference} from '../../components/SearchButtonValueReference' import {releasesLocaleNamespace} from '../../i18n' import {type DocumentHistory} from './documentTable/useReleaseHistory' import {DocumentDiffContainer} from './review/DocumentDiffContainer' diff --git a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx index fc7cd250dda..29378ff07c4 100644 --- a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx +++ b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx @@ -1,4 +1,5 @@ import {beforeEach, describe, expect, it, jest} from '@jest/globals' +import {type ReferenceValue} from '@sanity/types' import {act, fireEvent, render, screen, within} from '@testing-library/react' import {type ReactNode} from 'react' import {ColorSchemeProvider, UserColorManagerProvider} from 'sanity' @@ -6,10 +7,22 @@ import {ColorSchemeProvider, UserColorManagerProvider} from 'sanity' import {queryByDataUi} from '../../../../../../test/setup/customQueries' import {createTestProvider} from '../../../../../../test/testUtils/TestProvider' import {useObserveDocument} from '../../../../preview/useObserveDocument' +import {assetOperators} from '../../../../studio/components/navbar/search/definitions/operators/assetOperators' import {releasesUsEnglishLocaleBundle} from '../../../i18n' import {ReleaseReview} from '../ReleaseReview' import {type DocumentInBundleResult} from '../useBundleDocuments' +assetOperators.assetFileEqual.groqFilter({fieldPath: '', value: {} as any}) + +const fieldPath = 'asset' +const valueFile: ReferenceValue = { + _ref: 'refFile', + _type: 'sanity.fileAsset', +} +const valueImage: ReferenceValue = { + _ref: 'refImage', + _type: 'sanity.imageAsset', +} const BASE_DOCUMENTS_MOCKS = { doc1: { name: 'William Faulkner', @@ -169,7 +182,7 @@ describe('ReleaseReview', () => { wrapper, }) }) - it("should show the loader when the base document hasn't loaded", () => { + it.only("should show the loader when the base document hasn't loaded", () => { queryByDataUi(document.body, 'Spinner') }) }) diff --git a/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/assetOperators.test.ts b/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/assetOperators.test.ts index b16e3bcd3a6..69df8853f99 100644 --- a/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/assetOperators.test.ts +++ b/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/assetOperators.test.ts @@ -1,33 +1,47 @@ -import {describe, expect, it} from '@jest/globals' -import {type ReferenceValue} from '@sanity/types' +// import {describe, expect, it} from '@jest/globals' +// import {type ReferenceValue} from '@sanity/types' + +import {beforeEach, describe, expect, it} from '@jest/globals' import {assetOperators} from './assetOperators' -const fieldPath = 'asset' -const valueFile: ReferenceValue = { - _ref: 'refFile', - _type: 'sanity.fileAsset', -} -const valueImage: ReferenceValue = { - _ref: 'refImage', - _type: 'sanity.imageAsset', -} +// const fieldPath = 'asset' +// const valueFile: ReferenceValue = { +// _ref: 'refFile', +// _type: 'sanity.fileAsset', +// } +// const valueImage: ReferenceValue = { +// _ref: 'refImage', +// _type: 'sanity.imageAsset', +// } + +// describe('assetOperators', () => { +// it('should create a valid filter for assetFileEqual', () => { +// const filter = assetOperators.assetFileEqual.groqFilter({fieldPath, value: valueFile}) +// expect(filter).toEqual(`${fieldPath}.asset._ref == "${valueFile._ref}"`) +// }) +// it('should create a valid filter for assetFileNotEqual', () => { +// const filter = assetOperators.assetFileNotEqual.groqFilter({fieldPath, value: valueFile}) +// expect(filter).toEqual(`${fieldPath}.asset._ref != "${valueFile._ref}"`) +// }) +// it('should create a valid filter for assetImageEqual', () => { +// const filter = assetOperators.assetImageEqual.groqFilter({fieldPath, value: valueImage}) +// expect(filter).toEqual(`${fieldPath}.asset._ref == "${valueImage._ref}"`) +// }) +// it('should create a valid filter for assetImageNotEqual', () => { +// const filter = assetOperators.assetImageNotEqual.groqFilter({fieldPath, value: valueImage}) +// expect(filter).toEqual(`${fieldPath}.asset._ref != "${valueImage._ref}"`) +// }) +// }) describe('assetOperators', () => { - it('should create a valid filter for assetFileEqual', () => { - const filter = assetOperators.assetFileEqual.groqFilter({fieldPath, value: valueFile}) - expect(filter).toEqual(`${fieldPath}.asset._ref == "${valueFile._ref}"`) - }) - it('should create a valid filter for assetFileNotEqual', () => { - const filter = assetOperators.assetFileNotEqual.groqFilter({fieldPath, value: valueFile}) - expect(filter).toEqual(`${fieldPath}.asset._ref != "${valueFile._ref}"`) - }) - it('should create a valid filter for assetImageEqual', () => { - const filter = assetOperators.assetImageEqual.groqFilter({fieldPath, value: valueImage}) - expect(filter).toEqual(`${fieldPath}.asset._ref == "${valueImage._ref}"`) + beforeEach(() => { + assetOperators.assetFileEqual.groqFilter({ + fieldPath: 'asset', + value: {_ref: 'refFile', _type: 'sanity.fileAsset'}, + }) }) - it('should create a valid filter for assetImageNotEqual', () => { - const filter = assetOperators.assetImageNotEqual.groqFilter({fieldPath, value: valueImage}) - expect(filter).toEqual(`${fieldPath}.asset._ref != "${valueImage._ref}"`) + it('tetss', () => { + expect(1).toEqual(1) }) }) diff --git a/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/assetOperators.ts b/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/assetOperators.ts index 1b51f9f77e2..a9edebbe5ac 100644 --- a/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/assetOperators.ts +++ b/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/assetOperators.ts @@ -1,55 +1,64 @@ -import {type ReferenceValue} from '@sanity/types' +/* eslint-disable unused-imports/no-unused-imports */ +// import {type ReferenceValue} from '@sanity/types' import {SearchButtonValueReference} from '../../components/filters/common/ButtonValue' import {SearchFilterAssetInput} from '../../components/filters/filter/inputs/asset/Asset' import {defineSearchOperator, type SearchOperatorButtonValue} from './operatorTypes' import {toJSON} from './operatorUtils' -// @todo: don't manually cast `buttonValueComponent` and `inputComponent` once -// we understand why `npm run etl` fails with 'Unable to follow symbol' errors +// // @todo: don't manually cast `buttonValueComponent` and `inputComponent` once +// // we understand why `npm run etl` fails with 'Unable to follow symbol' errors +// export const assetOperators = { +// assetFileEqual: defineSearchOperator({ +// nameKey: 'search.operator.asset-file-equal.name', +// descriptionKey: 'search.operator.asset-file-equal.description', +// buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue, +// groqFilter: ({fieldPath, value}) => +// value?._ref && fieldPath ? `${fieldPath}.asset._ref == ${toJSON(value._ref)}` : null, +// initialValue: null, +// inputComponent: SearchFilterAssetInput('file'), +// label: 'is', +// type: 'assetFileEqual', +// }), +// assetFileNotEqual: defineSearchOperator({ +// nameKey: 'search.operator.asset-file-not-equal.name', +// descriptionKey: 'search.operator.asset-file-not-equal.description', +// buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue, +// groqFilter: ({fieldPath, value}) => +// value?._ref && fieldPath ? `${fieldPath}.asset._ref != ${toJSON(value._ref)}` : null, +// initialValue: null, +// inputComponent: SearchFilterAssetInput('file'), +// label: 'is not', +// type: 'assetFileNotEqual', +// }), +// assetImageEqual: defineSearchOperator({ +// nameKey: 'search.operator.asset-image-equal.name', +// descriptionKey: 'search.operator.asset-image-equal.description', +// buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue, +// groqFilter: ({fieldPath, value}) => +// value?._ref && fieldPath ? `${fieldPath}.asset._ref == ${toJSON(value._ref)}` : null, +// initialValue: null, +// inputComponent: SearchFilterAssetInput('image'), +// label: 'is', +// type: 'assetImageEqual', +// }), +// assetImageNotEqual: defineSearchOperator({ +// nameKey: 'search.operator.asset-image-not-equal.name', +// descriptionKey: 'search.operator.asset-image-not-equal.description', +// buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue, +// groqFilter: ({fieldPath, value}) => +// value?._ref && fieldPath ? `${fieldPath}.asset._ref != ${toJSON(value._ref)}` : null, +// initialValue: null, +// inputComponent: SearchFilterAssetInput('image'), +// label: 'is not', +// type: 'assetImageNotEqual', +// }), +// } + export const assetOperators = { assetFileEqual: defineSearchOperator({ - nameKey: 'search.operator.asset-file-equal.name', - descriptionKey: 'search.operator.asset-file-equal.description', - buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue, - groqFilter: ({fieldPath, value}) => - value?._ref && fieldPath ? `${fieldPath}.asset._ref == ${toJSON(value._ref)}` : null, - initialValue: null, - inputComponent: SearchFilterAssetInput('file'), - label: 'is', - type: 'assetFileEqual', - }), - assetFileNotEqual: defineSearchOperator({ - nameKey: 'search.operator.asset-file-not-equal.name', - descriptionKey: 'search.operator.asset-file-not-equal.description', - buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue, - groqFilter: ({fieldPath, value}) => - value?._ref && fieldPath ? `${fieldPath}.asset._ref != ${toJSON(value._ref)}` : null, - initialValue: null, - inputComponent: SearchFilterAssetInput('file'), - label: 'is not', - type: 'assetFileNotEqual', - }), - assetImageEqual: defineSearchOperator({ - nameKey: 'search.operator.asset-image-equal.name', - descriptionKey: 'search.operator.asset-image-equal.description', - buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue, + buttonValueComponent: SearchButtonValueReference, groqFilter: ({fieldPath, value}) => value?._ref && fieldPath ? `${fieldPath}.asset._ref == ${toJSON(value._ref)}` : null, - initialValue: null, - inputComponent: SearchFilterAssetInput('image'), - label: 'is', - type: 'assetImageEqual', - }), - assetImageNotEqual: defineSearchOperator({ - nameKey: 'search.operator.asset-image-not-equal.name', - descriptionKey: 'search.operator.asset-image-not-equal.description', - buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue, - groqFilter: ({fieldPath, value}) => - value?._ref && fieldPath ? `${fieldPath}.asset._ref != ${toJSON(value._ref)}` : null, - initialValue: null, - inputComponent: SearchFilterAssetInput('image'), - label: 'is not', - type: 'assetImageNotEqual', }), } From ef3fca5ee2f664f492553a5f5089b526f46b6e9c Mon Sep 17 00:00:00 2001 From: Jordan Lawrence Date: Thu, 12 Sep 2024 13:46:23 +0100 Subject: [PATCH 08/10] chore(releases): further experimentation on SanityDocumentPreview test failures --- .../tool/components/ReleaseDocumentPreview.tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx b/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx index 126611d6a7a..f6502b9c6fa 100644 --- a/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx +++ b/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx @@ -1,17 +1,14 @@ import {ErrorOutlineIcon} from '@sanity/icons' +import {type PreviewValue} from '@sanity/types' import {Card, Text} from '@sanity/ui' import {type ForwardedRef, forwardRef, useMemo} from 'react' -import {useTranslation} from 'react-i18next' -import { - DocumentPreviewPresence, - getPublishedId, - type PreviewValue, - SanityDefaultPreview, - useDocumentPresence, -} from 'sanity' +import {DocumentPreviewPresence, useDocumentPresence} from 'sanity' import {IntentLink} from 'sanity/router' import {Tooltip} from '../../../../ui-components' +import {useTranslation} from '../../../i18n' +import {SanityDefaultPreview} from '../../../preview/components/SanityDefaultPreview' +import {getPublishedId} from '../../../util/draftUtils' import {releasesLocaleNamespace} from '../../i18n' interface ReleaseDocumentPreviewProps { From cecf1b9154c677ce483afff77c70edd70a4e907f Mon Sep 17 00:00:00 2001 From: Jordan Lawrence Date: Thu, 12 Sep 2024 15:53:45 +0100 Subject: [PATCH 09/10] chore(releases): fixing ReleaseSummary and Review by mocking components --- .../preview/components/_previewComponents.ts | 6 ---- .../releases/tool/detail/ReleaseReview.tsx | 2 -- .../detail/__tests__/ReleaseReview.test.tsx | 28 +++++++++---------- .../detail/__tests__/ReleaseSummary.test.tsx | 13 ++++++++- .../documentTable/DocumentTableColumnDefs.tsx | 1 - 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/packages/sanity/src/core/preview/components/_previewComponents.ts b/packages/sanity/src/core/preview/components/_previewComponents.ts index f5f721f7307..ec878b3f305 100644 --- a/packages/sanity/src/core/preview/components/_previewComponents.ts +++ b/packages/sanity/src/core/preview/components/_previewComponents.ts @@ -8,12 +8,6 @@ import { MediaPreview, } from '../../components' -if (DefaultPreview) { - console.log('_PREVCOMP', DefaultPreview) -} else { - console.log('_PREVCOMP', 'DefaultPreview not found') -} - export const _previewComponents = { block: BlockPreview, blockImage: BlockImagePreview, diff --git a/packages/sanity/src/core/releases/tool/detail/ReleaseReview.tsx b/packages/sanity/src/core/releases/tool/detail/ReleaseReview.tsx index 08534b71668..582142e76c2 100644 --- a/packages/sanity/src/core/releases/tool/detail/ReleaseReview.tsx +++ b/packages/sanity/src/core/releases/tool/detail/ReleaseReview.tsx @@ -1,4 +1,3 @@ -/* eslint-disable unused-imports/no-unused-imports */ import {SearchIcon} from '@sanity/icons' import {Box, Container, Flex, Text, TextInput} from '@sanity/ui' import {useVirtualizer} from '@tanstack/react-virtual' @@ -7,7 +6,6 @@ import {useTranslation} from 'sanity' import {styled} from 'styled-components' import {type BundleDocument} from '../../../store/bundles/types' -import {SearchButtonValueReference} from '../../components/SearchButtonValueReference' import {releasesLocaleNamespace} from '../../i18n' import {type DocumentHistory} from './documentTable/useReleaseHistory' import {DocumentDiffContainer} from './review/DocumentDiffContainer' diff --git a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx index 29378ff07c4..9d9bba3b76e 100644 --- a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx +++ b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseReview.test.tsx @@ -1,28 +1,15 @@ import {beforeEach, describe, expect, it, jest} from '@jest/globals' -import {type ReferenceValue} from '@sanity/types' import {act, fireEvent, render, screen, within} from '@testing-library/react' import {type ReactNode} from 'react' -import {ColorSchemeProvider, UserColorManagerProvider} from 'sanity' +import {ColorSchemeProvider, type DefaultPreview, UserColorManagerProvider} from 'sanity' import {queryByDataUi} from '../../../../../../test/setup/customQueries' import {createTestProvider} from '../../../../../../test/testUtils/TestProvider' import {useObserveDocument} from '../../../../preview/useObserveDocument' -import {assetOperators} from '../../../../studio/components/navbar/search/definitions/operators/assetOperators' import {releasesUsEnglishLocaleBundle} from '../../../i18n' import {ReleaseReview} from '../ReleaseReview' import {type DocumentInBundleResult} from '../useBundleDocuments' -assetOperators.assetFileEqual.groqFilter({fieldPath: '', value: {} as any}) - -const fieldPath = 'asset' -const valueFile: ReferenceValue = { - _ref: 'refFile', - _type: 'sanity.fileAsset', -} -const valueImage: ReferenceValue = { - _ref: 'refImage', - _type: 'sanity.imageAsset', -} const BASE_DOCUMENTS_MOCKS = { doc1: { name: 'William Faulkner', @@ -154,6 +141,17 @@ jest.mock('../../../../preview/useObserveDocument', () => { } }) +jest.mock('../../../../components', () => { + const {DefaultPreview: actualDefaultPreview} = jest.requireActual( + '../../../../components/previews/general/DefaultPreview', + ) as {DefaultPreview: typeof DefaultPreview} + + return { + ...(jest.requireActual('../../../../components') || {}), + DefaultPreview: actualDefaultPreview, + } +}) + const mockedUseObserveDocument = useObserveDocument as jest.Mock async function createReleaseReviewWrapper() { @@ -182,7 +180,7 @@ describe('ReleaseReview', () => { wrapper, }) }) - it.only("should show the loader when the base document hasn't loaded", () => { + it("should show the loader when the base document hasn't loaded", () => { queryByDataUi(document.body, 'Spinner') }) }) diff --git a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx index 39798344146..ac065f40193 100644 --- a/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx +++ b/packages/sanity/src/core/releases/tool/detail/__tests__/ReleaseSummary.test.tsx @@ -1,6 +1,6 @@ import {beforeEach, describe, expect, it, jest} from '@jest/globals' import {fireEvent, render, screen, within} from '@testing-library/react' -import {type BundleDocument, defineType} from 'sanity' +import {type BundleDocument, type DefaultPreview, defineType} from 'sanity' import {route, RouterProvider} from 'sanity/router' import {getAllByDataUi, getByDataUi} from '../../../../../../test/setup/customQueries' @@ -27,6 +27,17 @@ jest.mock('../../../components/ReleasesMenu', () => ({ ReleasesMenu: () =>
ReleasesMenu
, })) +jest.mock('../../../../components', () => { + const {DefaultPreview: actualDefaultPreview} = jest.requireActual( + '../../../../components/previews/general/DefaultPreview', + ) as {DefaultPreview: typeof DefaultPreview} + + return { + ...(jest.requireActual('../../../../components') || {}), + DefaultPreview: actualDefaultPreview, + } +}) + const timeNow = new Date() const releaseDocuments: DocumentInBundleResult[] = [ diff --git a/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx b/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx index fe0dc93e0db..6b0abd90b73 100644 --- a/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx +++ b/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx @@ -17,7 +17,6 @@ const MemoReleaseDocumentPreview = memo( item: DocumentInBundleResult releaseSlug: string }) { - console.log('BANANAS', ReleaseDocumentPreview) return ( Date: Thu, 12 Sep 2024 15:55:20 +0100 Subject: [PATCH 10/10] chore(releases): reverting irrelevent changes --- .../operators/assetOperators.test.ts | 64 +++++-------- .../definitions/operators/assetOperators.ts | 95 +++++++++---------- 2 files changed, 68 insertions(+), 91 deletions(-) diff --git a/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/assetOperators.test.ts b/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/assetOperators.test.ts index 69df8853f99..b16e3bcd3a6 100644 --- a/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/assetOperators.test.ts +++ b/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/assetOperators.test.ts @@ -1,47 +1,33 @@ -// import {describe, expect, it} from '@jest/globals' -// import {type ReferenceValue} from '@sanity/types' - -import {beforeEach, describe, expect, it} from '@jest/globals' +import {describe, expect, it} from '@jest/globals' +import {type ReferenceValue} from '@sanity/types' import {assetOperators} from './assetOperators' -// const fieldPath = 'asset' -// const valueFile: ReferenceValue = { -// _ref: 'refFile', -// _type: 'sanity.fileAsset', -// } -// const valueImage: ReferenceValue = { -// _ref: 'refImage', -// _type: 'sanity.imageAsset', -// } - -// describe('assetOperators', () => { -// it('should create a valid filter for assetFileEqual', () => { -// const filter = assetOperators.assetFileEqual.groqFilter({fieldPath, value: valueFile}) -// expect(filter).toEqual(`${fieldPath}.asset._ref == "${valueFile._ref}"`) -// }) -// it('should create a valid filter for assetFileNotEqual', () => { -// const filter = assetOperators.assetFileNotEqual.groqFilter({fieldPath, value: valueFile}) -// expect(filter).toEqual(`${fieldPath}.asset._ref != "${valueFile._ref}"`) -// }) -// it('should create a valid filter for assetImageEqual', () => { -// const filter = assetOperators.assetImageEqual.groqFilter({fieldPath, value: valueImage}) -// expect(filter).toEqual(`${fieldPath}.asset._ref == "${valueImage._ref}"`) -// }) -// it('should create a valid filter for assetImageNotEqual', () => { -// const filter = assetOperators.assetImageNotEqual.groqFilter({fieldPath, value: valueImage}) -// expect(filter).toEqual(`${fieldPath}.asset._ref != "${valueImage._ref}"`) -// }) -// }) +const fieldPath = 'asset' +const valueFile: ReferenceValue = { + _ref: 'refFile', + _type: 'sanity.fileAsset', +} +const valueImage: ReferenceValue = { + _ref: 'refImage', + _type: 'sanity.imageAsset', +} describe('assetOperators', () => { - beforeEach(() => { - assetOperators.assetFileEqual.groqFilter({ - fieldPath: 'asset', - value: {_ref: 'refFile', _type: 'sanity.fileAsset'}, - }) + it('should create a valid filter for assetFileEqual', () => { + const filter = assetOperators.assetFileEqual.groqFilter({fieldPath, value: valueFile}) + expect(filter).toEqual(`${fieldPath}.asset._ref == "${valueFile._ref}"`) + }) + it('should create a valid filter for assetFileNotEqual', () => { + const filter = assetOperators.assetFileNotEqual.groqFilter({fieldPath, value: valueFile}) + expect(filter).toEqual(`${fieldPath}.asset._ref != "${valueFile._ref}"`) + }) + it('should create a valid filter for assetImageEqual', () => { + const filter = assetOperators.assetImageEqual.groqFilter({fieldPath, value: valueImage}) + expect(filter).toEqual(`${fieldPath}.asset._ref == "${valueImage._ref}"`) }) - it('tetss', () => { - expect(1).toEqual(1) + it('should create a valid filter for assetImageNotEqual', () => { + const filter = assetOperators.assetImageNotEqual.groqFilter({fieldPath, value: valueImage}) + expect(filter).toEqual(`${fieldPath}.asset._ref != "${valueImage._ref}"`) }) }) diff --git a/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/assetOperators.ts b/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/assetOperators.ts index a9edebbe5ac..1b51f9f77e2 100644 --- a/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/assetOperators.ts +++ b/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/assetOperators.ts @@ -1,64 +1,55 @@ -/* eslint-disable unused-imports/no-unused-imports */ -// import {type ReferenceValue} from '@sanity/types' +import {type ReferenceValue} from '@sanity/types' import {SearchButtonValueReference} from '../../components/filters/common/ButtonValue' import {SearchFilterAssetInput} from '../../components/filters/filter/inputs/asset/Asset' import {defineSearchOperator, type SearchOperatorButtonValue} from './operatorTypes' import {toJSON} from './operatorUtils' -// // @todo: don't manually cast `buttonValueComponent` and `inputComponent` once -// // we understand why `npm run etl` fails with 'Unable to follow symbol' errors -// export const assetOperators = { -// assetFileEqual: defineSearchOperator({ -// nameKey: 'search.operator.asset-file-equal.name', -// descriptionKey: 'search.operator.asset-file-equal.description', -// buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue, -// groqFilter: ({fieldPath, value}) => -// value?._ref && fieldPath ? `${fieldPath}.asset._ref == ${toJSON(value._ref)}` : null, -// initialValue: null, -// inputComponent: SearchFilterAssetInput('file'), -// label: 'is', -// type: 'assetFileEqual', -// }), -// assetFileNotEqual: defineSearchOperator({ -// nameKey: 'search.operator.asset-file-not-equal.name', -// descriptionKey: 'search.operator.asset-file-not-equal.description', -// buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue, -// groqFilter: ({fieldPath, value}) => -// value?._ref && fieldPath ? `${fieldPath}.asset._ref != ${toJSON(value._ref)}` : null, -// initialValue: null, -// inputComponent: SearchFilterAssetInput('file'), -// label: 'is not', -// type: 'assetFileNotEqual', -// }), -// assetImageEqual: defineSearchOperator({ -// nameKey: 'search.operator.asset-image-equal.name', -// descriptionKey: 'search.operator.asset-image-equal.description', -// buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue, -// groqFilter: ({fieldPath, value}) => -// value?._ref && fieldPath ? `${fieldPath}.asset._ref == ${toJSON(value._ref)}` : null, -// initialValue: null, -// inputComponent: SearchFilterAssetInput('image'), -// label: 'is', -// type: 'assetImageEqual', -// }), -// assetImageNotEqual: defineSearchOperator({ -// nameKey: 'search.operator.asset-image-not-equal.name', -// descriptionKey: 'search.operator.asset-image-not-equal.description', -// buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue, -// groqFilter: ({fieldPath, value}) => -// value?._ref && fieldPath ? `${fieldPath}.asset._ref != ${toJSON(value._ref)}` : null, -// initialValue: null, -// inputComponent: SearchFilterAssetInput('image'), -// label: 'is not', -// type: 'assetImageNotEqual', -// }), -// } - +// @todo: don't manually cast `buttonValueComponent` and `inputComponent` once +// we understand why `npm run etl` fails with 'Unable to follow symbol' errors export const assetOperators = { assetFileEqual: defineSearchOperator({ - buttonValueComponent: SearchButtonValueReference, + nameKey: 'search.operator.asset-file-equal.name', + descriptionKey: 'search.operator.asset-file-equal.description', + buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue, + groqFilter: ({fieldPath, value}) => + value?._ref && fieldPath ? `${fieldPath}.asset._ref == ${toJSON(value._ref)}` : null, + initialValue: null, + inputComponent: SearchFilterAssetInput('file'), + label: 'is', + type: 'assetFileEqual', + }), + assetFileNotEqual: defineSearchOperator({ + nameKey: 'search.operator.asset-file-not-equal.name', + descriptionKey: 'search.operator.asset-file-not-equal.description', + buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue, + groqFilter: ({fieldPath, value}) => + value?._ref && fieldPath ? `${fieldPath}.asset._ref != ${toJSON(value._ref)}` : null, + initialValue: null, + inputComponent: SearchFilterAssetInput('file'), + label: 'is not', + type: 'assetFileNotEqual', + }), + assetImageEqual: defineSearchOperator({ + nameKey: 'search.operator.asset-image-equal.name', + descriptionKey: 'search.operator.asset-image-equal.description', + buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue, groqFilter: ({fieldPath, value}) => value?._ref && fieldPath ? `${fieldPath}.asset._ref == ${toJSON(value._ref)}` : null, + initialValue: null, + inputComponent: SearchFilterAssetInput('image'), + label: 'is', + type: 'assetImageEqual', + }), + assetImageNotEqual: defineSearchOperator({ + nameKey: 'search.operator.asset-image-not-equal.name', + descriptionKey: 'search.operator.asset-image-not-equal.description', + buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue, + groqFilter: ({fieldPath, value}) => + value?._ref && fieldPath ? `${fieldPath}.asset._ref != ${toJSON(value._ref)}` : null, + initialValue: null, + inputComponent: SearchFilterAssetInput('image'), + label: 'is not', + type: 'assetImageNotEqual', }), }