ES6 Plato on Github
Report Home
Summary Display
components/Menu/Menu.js
Maintainability
73.55
Lines of code
116
Difficulty
15.47
Estimated Errors
0.55
Function weight
By Complexity
By SLOC
import React from 'react'; import { Link } from 'react-router-dom'; import { LinkContainer } from 'react-router-bootstrap' import { Glyphicon, Nav, NavItem, Navbar } from 'react-bootstrap'; import logo from '../../images/ebs.gif'; import './Menu.css'; import './glyhicon-spinner.css'; import BreadCrumbs from '../Breadcrumbs/BreadCrumbs.js'; export class Menu extends React.Component { constructor(props) { super(props); this.onLogOutClicked = this.onLogOutClicked.bind(this); } onLogOutClicked(e) { this.props.doLogOut(); } getLoggedOutRender() { return <Navbar fluid inverse fixedTop> <Navbar.Header> <Navbar.Brand> <Link to="/investigations" ><img alt="" src={logo} className='logo' /></Link> </Navbar.Brand> <Navbar.Toggle /> </Navbar.Header> </Navbar>; } getOpenDataMenuItem() { if (this.props.datacollections.fetching) { return <LinkContainer to='/public'> <NavItem eventKey={3} href='/public'> Open Data<span style={{ marginLeft: '10px' }} className="glyphicon glyphicon-repeat fast-right-spinner"></span> </NavItem> </LinkContainer>; } return <LinkContainer to='/public'> <NavItem eventKey={3} href='/public'> Open Data<span className="badge" style={{ marginLeft: '10px' }}>{this.props.datacollections.data.length}</span> </NavItem> </LinkContainer>; } getClosedDataMenuItem() { if (this.props.investigations.fetching) { return <LinkContainer to='/closed'> <NavItem eventKey={4} href='/closed'> Closed Data<span style={{ marginLeft: '10px' }} class="glyphicon glyphicon-repeat fast-right-spinner"></span> </NavItem> </LinkContainer>; } return <LinkContainer to='/closed'> <NavItem eventKey={4} href='/closed'> Closed Data<span className="badge" style={{ marginLeft: '10px' }}>{this.props.investigations.data.length}</span> </NavItem> </LinkContainer>; } render() { /** If there is not sessionId it means that we are not already been authenticated **/ if ((!this.props.user) || (!this.props.user.sessionId)) { return this.getLoggedOutRender(); } return (<div> <Navbar inverse collapseOnSelect> <Navbar.Header> <Navbar.Brand> <a href="/">Datahub</a> </Navbar.Brand> <Navbar.Toggle /> </Navbar.Header> <Navbar.Collapse> <Nav> <LinkContainer to='/search'> <NavItem eventKey={2} href='/search'> <span> <Glyphicon style={{ fontSize: '20px' }} glyph="glyphicon glyphicon-search" /> <sub style={{ color: 'red', fontSize: '10px', marginLeft: '5px' }}>NEW</sub> </span> </NavItem> </LinkContainer> <LinkContainer to='/investigations'> <NavItem eventKey={3} href='/investigations'> My Data<span className="badge" style={{ marginLeft: '10px' }}>{this.props.myInvestigations.data.length} </span> </NavItem> </LinkContainer> {this.getOpenDataMenuItem()} {this.getClosedDataMenuItem()} <LinkContainer to='/selection'> <NavItem eventKey={3} href='/selection'> My Selection<span className="badge" style={{ marginLeft: '10px' }}>{this.props.selection.datasetIds.length}</span> </NavItem> </LinkContainer> </Nav> <Nav pullRight> <NavItem eventKey={2} onClick={this.onLogOutClicked} > <Glyphicon glyph="glyphicon glyphicon-log-out" /> Log out <strong>{this.props.user.fullName}</strong> </NavItem> </Nav> </Navbar.Collapse> </Navbar> <BreadCrumbs breadcrumbsList={this.props.breadcrumbsList}></BreadCrumbs> </div>) } }