From 9669fa857ad4d0fd96cfe64d84412f0d3d64849d Mon Sep 17 00:00:00 2001 From: Celia Amador Date: Tue, 2 Jun 2026 12:58:21 +0200 Subject: [PATCH] EDM-3449: Display org label in the user dropdown Made-with: Cursor --- .../app/components/AppLayout/AppToolbar.css | 5 ++++ .../app/components/AppLayout/AppToolbar.tsx | 28 +++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/apps/standalone/src/app/components/AppLayout/AppToolbar.css b/apps/standalone/src/app/components/AppLayout/AppToolbar.css index 8b4c08b25..e2b9336a0 100644 --- a/apps/standalone/src/app/components/AppLayout/AppToolbar.css +++ b/apps/standalone/src/app/components/AppLayout/AppToolbar.css @@ -1,3 +1,8 @@ .fctl-app_toolbar { justify-content: flex-end; } + +/* Put the dropdown icon at the top - it looks better with the content (username + organization label in two lines) */ +.fctl-app_toolbar-menu__toggle { + align-items: flex-start; +} diff --git a/apps/standalone/src/app/components/AppLayout/AppToolbar.tsx b/apps/standalone/src/app/components/AppLayout/AppToolbar.tsx index 3b7095cb1..daff4366c 100644 --- a/apps/standalone/src/app/components/AppLayout/AppToolbar.tsx +++ b/apps/standalone/src/app/components/AppLayout/AppToolbar.tsx @@ -3,9 +3,12 @@ import { Alert, Avatar, Button, + Content, Dropdown, DropdownItem, DropdownList, + Flex, + FlexItem, MenuToggle, MenuToggleElement, Modal, @@ -23,6 +26,7 @@ import UserPreferencesModal from '@flightctl/ui-components/src/components/Masthe import { useTranslation } from '@flightctl/ui-components/src/hooks/useTranslation'; import { ROUTE, useNavigate } from '@flightctl/ui-components/src/hooks/useNavigate'; +import { useOrganizationGuardContext } from '@flightctl/ui-components/src/components/common/OrganizationGuard'; import { getErrorMessage } from '@flightctl/ui-components/src/utils/error'; import { AuthContext } from '../../context/AuthContext'; import { logout } from '../../utils/apiCalls'; @@ -30,12 +34,17 @@ import { logout } from '../../utils/apiCalls'; import './AppToolbar.css'; type UserDropdownProps = { - children?: React.ReactNode; username?: string; + organizationLabel?: string; onUserPreferences: VoidFunction; }; -const UserDropdown: React.FC = ({ children, username = 'User', onUserPreferences }) => { +const UserDropdown = ({ + children, + username = 'User', + organizationLabel, + onUserPreferences, +}: React.PropsWithChildren) => { const { t } = useTranslation(); const [isDropdownOpen, setIsDropdownOpen] = React.useState(false); const onDropdownToggle = () => { @@ -49,14 +58,21 @@ const UserDropdown: React.FC = ({ children, username = 'User' toggle={(toggleRef: React.Ref) => ( } onClick={onDropdownToggle} id="userMenu" - isFullHeight isExpanded={isDropdownOpen} variant="plainText" > - {username} + + {username} + {organizationLabel && ( + + {organizationLabel} + + )} + )} > @@ -74,6 +90,8 @@ const AppToolbar = () => { const [helpDropdownOpen, setHelpDropdownOpen] = React.useState(false); const { username } = React.useContext(AuthContext); + const { currentOrganization } = useOrganizationGuardContext(); + const organizationLabel = currentOrganization?.label || currentOrganization?.id; const [logoutLoading, setLogoutLoading] = React.useState(false); const [logoutErr, setLogoutErr] = React.useState(); const onUserPreferences = () => setPreferencesModalOpen(true); @@ -82,7 +100,7 @@ const AppToolbar = () => { let userDropdown = ; if (username) { userDropdown = ( - + { try {