Skip to content

Commit db834ef

Browse files
authored
feat(sanity): hide global user menu inside Core UI Rendering Context (#8591)
### Description This branch removes the global user menu when Studio is rendered inside Core UI. Core UI provides the global user menu capability, so Studio doesn't need to. #### Small viewport <img width="627" alt="Screenshot 2025-03-06 at 12 40 31" src="https://github.com/user-attachments/assets/89d016b2-f4f4-4512-8c64-13b0c53b75d7" /> #### Large viewport <img width="1671" alt="Screenshot 2025-03-06 at 12 40 40" src="https://github.com/user-attachments/assets/72b0ba7d-7b58-46a2-87be-06e2745df183" /> ### What to review The removal of the global user menu. ### Testing This can be tested by running Studio locally and then accessing the local dev server using a Core UI preview deployment.
1 parent 5b06c42 commit db834ef

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

packages/sanity/src/core/studio/components/navbar/StudioNavbar.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {type RouterState, useRouterState} from 'sanity/router'
1616
import {styled} from 'styled-components'
1717

1818
import {Button, TooltipDelayGroupProvider} from '../../../../ui-components'
19+
import {CapabilityGate} from '../../../components/CapabilityGate'
1920
import {type NavbarProps} from '../../../config/studio/types'
2021
import {isDev} from '../../../environment'
2122
import {useTranslation} from '../../../i18n'
@@ -285,9 +286,11 @@ export function StudioNavbar(props: Omit<NavbarProps, 'renderDefault'>) {
285286
{actionNodes}
286287

287288
{shouldRender.tools && (
288-
<Box flex="none" marginLeft={1}>
289-
<UserMenu />
290-
</Box>
289+
<CapabilityGate capability="globalUserMenu">
290+
<Box flex="none" marginLeft={1}>
291+
<UserMenu />
292+
</Box>
293+
</CapabilityGate>
291294
)}
292295
</Flex>
293296
</TooltipDelayGroupProvider>

packages/sanity/src/core/studio/components/navbar/navDrawer/NavDrawer.tsx

+15-12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {styled} from 'styled-components'
77

88
import {Button} from '../../../../../ui-components'
99
import {UserAvatar} from '../../../../components'
10+
import {CapabilityGate} from '../../../../components/CapabilityGate'
1011
import {type NavbarAction, type Tool} from '../../../../config'
1112
import {useTranslation} from '../../../../i18n'
1213
import {useColorSchemeSetValue} from '../../../colorScheme'
@@ -162,18 +163,20 @@ export const NavDrawer = memo(function NavDrawer(props: NavDrawerProps) {
162163
<Flex align="center">
163164
{/* Current user */}
164165
<Flex flex={1} align="center" paddingRight={2}>
165-
<Flex flex={1} align="center">
166-
<UserAvatar size={1} user="me" />
167-
<Box
168-
flex={1}
169-
marginLeft={3}
170-
title={currentUser?.name || currentUser?.email}
171-
>
172-
<Text size={1} textOverflow="ellipsis" weight="medium">
173-
{currentUser?.name || currentUser?.email}
174-
</Text>
175-
</Box>
176-
</Flex>
166+
<CapabilityGate capability="globalUserMenu">
167+
<Flex flex={1} align="center">
168+
<UserAvatar size={1} user="me" />
169+
<Box
170+
flex={1}
171+
marginLeft={3}
172+
title={currentUser?.name || currentUser?.email}
173+
>
174+
<Text size={1} textOverflow="ellipsis" weight="medium">
175+
{currentUser?.name || currentUser?.email}
176+
</Text>
177+
</Box>
178+
</Flex>
179+
</CapabilityGate>
177180
</Flex>
178181

179182
<Button

0 commit comments

Comments
 (0)