Merge + client: close sidebar menu on mobiles screen after choosing

Close #1318

* commit '2c6e3d0e91af59304128e7a94b1f13362b4b4117':
  + client: add comment about order of settings dropdown order
  + client: close sidebar menu on mobiles screen after choosing
This commit is contained in:
Artem Baskal 2020-01-17 11:34:48 +03:00
commit 2bc2b342eb
2 changed files with 48 additions and 61 deletions

View File

@ -8,6 +8,32 @@ import { Trans, withNamespaces } from 'react-i18next';
import { SETTINGS_URLS } from '../../helpers/constants';
import Dropdown from '../ui/Dropdown';
const MENU_ITEMS = [
{
route: '', exact: true, xlinkHref: 'dashboard', text: 'dashboard', order: 0,
},
// Settings dropdown should have visual order 1
{
route: 'filters', xlinkHref: 'filters', text: 'filters', order: 2,
},
{
route: 'logs', xlinkHref: 'log', text: 'query_log', order: 3,
},
{
route: 'guide', xlinkHref: 'setup', text: 'setup_guide', order: 4,
},
];
const DROPDOWN_ITEMS = [
{ route: 'settings', text: 'general_settings' },
{ route: 'dns', text: 'dns_settings' },
{ route: 'encryption', text: 'encryption_settings' },
{ route: 'clients', text: 'client_settings' },
{ route: 'dhcp', text: 'dhcp_settings' },
];
class Menu extends Component {
handleClickOutside = () => {
this.props.closeMenu();
@ -36,70 +62,31 @@ class Menu extends Component {
<Fragment>
<div className={menuClass}>
<ul className="nav nav-tabs border-0 flex-column flex-lg-row flex-nowrap">
<li className="nav-item border-bottom d-lg-none" onClick={this.toggleMenu}>
<div className="nav-link nav-link--back">
{MENU_ITEMS.map(({
route, text, exact, xlinkHref, order,
}) => (
<li className={`nav-item order-${order}`} key={text} onClick={this.toggleMenu}>
<NavLink to={`/${route}`} exact={exact || false} className="nav-link">
<svg className="nav-icon">
<use xlinkHref="#back" />
<use xlinkHref={`#${xlinkHref}`} />
</svg>
<Trans>back</Trans>
</div>
</li>
<li className="nav-item">
<NavLink to="/" exact={true} className="nav-link">
<svg className="nav-icon">
<use xlinkHref="#dashboard" />
</svg>
<Trans>dashboard</Trans>
<Trans>{text}</Trans>
</NavLink>
</li>
))}
<Dropdown
label={this.props.t('settings')}
baseClassName="dropdown nav-item"
baseClassName="dropdown nav-item order-1"
controlClassName={dropdownControlClass}
icon="settings"
>
<Fragment>
<NavLink to="/settings" className="dropdown-item">
<Trans>general_settings</Trans>
{DROPDOWN_ITEMS.map(({ route, text }) => (
<NavLink to={`/${route}`} className="dropdown-item" key={text}
onClick={this.toggleMenu}>
<Trans>{text}</Trans>
</NavLink>
<NavLink to="/dns" className="dropdown-item">
<Trans>dns_settings</Trans>
</NavLink>
<NavLink to="/encryption" className="dropdown-item">
<Trans>encryption_settings</Trans>
</NavLink>
<NavLink to="/clients" className="dropdown-item">
<Trans>client_settings</Trans>
</NavLink>
<NavLink to="/dhcp" className="dropdown-item">
<Trans>dhcp_settings</Trans>
</NavLink>
</Fragment>
))}
</Dropdown>
<li className="nav-item">
<NavLink to="/filters" className="nav-link">
<svg className="nav-icon">
<use xlinkHref="#filters" />
</svg>
<Trans>filters</Trans>
</NavLink>
</li>
<li className="nav-item">
<NavLink to="/logs" className="nav-link">
<svg className="nav-icon">
<use xlinkHref="#log" />
</svg>
<Trans>query_log</Trans>
</NavLink>
</li>
<li className="nav-item">
<NavLink to="/guide" className="nav-link">
<svg className="nav-icon">
<use xlinkHref="#setup" />
</svg>
<Trans>setup_guide</Trans>
</NavLink>
</li>
</ul>
</div>
</Fragment>

View File

@ -38,7 +38,7 @@ class Header extends Component {
className="header-toggler d-lg-none ml-lg-0 collapsed"
onClick={this.toggleMenuOpen}
>
<span className="header-toggler-icon"></span>
<span className="header-toggler-icon" />
</div>
<div className="header__column">
<div className="d-flex align-items-center">