diff --git a/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx b/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx index b98615fb18f..09c10d7b7b4 100644 --- a/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx +++ b/packages/sanity/src/core/releases/tool/components/ReleaseDocumentPreview.tsx @@ -6,7 +6,7 @@ import {IntentLink} from 'sanity/router' import {DocumentPreviewPresence} from '../../../presence' import {SanityDefaultPreview} from '../../../preview/components/SanityDefaultPreview' import {getPublishedId} from '../../../util/draftUtils' -import {useDocumentPresence} from '../../index' +import {type ReleaseState, useDocumentPresence} from '../../index' import {getReleaseIdFromReleaseDocumentId} from '../../util/getReleaseIdFromReleaseDocumentId' interface ReleaseDocumentPreviewProps { @@ -15,8 +15,8 @@ interface ReleaseDocumentPreviewProps { releaseId: string previewValues: PreviewValue isLoading: boolean - revision?: string - hasValidationError?: boolean + releaseState?: ReleaseState + documentRevision?: string } export function ReleaseDocumentPreview({ @@ -25,11 +25,24 @@ export function ReleaseDocumentPreview({ releaseId, previewValues, isLoading, - revision, - hasValidationError, + releaseState, + documentRevision, }: ReleaseDocumentPreviewProps) { const documentPresence = useDocumentPresence(documentId) + const intentParams = useMemo(() => { + if (releaseState !== 'published' && releaseState !== 'archived') return {} + + const rev = releaseState === 'archived' ? '@lastEdited' : '@lastPublished' + + return { + rev, + inspect: 'sanity/structure/history', + historyEvent: documentRevision, + historyVersion: getReleaseIdFromReleaseDocumentId(releaseId), + } + }, [documentRevision, releaseId, releaseState]) + const LinkComponent = useMemo( () => // eslint-disable-next-line @typescript-eslint/no-shadow @@ -41,13 +54,21 @@ export function ReleaseDocumentPreview({ params={{ id: getPublishedId(documentId), type: documentTypeName, + ...intentParams, }} - searchParams={[['perspective', getReleaseIdFromReleaseDocumentId(releaseId)]]} + searchParams={[ + [ + 'perspective', + releaseState === 'published' + ? 'published' + : getReleaseIdFromReleaseDocumentId(releaseId), + ], + ]} ref={ref} /> ) }), - [documentId, documentTypeName, releaseId], + [documentId, documentTypeName, intentParams, releaseId, releaseState], ) const previewPresence = useMemo( @@ -55,16 +76,9 @@ export function ReleaseDocumentPreview({ [documentPresence], ) - const preview = ( - - ) - - /** @todo revision deeplink support for archived and published version docs */ - if (revision) return preview - return ( - {preview} + ) } 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 c40acb8d5ca..6eea0d27510 100644 --- a/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx +++ b/packages/sanity/src/core/releases/tool/detail/documentTable/DocumentTableColumnDefs.tsx @@ -20,21 +20,23 @@ const MemoReleaseDocumentPreview = memo( function MemoReleaseDocumentPreview({ item, releaseId, - revision, + releaseState, + documentRevision, }: { item: DocumentInRelease releaseId: string - revision?: string + releaseState?: ReleaseState + documentRevision?: string }) { return ( ) }, @@ -135,11 +137,8 @@ export const getDocumentTableColumnDefs: ( ), 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 ea52a516b25..5fc47d787d8 100644 --- a/packages/sanity/src/core/releases/tool/detail/review/DocumentReviewHeader.tsx +++ b/packages/sanity/src/core/releases/tool/detail/review/DocumentReviewHeader.tsx @@ -55,7 +55,6 @@ export function DocumentReviewHeader({ releaseId={releaseId} previewValues={previewValues} isLoading={isLoading} - hasValidationError={validation?.hasError} />