badguardhome/client/src/components/Header/index.js

79 lines
2.8 KiB
JavaScript
Raw Normal View History

2018-08-30 14:25:33 +00:00
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import classnames from 'classnames';
2018-10-29 03:26:19 +00:00
import { Trans, withNamespaces } from 'react-i18next';
2018-08-30 14:25:33 +00:00
import Menu from './Menu';
import Version from './Version';
2019-01-18 17:17:48 +00:00
import logo from '../ui/svg/logo.svg';
2018-08-30 14:25:33 +00:00
import './Header.css';
class Header extends Component {
state = {
isMenuOpen: false,
};
toggleMenuOpen = () => {
this.setState(prevState => ({ isMenuOpen: !prevState.isMenuOpen }));
};
closeMenu = () => {
this.setState({ isMenuOpen: false });
};
render() {
const { dashboard } = this.props;
const { isMenuOpen } = this.state;
2018-08-30 14:25:33 +00:00
const badgeClass = classnames({
'badge dns-status': true,
'badge-success': dashboard.protectionEnabled,
'badge-danger': !dashboard.protectionEnabled,
2018-08-30 14:25:33 +00:00
});
return (
<div className="header">
<div className="container">
<div className="row align-items-center">
<div className="header-toggler d-lg-none ml-2 ml-lg-0 collapsed" onClick={this.toggleMenuOpen}>
<span className="header-toggler-icon"></span>
</div>
<div className="col col-lg-3">
<div className="d-flex align-items-center">
<Link to="/" className="nav-link pl-0 pr-1">
<img src={logo} alt="" className="header-brand-img" />
</Link>
2018-10-11 08:08:07 +00:00
{!dashboard.proccessing && dashboard.isCoreRunning &&
2018-08-30 14:25:33 +00:00
<span className={badgeClass}>
2018-11-09 06:51:28 +00:00
<Trans>{dashboard.protectionEnabled ? 'on' : 'off'}</Trans>
2018-08-30 14:25:33 +00:00
</span>
}
</div>
</div>
<Menu
location={this.props.location}
isMenuOpen={isMenuOpen}
2018-08-30 14:25:33 +00:00
toggleMenuOpen={this.toggleMenuOpen}
closeMenu={this.closeMenu}
/>
{!dashboard.processing &&
<div className="col col-sm-6 col-lg-3">
<Version
{ ...this.props.dashboard }
/>
</div>
}
2018-08-30 14:25:33 +00:00
</div>
</div>
</div>
);
}
}
Header.propTypes = {
dashboard: PropTypes.object,
location: PropTypes.object,
};
2018-10-29 03:26:19 +00:00
export default withNamespaces()(Header);