@@ -10,6 +10,7 @@ import {
10
10
import { styled } from 'styled-components'
11
11
12
12
import { MenuButton , type MenuButtonProps , MenuItem , Tooltip } from '../../../../../ui-components'
13
+ import { CapabilityGate } from '../../../../components/CapabilityGate'
13
14
import { useTranslation } from '../../../../i18n'
14
15
import { useActiveWorkspace } from '../../../activeWorkspaceMatcher'
15
16
import { useWorkspaces } from '../../../workspaces'
@@ -53,9 +54,11 @@ export function WorkspaceMenuButton() {
53
54
{ activeWorkspace . title }
54
55
</ Text >
55
56
</ Box >
56
- < Text size = { 1 } >
57
- < ChevronDownIcon />
58
- </ Text >
57
+ < CapabilityGate capability = "globalWorkspaceControl" >
58
+ < Text size = { 1 } >
59
+ < ChevronDownIcon />
60
+ </ Text >
61
+ </ CapabilityGate >
59
62
</ Flex >
60
63
</ UIButton >
61
64
</ Tooltip >
@@ -64,39 +67,41 @@ export function WorkspaceMenuButton() {
64
67
id = "workspace-menu"
65
68
menu = {
66
69
! disabled && authStates ? (
67
- < StyledMenu >
68
- { workspaces . map ( ( workspace ) => {
69
- const authState = authStates [ workspace . name ]
70
+ < CapabilityGate capability = "globalWorkspaceControl" >
71
+ < StyledMenu >
72
+ { workspaces . map ( ( workspace ) => {
73
+ const authState = authStates [ workspace . name ]
70
74
71
- // eslint-disable-next-line no-nested-ternary
72
- const state = authState . authenticated
73
- ? 'logged-in'
74
- : workspace . auth . LoginComponent
75
- ? 'logged-out'
76
- : 'no-access'
75
+ // eslint-disable-next-line no-nested-ternary
76
+ const state = authState . authenticated
77
+ ? 'logged-in'
78
+ : workspace . auth . LoginComponent
79
+ ? 'logged-out'
80
+ : 'no-access'
77
81
78
- const isSelected = workspace . name === activeWorkspace . name
82
+ const isSelected = workspace . name === activeWorkspace . name
79
83
80
- // we have a temporary need to make a hard direct link to the workspace
81
- // because of possibly shared context between workspaces. When this is resolved,
82
- // we can remove this and use setActiveWorkspace instead
83
- return (
84
- < MenuItem
85
- as = "a"
86
- href = { workspace . basePath }
87
- badgeText = { STATE_TITLES [ state ] }
88
- iconRight = { isSelected ? CheckmarkIcon : undefined }
89
- key = { workspace . name }
90
- pressed = { isSelected }
91
- preview = { < WorkspacePreviewIcon icon = { workspace . icon } size = "small" /> }
92
- selected = { isSelected }
93
- __unstable_subtitle = { workspace . subtitle }
94
- __unstable_space = { 1 }
95
- text = { workspace ?. title || workspace . name }
96
- />
97
- )
98
- } ) }
99
- </ StyledMenu >
84
+ // we have a temporary need to make a hard direct link to the workspace
85
+ // because of possibly shared context between workspaces. When this is resolved,
86
+ // we can remove this and use setActiveWorkspace instead
87
+ return (
88
+ < MenuItem
89
+ as = "a"
90
+ href = { workspace . basePath }
91
+ badgeText = { STATE_TITLES [ state ] }
92
+ iconRight = { isSelected ? CheckmarkIcon : undefined }
93
+ key = { workspace . name }
94
+ pressed = { isSelected }
95
+ preview = { < WorkspacePreviewIcon icon = { workspace . icon } size = "small" /> }
96
+ selected = { isSelected }
97
+ __unstable_subtitle = { workspace . subtitle }
98
+ __unstable_space = { 1 }
99
+ text = { workspace ?. title || workspace . name }
100
+ />
101
+ )
102
+ } ) }
103
+ </ StyledMenu >
104
+ </ CapabilityGate >
100
105
) : undefined
101
106
}
102
107
popover = { POPOVER_PROPS }
0 commit comments