Skip to content

Commit

Permalink
Added support for missing link_params from review
Browse files Browse the repository at this point in the history
  • Loading branch information
fhlavac committed Aug 6, 2019
1 parent 2258cdd commit f2bcbc1
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/helpers/application_helper/navbar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand Down
7 changes: 7 additions & 0 deletions app/javascript/components/main-menu/helpers.js
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 10 additions & 1 deletion app/javascript/components/main-menu/second-level.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,25 @@ 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,
title,
href,
items,
level,
type,
}) => (
<li className={`list-group-item ${items.length > 0 ? 'tertiary-nav-item-pf' : ''}`} data-target={`#menu-${id}`}>
<a href={href}>
<a
href={getHrefByType(type, href, id)}
onMouseDown={() => {
window.miqCheckForChanges();
return type === 'modal' && sendDataWithRx({ type: 'showAboutModal' });
}}
target={type === 'new_window' ? '_blank' : '_self'}
>
<span className="list-group-item-value">{title}</span>
</a>
<div className="nav-pf-tertiary-nav">
Expand Down
11 changes: 10 additions & 1 deletion app/javascript/components/main-menu/third-level.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import React from 'react';
import { menuProps } from './recursive-props';
import { getHrefByType } from './helpers';

const ThirdLevel = ({
id,
title,
href,
active,
visible,
type,
}) => (!visible ? null : (
<li className={`list-group-item ${active ? 'active' : ''}`} id={`menu_item_${id}`}>
<a href={href}>
<a
href={getHrefByType(type, href, id)}
onMouseDown={() => {
window.miqCheckForChanges();
return type === 'modal' && sendDataWithRx({ type: 'showAboutModal' });
}}
target={type === 'new_window' ? '_blank' : '_self'}
>
<span className="list-group-item-value">{title}</span>
</a>
</li>
Expand Down
11 changes: 10 additions & 1 deletion app/javascript/components/main-menu/top-level.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -11,9 +12,17 @@ const TopLevel = ({
href,
active,
items,
type,
}) => (
<li className={`${active ? 'active' : ''} list-group-item secondary-nav-item-pf`} data-target={`#menu-${id}`}>
<a href={href}>
<a
href={getHrefByType(type, href, id)}
onMouseDown={() => {
window.miqCheckForChanges();
return type === 'modal' && sendDataWithRx({ type: 'showAboutModal' });
}}
target={type === 'new_window' ? '_blank' : '_self'}
>
<span className={iconClass} />
<span className="list-group-item-value">{title}</span>
</a>
Expand Down
Loading

0 comments on commit f2bcbc1

Please sign in to comment.