<commit_before>import React from 'react';
import { connect } from 'react-redux';
import { withRouter, Link } from 'react-router';
import { ToggleVisibility } from '../../actions/ui/globalSearch';
import classnames from 'classnames';

import { Glyphicon } from 'react-bootstrap';

function handleSearchClick(event, toggleGlobalSearch) {
  event.preventDefault();
  toggleGlobalSearch();
}

function isActive(navbarPath, fragment) {
  if (navbarPath === 'requests' || navbarPath === 'request') {
    return _.contains(['requests', 'request'], fragment);
  }
  if (navbarPath === 'tasks' || navbarPath === 'task') {
    return _.contains(['tasks', 'task'], fragment);
  }
  if (navbarPath === 'admin') {
    return (
      fragment === 'racks' ||
      fragment === 'slaves' ||
      fragment === 'webhooks' ||
      fragment === 'task-search'
    );
  }
  if (navbarPath === '/') {
    return fragment === '';
  }
  return navbarPath === fragment;
}

// put into page wrapper, render children
const Navigation = (props) => {
  const fragment = props.location.pathname.split('/')[1];
  return (
    <nav className="navbar navbar-default">
      <div className="container-fluid">
        <div className="navbar-header">
          <Link className="navbar-brand" to="/">{config.title}</Link>
        </div>
        <div className="collapse navbar-collapse" id="navbar-collapse">
          <ul className="nav navbar-nav">
            <li className={classnames({active: isActive('/', fragment)})}>
              <Link to="/">Dashboard {isActive('/', fragment) && <span className="sr-only">(current)</span>}</Link>
            </li>
            <li className={classnames({active: isActive('status', fragment)})}>
              <Link to="/status">Status {isActive('status', fragment) && <span className="sr-only">(current)</span>}</Link>
            </li>
            <li className={classnames({active: isActive('requests', fragment)})}>
              <Link to="/requests">Requests {isActive('requests', fragment) && <span className="sr-only">(current)</span>}</Link>
            </li>
            <li className={classnames({active: isActive('tasks', fragment)})}>
              <Link to="/tasks">Tasks {isActive('tasks', fragment) && <span className="sr-only">(current)</span>}</Link>
            </li>
            <li className={classnames('dropdown', {active: isActive('admin', fragment)})}>
              <a href="#" className="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                Admin <span className="caret"></span>
              </a>
              <ul className="dropdown-menu"><commit_msg>Nav bar can now be expanded in mobile view<commit_after>import React from 'react';
import { connect } from 'react-redux';
import { withRouter, Link } from 'react-router';
import { ToggleVisibility } from '../../actions/ui/globalSearch';
import classnames from 'classnames';

import { Glyphicon } from 'react-bootstrap';

function handleSearchClick(event, toggleGlobalSearch) {
  event.preventDefault();
  toggleGlobalSearch();
}

function isActive(navbarPath, fragment) {
  if (navbarPath === 'requests' || navbarPath === 'request') {
    return _.contains(['requests', 'request'], fragment);
  }
  if (navbarPath === 'tasks' || navbarPath === 'task') {
    return _.contains(['tasks', 'task'], fragment);
  }
  if (navbarPath === 'admin') {
    return (
      fragment === 'racks' ||
      fragment === 'slaves' ||
      fragment === 'webhooks' ||
      fragment === 'task-search'
    );
  }
  if (navbarPath === '/') {
    return fragment === '';
  }
  return navbarPath === fragment;
}

// put into page wrapper, render children
const Navigation = (props) => {
  const fragment = props.location.pathname.split('/')[1];
  return (
    <nav className="navbar navbar-default">
      <div className="container-fluid">
        <div className="navbar-header">
          <button type="button" className="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse" aria-expanded="false">
            <span className="sr-only">Toggle navigation</span>
            <span className="icon-bar"></span>
            <span className="icon-bar"></span>
            <span className="icon-bar"></span>
          </button>
          <Link className="navbar-brand" to="/">{config.title}</Link>
        </div>
        <div className="collapse navbar-collapse" id="navbar-collapse">
          <ul className="nav navbar-nav">
            <li className={classnames({active: isActive('/', fragment)})}>
              <Link to="/">Dashboard {isActive('/', fragment) && <span className="sr-only">(current)</span>}</Link>
            </li>
            <li className={classnames({active: isActive('status', fragment)})}>
              <Link to="/status">Status {isActive('status', fragment) && <span className="sr-only">(current)</span>}</Link>
            </li>
            <li className={classnames({active: isActive('requests', fragment)})}>
              <Link to="/requests">Requests {isActive('requests', fragment) && <span className="sr-only">(current)</span>}</Link>
            </li>
            <li className={classnames({active: isActive('tasks', fragment)})}>
              <Link to="/tasks">Tasks {isActive('tasks', fragment) && <span className="sr-only">(current)</span>}</Link>
            </li>
            <li className={classnames('dropdown', {active: isActive('admin', fragment)})}>
              <a href="#" className="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                Admin <span className="caret"></span>
              </a>
              <ul className="dropdown-menu">
{'fraction_non_alphanumeric': 0.1857443820224719, 'fraction_numerical': 0.00035112359550561797, 'mean_word_length': 3.195139911634757, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 91, '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': '1882183', 'n_tokens_mistral': 1576, 'n_tokens_neox': 1553, 'n_words': 350}