<commit_before>'use strict';

import React from 'react';
import {Link} from 'react-router';
import Component from '../components/component.react';
import {signOut} from '../users/actions';
import {flash} from '../flashMessages/actions';

class Header extends Component {

  constructor(props) {
    super(props);
    this.state = { menu: false };
  }

  componentDidMount() {
    document.body.addEventListener('click', this.onClickOutside.bind(this));
  }

  componentWillUnmount() {
    document.body.removeEventListener('click', this.onClickOutside);
  }

  signOut() {
    signOut();

    flash('Successfuly signed out.');

    this.props.router.transitionTo('signin');
  }

  onClick(e) {
    e.preventDefault();
    this.setState({ menu: !this.state.menu });
  }

  onClickOutside() {
    this.setState({ menu: false });
  }

  render() {
    let className = ['dropdown'];
    if (this.state.menu)
      className.push('open');

    let menu = [
      'dashboard', 'applications', 'messages',
      'templates', 'directory'
    ];
    let user = {};
    if (this.props.user) {
      user = this.props.user;
      if (user.role === 'admin')
        menu.push('users');
        menu.push('phones');
        menu.push('inbox');
    }

    return (
      <nav className="navbar navbar-static-top">
        <div className="container-fluid">
          <div id="navbar" className="navbar-collapse collapse">
            <Link to="dashboard" className="navbar-brand"><commit_msg>Header Component: fixing adding admin menu items<commit_after>'use strict';

import React from 'react';
import {Link} from 'react-router';
import Component from '../components/component.react';
import {signOut} from '../users/actions';
import {flash} from '../flashMessages/actions';

class Header extends Component {

  constructor(props) {
    super(props);
    this.state = { menu: false };
  }

  componentDidMount() {
    document.body.addEventListener('click', this.onClickOutside.bind(this));
  }

  componentWillUnmount() {
    document.body.removeEventListener('click', this.onClickOutside);
  }

  signOut() {
    signOut();

    flash('Successfuly signed out.');

    this.props.router.transitionTo('signin');
  }

  onClick(e) {
    e.preventDefault();
    this.setState({ menu: !this.state.menu });
  }

  onClickOutside() {
    this.setState({ menu: false });
  }

  render() {
    let className = ['dropdown'];
    if (this.state.menu)
      className.push('open');

    let menu = [
      'dashboard', 'applications', 'messages',
      'templates', 'directory'
    ];
    let user = {};
    if (this.props.user) {
      user = this.props.user;
      if (user.role === 'admin') {
        menu.push('users');
        menu.push('phones');
        menu.push('inbox');
      }
    }

    return (
      <nav className="navbar navbar-static-top">
        <div className="container-fluid">
          <div id="navbar" className="navbar-collapse collapse">
            <Link to="dashboard" className="navbar-brand">
{'fraction_non_alphanumeric': 0.1630543514504835, 'fraction_numerical': 0.0, 'mean_word_length': 2.9946737683089215, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2119622', 'n_tokens_mistral': 905, 'n_tokens_neox': 884, 'n_words': 187}