diff --git a/webpack/assets/javascripts/react_app/components/Layout/Layout.fixtures.js b/webpack/assets/javascripts/react_app/components/Layout/Layout.fixtures.js index 8c0a00c57378..43d51d910850 100644 --- a/webpack/assets/javascripts/react_app/components/Layout/Layout.fixtures.js +++ b/webpack/assets/javascripts/react_app/components/Layout/Layout.fixtures.js @@ -15,6 +15,14 @@ const subItemsA = [ href: '/c', id: 'menu_item_cc', }, + + { + title: 'Ac', + isDivider: false, + onClick: mockOnClick, + href: '/ac', + id: 'menu_item_ac', + }, ]; const subItemsB = [ { @@ -26,7 +34,7 @@ const subItemsB = [ }, ]; -const PFitems = [ +export const PFitems = [ { title: 'Monitor', initialActive: true, @@ -40,31 +48,6 @@ const PFitems = [ subItems: subItemsB, }, ]; -// Server Hash Data -const monitorChildren = [ - { - type: 'item', - name: 'Dashboard', - title: 'Dashboard', - exact: true, - url: '/', - }, - { - type: 'item', - name: 'Facts', - title: 'Facts', - url: '/fact_values', - }, -]; - -const hostsChildren = [ - { - type: 'item', - name: 'All Hosts', - title: 'All Hosts', - url: '/hosts/new', - }, -]; const namelessChildren = [ { @@ -76,21 +59,6 @@ const namelessChildren = [ }, ]; -const hashItemsA = [ - { - type: 'sub_menu', - name: 'Monitor', - icon: 'fa fa-tachometer', - children: monitorChildren, - }, - { - type: 'sub_menu', - name: 'Hosts', - icon: 'fa fa-server', - children: hostsChildren, - }, -]; - export const hashItemNameless = [ { type: 'sub_menu', diff --git a/webpack/assets/javascripts/react_app/components/Layout/LayoutSelectors.js b/webpack/assets/javascripts/react_app/components/Layout/LayoutSelectors.js index 5fd99f86544b..918163a0703f 100644 --- a/webpack/assets/javascripts/react_app/components/Layout/LayoutSelectors.js +++ b/webpack/assets/javascripts/react_app/components/Layout/LayoutSelectors.js @@ -1,5 +1,4 @@ import { snakeCase } from 'lodash'; -import { noop } from '../../common/helpers'; export const selectLayout = state => state.layout; @@ -37,7 +36,6 @@ const childToMenuItem = (child, currentLocation, currentOrganization) => ({ child.title === currentLocation || child.title === currentOrganization ? 'mobile-active' : '', - href: child.url || '#', - preventHref: true, - onClick: child.onClick || noop, + href: child.url, + onClick: child.onClick, }); diff --git a/webpack/assets/javascripts/react_app/components/Layout/Navigation.js b/webpack/assets/javascripts/react_app/components/Layout/Navigation.js index 5bc5a75ff969..37af20e873ce 100644 --- a/webpack/assets/javascripts/react_app/components/Layout/Navigation.js +++ b/webpack/assets/javascripts/react_app/components/Layout/Navigation.js @@ -9,6 +9,7 @@ import { NavItemSeparator, } from '@patternfly/react-core'; import { getCurrentPath } from './LayoutHelper'; +import { NavigationSearch } from './NavigationSearch'; const titleWithIcon = (title, iconClass) => (
@@ -43,7 +44,7 @@ const Navigation = ({ items.forEach(item => { item.subItems.forEach(subItem => { - if (!subItem.isDivider) { + if (!subItem.isDivider && subItem.href) { // don't keep the query parameters for the key subItemToItemMap[pathFragment(subItem.href)] = item.title; } @@ -68,7 +69,7 @@ const Navigation = ({ } else { groups[currIndex].groupItems.push({ ...sub, - isActive: currentPath === sub.href.split('?')[0], + isActive: currentPath === sub.href?.split('?')[0], }); } }); @@ -79,13 +80,17 @@ const Navigation = ({ [items.length, currentPath] ); + if (!items.length) return null; + const clickAndNavigate = (_onClick, href) => { _onClick && _onClick(); setCurrentPath(href); }; + return (