ManageIQ/manageiq-ui-classic

View on GitHub
app/javascript/menu/README.md

Summary

Maintainability
Test Coverage
## ManageIQ Main Menu & Navbar

This code exports 2 registry components:

* `menu.MainMenu` - the carbon main menu
* `menu.Navbar` - an empty navbar stub, overidable, + `app/stylesheet/navbar.scss`


### Main Menu

The menu consists of a permanent SideNav, expanded or collapsed,
and a secondary pop-up SideNav with an overlay, always expanded.

The primary pane remembers the collapsed state, but selecting a section or triggering the search or class selector forces it to expand.

Document `body` additionally gets a `miq-main-menu-expanded` or `miq-main-menu-collapsed` class.

Expanded state is persisted in `localStorage`, by setting `patternfly-navigation-primary` to either `'collapsed'` or `'expanded'`.


**Components** (in order):

* `MiqLogo` (`.menu-logo`) - manageiq logo, uses `logoLarge` and `logoSmall` for the URLs, and is hidden when `showLogo` is false
* `Username` (`.menu-user`) - username, appliance name; collapses to initials; uses `applianceName`, `currentUser`, is hidden when `showUser` is false
* `GroupSwitcher` (`.menu-group`) - display or switch current group; uses `currentGroup`, `miqGroups`
* `MenuSearch` (`.menu-search`) - search in menu component, `onSearch` provides an array of results or null
* when searching: `SearchResults` (`.menu-results`) - list of menu items
* when not searching: `FirstLevel` (`.menu-items`) - the actual menu
* `MenuCollapse` (`.menu-collapse`) - bottom expand/collapse button

Second level SideNav only contains `SecondLevel` which is a simple `SideNavItems` with `SideNavMenu` and `SideNavMenuItem` items.

`FirstLevel` is a `SideNavItems` with `SideNavLink` for items, but needs a custom `SideNavMenuLink` to display the right chevron for sections.