Skip to content

Commit

Permalink
feat(sanity): hide global user menu inside Core UI Rendering Context
Browse files Browse the repository at this point in the history
  • Loading branch information
juice49 committed Feb 12, 2025
1 parent e23ed66 commit 8d1981c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {type RouterState, useRouterState} from 'sanity/router'
import {styled} from 'styled-components'

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

{shouldRender.tools && (
<Box flex="none" marginLeft={1}>
<UserMenu />
</Box>
<CapabilityGate capability="globalUserMenu">
<Box flex="none" marginLeft={1}>
<UserMenu />
</Box>
</CapabilityGate>
)}
</Flex>
</TooltipDelayGroupProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {styled} from 'styled-components'

import {Button} from '../../../../../ui-components'
import {UserAvatar} from '../../../../components'
import {CapabilityGate} from '../../../../components/CapabilityGate'
import {type NavbarAction, type Tool} from '../../../../config'
import {useTranslation} from '../../../../i18n'
import {useColorSchemeSetValue} from '../../../colorScheme'
Expand Down Expand Up @@ -162,18 +163,20 @@ export const NavDrawer = memo(function NavDrawer(props: NavDrawerProps) {
<Flex align="center">
{/* Current user */}
<Flex flex={1} align="center" paddingRight={2}>
<Flex flex={1} align="center">
<UserAvatar size={1} user="me" />
<Box
flex={1}
marginLeft={3}
title={currentUser?.name || currentUser?.email}
>
<Text size={1} textOverflow="ellipsis" weight="medium">
{currentUser?.name || currentUser?.email}
</Text>
</Box>
</Flex>
<CapabilityGate capability="globalUserMenu">
<Flex flex={1} align="center">
<UserAvatar size={1} user="me" />
<Box
flex={1}
marginLeft={3}
title={currentUser?.name || currentUser?.email}
>
<Text size={1} textOverflow="ellipsis" weight="medium">
{currentUser?.name || currentUser?.email}
</Text>
</Box>
</Flex>
</CapabilityGate>
</Flex>

<Button
Expand Down

0 comments on commit 8d1981c

Please sign in to comment.