diff --git a/app/helpers/application_helper/navbar.rb b/app/helpers/application_helper/navbar.rb index 0b3dcf4b22d..2ef1b684eb5 100644 --- a/app/helpers/application_helper/navbar.rb +++ b/app/helpers/application_helper/navbar.rb @@ -4,7 +4,6 @@ def menu_to_json(placement = :default) structure = [] Menu::Manager.menu(placement) do |menu_section| next unless menu_section.visible? - structure << item_to_hash(menu_section) end structure @@ -16,6 +15,7 @@ def item_to_hash(item) :title => item.name, :iconClass => item.icon, :href => item.link_params[:href], + :type => item.type, :preventHref => !item.href, :visible => item.visible?, :active => item_active?(item), diff --git a/app/javascript/components/main-menu/helpers.js b/app/javascript/components/main-menu/helpers.js new file mode 100644 index 00000000000..38dd5566002 --- /dev/null +++ b/app/javascript/components/main-menu/helpers.js @@ -0,0 +1,7 @@ +export const getHrefByType = (type, href, id) => ( + { + big_iframe: `/dashboard/iframe?id=${id}`, + // eslint-disable-next-line no-script-url + modal: 'javascript:void(0);', + } +)[type] || href; diff --git a/app/javascript/components/main-menu/second-level.jsx b/app/javascript/components/main-menu/second-level.jsx index b8801f1f591..a2a48a5011f 100644 --- a/app/javascript/components/main-menu/second-level.jsx +++ b/app/javascript/components/main-menu/second-level.jsx @@ -2,6 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { MenuItem } from './main-menu'; import { menuProps } from './recursive-props'; +import { getHrefByType } from './helpers'; const SecondLevel = ({ id, @@ -9,9 +10,17 @@ const SecondLevel = ({ href, items, level, + type, }) => (
  • 0 ? 'tertiary-nav-item-pf' : ''}`} data-target={`#menu-${id}`}> - + { + window.miqCheckForChanges(); + return type === 'modal' && sendDataWithRx({ type: 'showAboutModal' }); + }} + target={type === 'new_window' ? '_blank' : '_self'} + > {title}
    diff --git a/app/javascript/components/main-menu/third-level.jsx b/app/javascript/components/main-menu/third-level.jsx index f316d06d6d5..e682d846d08 100644 --- a/app/javascript/components/main-menu/third-level.jsx +++ b/app/javascript/components/main-menu/third-level.jsx @@ -1,5 +1,6 @@ import React from 'react'; import { menuProps } from './recursive-props'; +import { getHrefByType } from './helpers'; const ThirdLevel = ({ id, @@ -7,9 +8,17 @@ const ThirdLevel = ({ href, active, visible, + type, }) => (!visible ? null : (
  • - + { + window.miqCheckForChanges(); + return type === 'modal' && sendDataWithRx({ type: 'showAboutModal' }); + }} + target={type === 'new_window' ? '_blank' : '_self'} + > {title}
  • diff --git a/app/javascript/components/main-menu/top-level.jsx b/app/javascript/components/main-menu/top-level.jsx index e841ca05cea..0bd37c96f5a 100644 --- a/app/javascript/components/main-menu/top-level.jsx +++ b/app/javascript/components/main-menu/top-level.jsx @@ -2,6 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { MenuItem } from './main-menu'; import { menuProps, RecursiveMenuProps } from './recursive-props'; +import { getHrefByType } from './helpers'; const TopLevel = ({ level, @@ -11,9 +12,17 @@ const TopLevel = ({ href, active, items, + type, }) => (
  • - + { + window.miqCheckForChanges(); + return type === 'modal' && sendDataWithRx({ type: 'showAboutModal' }); + }} + target={type === 'new_window' ? '_blank' : '_self'} + > {title} diff --git a/app/javascript/spec/main-menu/__snapshots__/main-menu.spec.js.snap b/app/javascript/spec/main-menu/__snapshots__/main-menu.spec.js.snap index ff0f8277b0f..de7d3dbcb46 100644 --- a/app/javascript/spec/main-menu/__snapshots__/main-menu.spec.js.snap +++ b/app/javascript/spec/main-menu/__snapshots__/main-menu.spec.js.snap @@ -18,6 +18,7 @@ exports[`Main menu test should render correctly 1`] = ` "items": Array [], "preventHref": false, "title": "Dashboard", + "type": "modal", "visible": true, }, Object { @@ -28,11 +29,13 @@ exports[`Main menu test should render correctly 1`] = ` "items": Array [], "preventHref": false, "title": "Chargeback", + "type": "big_iframe", "visible": true, }, ], "preventHref": true, "title": "Cloud Intel", + "type": "default", "visible": true, }, Object { @@ -55,6 +58,7 @@ exports[`Main menu test should render correctly 1`] = ` "items": Array [], "preventHref": false, "title": "Providers", + "type": "new_window", "visible": true, }, Object { @@ -65,6 +69,7 @@ exports[`Main menu test should render correctly 1`] = ` "items": Array [], "preventHref": false, "title": "Availability Zones", + "type": "default", "visible": true, }, Object { @@ -75,16 +80,19 @@ exports[`Main menu test should render correctly 1`] = ` "items": Array [], "preventHref": false, "title": "Host Aggregates", + "type": "new_window", "visible": false, }, ], "preventHref": true, "title": "Clouds", + "type": "new_window", "visible": true, }, ], "preventHref": true, "title": "Compute", + "type": "new_window", "visible": true, }, ] @@ -121,6 +129,7 @@ exports[`Main menu test should render correctly 1`] = ` "items": Array [], "preventHref": false, "title": "Dashboard", + "type": "modal", "visible": true, }, Object { @@ -131,6 +140,7 @@ exports[`Main menu test should render correctly 1`] = ` "items": Array [], "preventHref": false, "title": "Chargeback", + "type": "big_iframe", "visible": true, }, ] @@ -139,6 +149,7 @@ exports[`Main menu test should render correctly 1`] = ` level={0} preventHref={true} title="Cloud Intel" + type="default" visible={true} >
  • diff --git a/app/javascript/spec/main-menu/main-menu.spec.js b/app/javascript/spec/main-menu/main-menu.spec.js index b7ba09e0d1e..f9021747e0d 100644 --- a/app/javascript/spec/main-menu/main-menu.spec.js +++ b/app/javascript/spec/main-menu/main-menu.spec.js @@ -18,6 +18,7 @@ describe('Main menu test', () => { preventHref: true, visible: true, active: true, + type: 'default', items: [{ id: 'dashboard', title: 'Dashboard', @@ -26,6 +27,7 @@ describe('Main menu test', () => { preventHref: false, visible: true, active: true, + type: 'modal', items: [], }, { id: 'chargeback', @@ -35,6 +37,7 @@ describe('Main menu test', () => { preventHref: false, visible: true, active: false, + type: 'big_iframe', items: [], }], }, { @@ -45,6 +48,7 @@ describe('Main menu test', () => { preventHref: true, visible: true, active: false, + type: 'new_window', items: [{ id: 'clo', title: 'Clouds', @@ -53,6 +57,7 @@ describe('Main menu test', () => { preventHref: true, visible: true, active: false, + type: 'new_window', items: [{ id: 'ems_cloud', title: 'Providers', @@ -61,6 +66,7 @@ describe('Main menu test', () => { preventHref: false, visible: true, active: true, + type: 'new_window', items: [], }, { id: 'availability_zone', @@ -70,6 +76,7 @@ describe('Main menu test', () => { preventHref: false, visible: true, active: false, + type: 'default', items: [], }, { id: 'host_aggregate', @@ -79,6 +86,7 @@ describe('Main menu test', () => { preventHref: false, visible: false, active: false, + type: 'new_window', items: [], }], }],