forked from kubeflow/model-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: lucferbux <lferrnan@redhat.com>
- Loading branch information
Showing
5 changed files
with
107 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import React from 'react'; | ||
import { | ||
Dropdown, | ||
DropdownItem, | ||
DropdownList, | ||
Masthead, | ||
MastheadContent, | ||
MastheadMain, | ||
MenuToggle, | ||
MenuToggleElement, | ||
Toolbar, | ||
ToolbarContent, | ||
ToolbarGroup, | ||
ToolbarItem, | ||
} from '@patternfly/react-core'; | ||
import { SimpleSelect, SimpleSelectOption } from '@patternfly/react-templates'; | ||
|
||
interface NavBarProps { | ||
username?: string; | ||
onLogout: () => void; | ||
} | ||
|
||
const NavBar: React.FC<NavBarProps> = ({ username, onLogout }) => { | ||
const Options: SimpleSelectOption[] = [{ content: 'All Namespaces', value: 'All' }]; | ||
|
||
const [selected, setSelected] = React.useState<string | undefined>('All'); | ||
const [userMenuOpen, setUserMenuOpen] = React.useState(false); | ||
|
||
const initialOptions = React.useMemo<SimpleSelectOption[]>( | ||
() => Options.map((o) => ({ ...o, selected: o.value === selected })), | ||
[selected], | ||
); | ||
|
||
const handleLogout = () => { | ||
setUserMenuOpen(false); | ||
onLogout(); | ||
}; | ||
|
||
const userMenuItems = [ | ||
<DropdownItem key="logout" onClick={handleLogout}> | ||
Log out | ||
</DropdownItem>, | ||
]; | ||
|
||
return ( | ||
<Masthead> | ||
<MastheadMain /> | ||
<MastheadContent> | ||
<Toolbar> | ||
<ToolbarContent> | ||
<ToolbarGroup variant="action-group-plain" align={{ default: 'alignStart' }}> | ||
<ToolbarItem> | ||
<SimpleSelect | ||
isDisabled | ||
initialOptions={initialOptions} | ||
onSelect={(_ev, selection) => setSelected(String(selection))} | ||
></SimpleSelect> | ||
</ToolbarItem> | ||
</ToolbarGroup> | ||
{username && ( | ||
<ToolbarGroup variant="action-group-plain" align={{ default: 'alignEnd' }}> | ||
<ToolbarItem> | ||
<Dropdown | ||
popperProps={{ position: 'right' }} | ||
onOpenChange={(isOpen) => setUserMenuOpen(isOpen)} | ||
toggle={(toggleRef: React.Ref<MenuToggleElement>) => ( | ||
<MenuToggle | ||
aria-label="User menu" | ||
id="user-menu-toggle" | ||
ref={toggleRef} | ||
onClick={() => setUserMenuOpen(!userMenuOpen)} | ||
isExpanded={userMenuOpen} | ||
> | ||
{username} | ||
</MenuToggle> | ||
)} | ||
isOpen={userMenuOpen} | ||
> | ||
<DropdownList>{userMenuItems}</DropdownList> | ||
</Dropdown> | ||
</ToolbarItem> | ||
</ToolbarGroup> | ||
)} | ||
</ToolbarContent> | ||
</Toolbar> | ||
</MastheadContent> | ||
</Masthead> | ||
); | ||
}; | ||
|
||
export default NavBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters