refactor(ui): simplify workspace dropdown component structure (#11040)
Reorganized the workspace dropdown rendering logic for improved readability and maintainability. Ensured consistent handling of separators and dropdown items, while preserving the existing functionality. Fix #11034
This commit is contained in:
@ -127,6 +127,8 @@ export const MultiWorkspaceDropdownDefaultComponents = () => {
|
|||||||
>
|
>
|
||||||
{currentWorkspace?.displayName}
|
{currentWorkspace?.displayName}
|
||||||
</DropdownMenuHeader>
|
</DropdownMenuHeader>
|
||||||
|
{workspaces.length > 1 && (
|
||||||
|
<>
|
||||||
<StyledDropdownMenuItemsContainer>
|
<StyledDropdownMenuItemsContainer>
|
||||||
{workspaces
|
{workspaces
|
||||||
.filter(({ id }) => id !== currentWorkspace?.id)
|
.filter(({ id }) => id !== currentWorkspace?.id)
|
||||||
@ -134,7 +136,9 @@ export const MultiWorkspaceDropdownDefaultComponents = () => {
|
|||||||
.map((workspace) => (
|
.map((workspace) => (
|
||||||
<UndecoratedLink
|
<UndecoratedLink
|
||||||
key={workspace.id}
|
key={workspace.id}
|
||||||
to={buildWorkspaceUrl(getWorkspaceUrl(workspace.workspaceUrls))}
|
to={buildWorkspaceUrl(
|
||||||
|
getWorkspaceUrl(workspace.workspaceUrls),
|
||||||
|
)}
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
event?.preventDefault();
|
event?.preventDefault();
|
||||||
handleChange(workspace);
|
handleChange(workspace);
|
||||||
@ -156,12 +160,16 @@ export const MultiWorkspaceDropdownDefaultComponents = () => {
|
|||||||
<MenuItem
|
<MenuItem
|
||||||
LeftIcon={IconSwitchHorizontal}
|
LeftIcon={IconSwitchHorizontal}
|
||||||
text={t`Other workspaces`}
|
text={t`Other workspaces`}
|
||||||
onClick={() => setMultiWorkspaceDropdownState('workspaces-list')}
|
onClick={() =>
|
||||||
|
setMultiWorkspaceDropdownState('workspaces-list')
|
||||||
|
}
|
||||||
hasSubMenu={true}
|
hasSubMenu={true}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</StyledDropdownMenuItemsContainer>
|
</StyledDropdownMenuItemsContainer>
|
||||||
{workspaces.length > 1 && <DropdownMenuSeparator />}
|
<DropdownMenuSeparator />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<StyledDropdownMenuItemsContainer>
|
<StyledDropdownMenuItemsContainer>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
LeftIcon={colorSchemeList.find(({ id }) => id === colorScheme)?.icon}
|
LeftIcon={colorSchemeList.find(({ id }) => id === colorScheme)?.icon}
|
||||||
|
|||||||
Reference in New Issue
Block a user