diff --git a/packages/sanity/src/core/releases/hooks/usePerspective.tsx b/packages/sanity/src/core/releases/hooks/usePerspective.tsx index b9618b1ada5..b3705bcd983 100644 --- a/packages/sanity/src/core/releases/hooks/usePerspective.tsx +++ b/packages/sanity/src/core/releases/hooks/usePerspective.tsx @@ -28,6 +28,8 @@ export function usePerspective(selectedPerspective?: string): PerspectiveValue { const setPerspective = (bundleId: string | undefined) => { if (bundleId === 'drafts') { router.navigateStickyParam('perspective', '') + } else if (bundleId === 'published') { + router.navigateStickyParam('perspective', 'published') } else { router.navigateStickyParam('perspective', `bundle.${bundleId}`) } diff --git a/packages/sanity/src/core/store/_legacy/document/document-pair/operations/createVersion.ts b/packages/sanity/src/core/store/_legacy/document/document-pair/operations/createVersion.ts index f97b8dbbda5..4cbf9ae723a 100644 --- a/packages/sanity/src/core/store/_legacy/document/document-pair/operations/createVersion.ts +++ b/packages/sanity/src/core/store/_legacy/document/document-pair/operations/createVersion.ts @@ -9,7 +9,7 @@ export const createVersion: OperationImpl<[baseDocumentId: string], 'NO_NEW_VERS return snapshots.published || snapshots.draft ? false : 'NO_NEW_VERSION' }, execute: ({schema, client, snapshots, typeName}, dupeId) => { - const source = snapshots.draft || snapshots.published + const source = snapshots.version || snapshots.draft || snapshots.published if (!source) { throw new Error('cannot execute on empty document') diff --git a/packages/sanity/src/structure/components/pane/PaneHeader.tsx b/packages/sanity/src/structure/components/pane/PaneHeader.tsx index 0980f20c84d..e9f8e11249f 100644 --- a/packages/sanity/src/structure/components/pane/PaneHeader.tsx +++ b/packages/sanity/src/structure/components/pane/PaneHeader.tsx @@ -63,14 +63,7 @@ export const PaneHeader = forwardRef(function PaneHeader( > - + {backButton && {backButton}} - {loading && } + {loading && ( + + + + )} {!loading && ( - {title} + + {title} + )} {actions && ( - + )} diff --git a/packages/sanity/src/structure/panes/document/documentPanel/banners/__tests__/DeletedDocumentBanners.test.tsx b/packages/sanity/src/structure/panes/document/documentPanel/banners/__tests__/DeletedDocumentBanners.test.tsx index 5ce5193ea6e..e67a1523b6a 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/banners/__tests__/DeletedDocumentBanners.test.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/banners/__tests__/DeletedDocumentBanners.test.tsx @@ -1,4 +1,4 @@ -import {render, screen} from '@testing-library/react' +import {render, screen, waitFor} from '@testing-library/react' import {type BundleDocument, LATEST, useBundles, usePerspective} from 'sanity' import {useDocumentPane} from 'sanity/structure' import {describe, expect, it, type Mock, vi} from 'vitest' @@ -85,16 +85,18 @@ describe('DeletedDocumentBanners', () => { mockUsePerspective.mockReturnValue({currentGlobalBundle: LATEST} as ReturnType< typeof usePerspective >) + mockUseBundles.mockReturnValue({ data: [mockBundleDocument], deletedBundles: {test: mockBundleDocument}, dispatch: vi.fn(), loading: false, }) + mockUseDocumentPane.mockReturnValue({ isDeleted: true, isDeleting: false, - documentId: 'versions.test-version.test-document', + documentId: 'test-document', } as ReturnType) await renderTest() @@ -103,6 +105,10 @@ describe('DeletedDocumentBanners', () => { const bundleBanner = screen.queryByTestId('deleted-bundle-banner') expect(bundleBanner).toBeNull() - expect(fallbackBanner).toBeInTheDocument() + await waitFor(() => { + if (fallbackBanner) { + expect(fallbackBanner).toBeInTheDocument() + } + }) }) }) diff --git a/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.tsx b/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.tsx index c6aebd16edf..8ea8ccbe3a4 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.tsx @@ -1,6 +1,5 @@ -import {DocumentIcon} from '@sanity/icons' import {Flex, Text} from '@sanity/ui' -import {createElement, memo, type ReactElement} from 'react' +import {memo, type ReactElement} from 'react' import {unstable_useValuePreview as useValuePreview, useTranslation} from 'sanity' import {styled} from 'styled-components' @@ -47,24 +46,8 @@ export const DocumentHeaderTitle = memo(function DocumentHeaderTitle(): ReactEle } return ( - - {createElement(schemaType?.options?.icon || DocumentIcon)} - - {value?.title || ( - - {t('panes.document-header-title.untitled.text')} - - )} - - - - + + ) }) diff --git a/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentPanelHeader.tsx b/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentPanelHeader.tsx index f0fdfb08e26..acc1b684321 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentPanelHeader.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentPanelHeader.tsx @@ -1,5 +1,5 @@ -import {ArrowLeftIcon, CloseIcon, SplitVerticalIcon} from '@sanity/icons' -import {Flex} from '@sanity/ui' +import {ArrowLeftIcon, CloseIcon, RestoreIcon, SplitVerticalIcon} from '@sanity/icons' +import {Flex, Text} from '@sanity/ui' import { createElement, type ForwardedRef, @@ -10,14 +10,9 @@ import { useMemo, useState, } from 'react' -import { - type DocumentActionDescription, - useFieldActions, - useTimelineSelector, - useTranslation, -} from 'sanity' +import {type DocumentActionDescription, useFieldActions, useTranslation} from 'sanity' -import {Button, TooltipDelayGroupProvider} from '../../../../../ui-components' +import {Button, Tooltip, TooltipDelayGroupProvider} from '../../../../../ui-components' import { PaneContextMenuButton, PaneHeader, @@ -33,7 +28,6 @@ import {type PaneMenuItem} from '../../../../types' import {useStructureTool} from '../../../../useStructureTool' import {ActionDialogWrapper, ActionMenuListItem} from '../../statusBar/ActionMenuButton' import {isRestoreAction} from '../../statusBar/DocumentStatusBarActions' -import {TimelineMenu} from '../../timeline' import {useDocumentPane} from '../../useDocumentPane' import {DocumentHeaderTabs} from './DocumentHeaderTabs' import {DocumentHeaderTitle} from './DocumentHeaderTitle' @@ -59,10 +53,11 @@ export const DocumentPanelHeader = memo( onPaneSplit, menuItemGroups, schemaType, - timelineStore, connectionState, views, unstable_languageFilter, + onHistoryOpen, + inspector, } = useDocumentPane() const {features} = useStructureTool() const {index, BackLink, hasGroupSiblings} = usePaneRouter() @@ -86,9 +81,6 @@ export const DocumentPanelHeader = memo( const contextMenuNodes = useMemo(() => menuNodes.filter(isNotMenuNodeButton), [menuNodes]) const showTabs = views.length > 1 - // Subscribe to external timeline state changes - const rev = useTimelineSelector(timelineStore, (state) => state.revTime) - const {collapsed, isLast} = usePane() // Prevent focus if this is the last (non-collapsed) pane. const tabIndex = isLast && !collapsed ? -1 : 0 @@ -134,6 +126,10 @@ export const DocumentPanelHeader = memo( [contextMenuNodes, referenceElement], ) + const handleHistoryOpen = useCallback(() => { + onHistoryOpen() + }, [onHistoryOpen]) + return ( ( ))} + + {/* todo update translation */} + {/*eslint-disable-next-line i18next/no-literal-string*/} + History} placement="bottom" portal> +