Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(releases): moving from bundles to releases directory #7500

Merged
merged 11 commits into from
Sep 20, 2024
Merged
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 9 additions & 9 deletions packages/sanity/src/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
export {
getDocumentIsInPerspective,
LATEST,
ReleaseActions,
ReleaseBadge,
ReleasesMenu,
useDocumentVersions,
usePerspective,
} from './bundles'
export * from './changeIndicators'
export {
CommentInput,
Expand All @@ -30,6 +21,15 @@ export * from './hooks'
export * from './i18n'
export * from './presence'
export * from './preview'
export {
getDocumentIsInPerspective,
LATEST,
ReleaseActions,
ReleaseBadge,
ReleasesMenu,
useDocumentVersions,
usePerspective,
} from './releases'
export * from './scheduledPublishing'
export * from './schema'
export type {SearchFactoryOptions, SearchOptions, SearchSort, SearchTerms} from './search'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {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 {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 '../../../__telemetry__/releases.telemetry'
import {ReleaseDetailsDialog} from '../../../components/dialog/ReleaseDetailsDialog'
import {releasesLocaleNamespace} from '../../../i18n'

export type ReleaseMenuButtonProps = {
disabled?: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {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'

interface ReleasePublishAllButtonProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ 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 {Chip} from '../../components/Chip'
import {Table, type TableProps} from '../../components/Table/Table'
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'
import {DocumentActions} from './documentTable/DocumentActions'
import {getDocumentTableColumnDefs} from './documentTable/DocumentTableColumnDefs'
import {type DocumentHistory} from './documentTable/useReleaseHistory'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {beforeEach, describe, expect, it, jest} from '@jest/globals'
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'
Expand Down Expand Up @@ -131,7 +131,7 @@ jest.mock('sanity/router', () => ({
}),
}))

jest.mock('../../../../bundles/components/ReleasesMenu', () => ({
jest.mock('../../../components/ReleasesMenu', () => ({
ReleasesMenu: () => <div>ReleasesMenu</div>,
}))

Expand All @@ -141,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<typeof useObserveDocument>

async function createReleaseReviewWrapper() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -23,10 +23,21 @@ jest.mock('../../../../user-color', () => ({
useUserColor: jest.fn().mockReturnValue('red'),
}))

jest.mock('../../../../bundles/components/ReleasesMenu', () => ({
jest.mock('../../../components/ReleasesMenu', () => ({
ReleasesMenu: () => <div>ReleasesMenu</div>,
}))

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[] = [
Expand Down Expand Up @@ -56,7 +67,7 @@ const releaseDocuments: DocumentInBundleResult[] = [
},
},
{
memoKey: 'key123',
memoKey: 'key456',
document: {
_id: '456',
_type: 'document',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ 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 {ReleaseMenuButton} from '../../components/ReleaseMenuButton/ReleaseMenuButton'
import {Table, type TableProps} from '../../components/Table/Table'
import {type TableSort} from '../../components/Table/TableProvider'
import {ReleaseDetailsDialog} from '../../components/dialog/ReleaseDetailsDialog'
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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ 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 {type TableRowProps} from '../../components/Table/Table'
import {Headers} from '../../components/Table/TableHeader'
import {type Column} from '../../components/Table/types'
import {ReleaseBadge} from '../../components/ReleaseBadge'
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<TableBundle>['cell'] = ({cellProps, datum: bundle}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {usePerspective} from '../../../../releases/hooks/usePerspective'
import {useBundles} from '../../../../store/bundles'

export function GlobalPerspectiveMenu(): JSX.Element {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jest.mock('../../../useDocumentPane', () => ({
useDocumentPane: jest.fn(),
}))

jest.mock('../../../../../../core/bundles/hooks/usePerspective', () => ({
jest.mock('../../../../../../core/releases/hooks/usePerspective', () => ({
usePerspective: jest.fn(),
}))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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
Expand All @@ -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(),
}))

Expand Down
Loading