@@ -8,7 +8,7 @@ import {MenuGroup} from '../../../../../ui-components/menuGroup/MenuGroup'
8
8
import { MenuItem } from '../../../../../ui-components/menuItem/MenuItem'
9
9
import { useTranslation } from '../../../../i18n/hooks/useTranslation'
10
10
import { useDocumentPairPermissions } from '../../../../store/_legacy/grants/documentPairPermissions'
11
- import { getPublishedId , isDraftId , isPublishedId } from '../../../../util/draftUtils'
11
+ import { getPublishedId , isPublishedId } from '../../../../util/draftUtils'
12
12
import { useReleasesUpsell } from '../../../contexts/upsell/useReleasesUpsell'
13
13
import { type ReleaseDocument } from '../../../store/types'
14
14
import { useReleaseOperations } from '../../../store/useReleaseOperations'
@@ -60,12 +60,14 @@ export const VersionContextMenu = memo(function VersionContextMenu(props: {
60
60
const { createRelease} = useReleaseOperations ( )
61
61
const [ hasCreatePermission , setHasCreatePermission ] = useState < boolean | null > ( null )
62
62
63
- const releaseId = isVersion ? fromRelease : documentId
64
63
const [ permissions , isPermissionsLoading ] = useDocumentPairPermissions ( {
65
64
id : getPublishedId ( documentId ) ,
66
65
type,
67
- version : releaseId ,
68
- permission : isDraftId ( documentId ) ? 'discardDraft' : 'discardVersion' ,
66
+ version : isVersion ? fromRelease : undefined ,
67
+ // Note: the result of this discard permission check is disregarded for the published document
68
+ // version. Discarding is never available for the published document version. Therefore, the
69
+ // parameters provided here are not configured to handle published document versions.
70
+ permission : fromRelease === 'draft' ? 'discardDraft' : 'discardVersion' ,
69
71
} )
70
72
const hasDiscardPermission = ! isPermissionsLoading && permissions ?. granted
71
73
@@ -88,7 +90,7 @@ export const VersionContextMenu = memo(function VersionContextMenu(props: {
88
90
{ isVersion && (
89
91
< IntentLink
90
92
intent = "release"
91
- params = { { id : releaseId } }
93
+ params = { { id : fromRelease } }
92
94
rel = "noopener noreferrer"
93
95
style = { { textDecoration : 'none' } }
94
96
disabled = { disabled }
0 commit comments