@@ -54,13 +54,18 @@ export const DocVisibility = ({ doc }: DocVisibilityProps) => {
5454 const linkReachOptions : DropdownMenuOption [ ] = useMemo ( ( ) => {
5555 return Object . values ( LinkReach ) . map ( ( key ) => {
5656 const isDisabled = doc . abilities . link_select_options [ key ] === undefined ;
57+ let linkRole = undefined ;
58+ if ( key !== LinkReach . RESTRICTED ) {
59+ linkRole = docLinkRole ;
60+ }
5761
5862 return {
5963 label : linkReachTranslations [ key ] ,
6064 callback : ( ) =>
6165 updateDocLink ( {
6266 id : doc . id ,
6367 link_reach : key ,
68+ link_role : linkRole ,
6469 } ) ,
6570 isSelected : docLinkReach === key ,
6671 disabled : isDisabled ,
@@ -70,6 +75,7 @@ export const DocVisibility = ({ doc }: DocVisibilityProps) => {
7075 doc . abilities . link_select_options ,
7176 doc . id ,
7277 docLinkReach ,
78+ docLinkRole ,
7379 linkReachTranslations ,
7480 updateDocLink ,
7581 ] ) ;
@@ -78,7 +84,8 @@ export const DocVisibility = ({ doc }: DocVisibilityProps) => {
7884 ( option ) => option . disabled ,
7985 ) ;
8086
81- const showLinkRoleOptions = doc . computed_link_reach !== LinkReach . RESTRICTED ;
87+ const showLinkRoleOptions =
88+ docLinkReach !== LinkReach . RESTRICTED && docLinkRole ;
8289
8390 const linkRoleOptions : DropdownMenuOption [ ] = useMemo ( ( ) => {
8491 const options = doc . abilities . link_select_options [ docLinkReach ] ?? [ ] ;
@@ -175,26 +182,24 @@ export const DocVisibility = ({ doc }: DocVisibilityProps) => {
175182 </ Box >
176183 { showLinkRoleOptions && (
177184 < Box $direction = "row" $align = "center" $gap = { spacingsTokens [ '3xs' ] } >
178- { docLinkReach !== LinkReach . RESTRICTED && (
179- < DropdownMenu
180- testId = "doc-access-mode"
181- disabled = { ! canManage }
182- showArrow = { true }
183- options = { linkRoleOptions }
184- topMessage = {
185- haveDisabledLinkRoleOptions
186- ? t (
187- 'You cannot restrict access to a subpage relative to its parent page.' ,
188- )
189- : undefined
190- }
191- label = { t ( 'Document access mode' ) }
192- >
193- < Text $weight = "initial" $variation = "600" >
194- { linkModeTranslations [ docLinkRole ] }
195- </ Text >
196- </ DropdownMenu >
197- ) }
185+ < DropdownMenu
186+ testId = "doc-access-mode"
187+ disabled = { ! canManage }
188+ showArrow = { true }
189+ options = { linkRoleOptions }
190+ topMessage = {
191+ haveDisabledLinkRoleOptions
192+ ? t (
193+ 'You cannot restrict access to a subpage relative to its parent page.' ,
194+ )
195+ : undefined
196+ }
197+ label = { t ( 'Document access mode' ) }
198+ >
199+ < Text $weight = "initial" $variation = "600" >
200+ { linkModeTranslations [ docLinkRole ] }
201+ </ Text >
202+ </ DropdownMenu >
198203 </ Box >
199204 ) }
200205 </ Box >
0 commit comments