Skip to content

Commit

Permalink
fix: hard link between datasets, for now (#7228)
Browse files Browse the repository at this point in the history
  • Loading branch information
cngonzalez authored and ricokahler committed Jul 23, 2024
1 parent c4f9a1f commit 2e77986
Showing 1 changed file with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Menu,
Text,
} from '@sanity/ui'
import {useRouter} from 'sanity/router'
import {styled} from 'styled-components'

import {MenuButton, type MenuButtonProps, MenuItem, Tooltip} from '../../../../../ui-components'
Expand All @@ -21,7 +20,6 @@ const StyledMenu = styled(Menu)`
max-width: 350px;
min-width: 250px;
`

const POPOVER_PROPS: MenuButtonProps['popover'] = {
constrainSize: true,
fallbackPlacements: ['bottom-end', 'bottom'],
Expand All @@ -30,9 +28,8 @@ const POPOVER_PROPS: MenuButtonProps['popover'] = {

export function WorkspaceMenuButton() {
const workspaces = useWorkspaces()
const {activeWorkspace, setActiveWorkspace} = useActiveWorkspace()
const {activeWorkspace} = useActiveWorkspace()
const [authStates] = useWorkspaceAuthStates(workspaces)
const {navigateUrl} = useRouter()
const {t} = useTranslation()

const multipleWorkspaces = workspaces.length > 1
Expand Down Expand Up @@ -77,24 +74,18 @@ export function WorkspaceMenuButton() {
? 'logged-out'
: 'no-access'

const handleSelectWorkspace = () => {
if (state === 'logged-in' && workspace.name !== activeWorkspace.name) {
setActiveWorkspace(workspace.name)
}

// Navigate to the base path of the workspace to authenticate
if (state === 'logged-out') {
navigateUrl({path: workspace.basePath})
}
}
const isSelected = workspace.name === activeWorkspace.name

// we have a temporary need to make a hard direct link to the workspace
// because of possibly shared context between workspaces. When this is resolved,
// we can remove this and use setActiveWorkspace instead
return (
<MenuItem
as="a"
href={workspace.basePath}
badgeText={STATE_TITLES[state]}
iconRight={isSelected ? CheckmarkIcon : undefined}
key={workspace.name}
// eslint-disable-next-line react/jsx-no-bind
onClick={handleSelectWorkspace}
pressed={isSelected}
preview={<WorkspacePreviewIcon icon={workspace.icon} size="small" />}
selected={isSelected}
Expand Down

0 comments on commit 2e77986

Please sign in to comment.