@@ -4,6 +4,7 @@ import {memo, useMemo, useState} from 'react'
4
4
5
5
import { MenuButton , MenuItem } from '../../../../../ui-components'
6
6
import { ContextMenuButton } from '../../../../components/contextMenuButton'
7
+ import { useSchema } from '../../../../hooks'
7
8
import { useTranslation } from '../../../../i18n'
8
9
import { useDocumentPairPermissions } from '../../../../store/_legacy/grants/documentPairPermissions'
9
10
import { getPublishedId , getVersionFromId } from '../../../../util/draftUtils'
@@ -13,14 +14,8 @@ import {releasesLocaleNamespace} from '../../../i18n'
13
14
import { isGoingToUnpublish } from '../../../util/isGoingToUnpublish'
14
15
import { type BundleDocumentRow } from '../ReleaseSummary'
15
16
16
- export const DocumentActions = memo (
17
- function DocumentActions ( {
18
- document,
19
- releaseTitle,
20
- } : {
21
- document : BundleDocumentRow
22
- releaseTitle : string
23
- } ) {
17
+ const DocumentActionsInner = memo (
18
+ function DocumentActionsInner ( { document} : { document : BundleDocumentRow } ) {
24
19
const [ showDiscardDialog , setShowDiscardDialog ] = useState ( false )
25
20
const [ showUnpublishDialog , setShowUnpublishDialog ] = useState ( false )
26
21
const { t : coreT } = useTranslation ( )
@@ -124,6 +119,25 @@ export const DocumentActions = memo(
124
119
</ >
125
120
)
126
121
} ,
127
- ( prev , next ) =>
128
- prev . document . memoKey === next . document . memoKey && prev . releaseTitle === next . releaseTitle ,
122
+ ( prev , next ) => prev . document . memoKey === next . document . memoKey ,
129
123
)
124
+
125
+ export const DocumentActions = memo ( function GuardedDocumentActions ( props : {
126
+ document : BundleDocumentRow
127
+ } ) {
128
+ const schema = useSchema ( )
129
+ const type = schema . get ( props . document . document . _type )
130
+ const { t} = useTranslation ( )
131
+ if ( ! type ) {
132
+ return (
133
+ < ContextMenuButton
134
+ disabled
135
+ tooltipProps = { {
136
+ content : t ( 'document.type.not-found' , { type : props . document . document . _type } ) ,
137
+ } }
138
+ />
139
+ )
140
+ }
141
+
142
+ return < DocumentActionsInner { ...props } />
143
+ } )
0 commit comments