7
7
Menu ,
8
8
Text ,
9
9
} from '@sanity/ui'
10
- import { useRouter } from 'sanity/router'
11
10
import { styled } from 'styled-components'
12
11
13
12
import { MenuButton , type MenuButtonProps , MenuItem , Tooltip } from '../../../../../ui-components'
@@ -21,7 +20,6 @@ const StyledMenu = styled(Menu)`
21
20
max-width: 350px;
22
21
min-width: 250px;
23
22
`
24
-
25
23
const POPOVER_PROPS : MenuButtonProps [ 'popover' ] = {
26
24
constrainSize : true ,
27
25
fallbackPlacements : [ 'bottom-end' , 'bottom' ] ,
@@ -30,9 +28,8 @@ const POPOVER_PROPS: MenuButtonProps['popover'] = {
30
28
31
29
export function WorkspaceMenuButton ( ) {
32
30
const workspaces = useWorkspaces ( )
33
- const { activeWorkspace, setActiveWorkspace } = useActiveWorkspace ( )
31
+ const { activeWorkspace} = useActiveWorkspace ( )
34
32
const [ authStates ] = useWorkspaceAuthStates ( workspaces )
35
- const { navigateUrl} = useRouter ( )
36
33
const { t} = useTranslation ( )
37
34
38
35
const multipleWorkspaces = workspaces . length > 1
@@ -77,24 +74,18 @@ export function WorkspaceMenuButton() {
77
74
? 'logged-out'
78
75
: 'no-access'
79
76
80
- const handleSelectWorkspace = ( ) => {
81
- if ( state === 'logged-in' && workspace . name !== activeWorkspace . name ) {
82
- setActiveWorkspace ( workspace . name )
83
- }
84
-
85
- // Navigate to the base path of the workspace to authenticate
86
- if ( state === 'logged-out' ) {
87
- navigateUrl ( { path : workspace . basePath } )
88
- }
89
- }
90
77
const isSelected = workspace . name === activeWorkspace . name
78
+
79
+ // we have a temporary need to make a hard direct link to the workspace
80
+ // because of possibly shared context between workspaces. When this is resolved,
81
+ // we can remove this and use setActiveWorkspace instead
91
82
return (
92
83
< MenuItem
84
+ as = "a"
85
+ href = { workspace . basePath }
93
86
badgeText = { STATE_TITLES [ state ] }
94
87
iconRight = { isSelected ? CheckmarkIcon : undefined }
95
88
key = { workspace . name }
96
- // eslint-disable-next-line react/jsx-no-bind
97
- onClick = { handleSelectWorkspace }
98
89
pressed = { isSelected }
99
90
preview = { < WorkspacePreviewIcon icon = { workspace . icon } size = "small" /> }
100
91
selected = { isSelected }
0 commit comments