/* eslint-disable @typescript-eslint/ban-ts-comment */ /* eslint-disable no-relative-import-paths/no-relative-import-paths */ // @ts-nocheck - Overlay file copied into the starter repo where path aliases are configured. import React from 'react'; import { Brand, Dropdown, DropdownItem, DropdownList, Masthead, MastheadBrand, MastheadContent, MastheadLogo, MastheadMain, MastheadToggle, MenuToggle, MenuToggleElement, PageToggleButton, Toolbar, ToolbarContent, ToolbarGroup, ToolbarItem, } from '@patternfly/react-core'; import { SimpleSelect } from '@patternfly/react-templates'; import { BarsIcon } from '@patternfly/react-icons'; import { useNamespaceSelector, useModularArchContext } from 'mod-arch-core'; // TODO: Replace this import with the proper one in the dashboard main package. import { images as sharedImages } from '../../shared/images'; interface NavBarProps { username?: string; onLogout: () => void; } const NavBar: React.FC = ({ username, onLogout }) => { const { namespaces, preferredNamespace, updatePreferredNamespace } = useNamespaceSelector(); const { config } = useModularArchContext(); const [userMenuOpen, setUserMenuOpen] = React.useState(false); const isMandatoryNamespace = Boolean(config.mandatoryNamespace); const options = namespaces.map((namespace) => ({ content: namespace.name, value: namespace.name, selected: namespace.name === preferredNamespace?.name, })); const handleLogout = () => { setUserMenuOpen(false); onLogout(); }; const userMenuItems = [ Log out , ]; return ( { if (!isMandatoryNamespace) { updatePreferredNamespace({ name: String(selection) }); } }} /> {username && ( setUserMenuOpen(isOpen)} toggle={(toggleRef: React.Ref) => ( setUserMenuOpen(!userMenuOpen)} isExpanded={userMenuOpen} > {username} )} isOpen={userMenuOpen} > {userMenuItems} )} ); }; export default NavBar;