<commit_before>import React, { Component, PropTypes } from 'react'
import { Navbar, Button, ButtonToolbar, Checkbox } from 'react-bootstrap'

import SidebarNavItem from './SidebarNavItem'
import SidebarPopover from './SidebarPopover'
import JobMonitor from './JobMonitor'

export default class Sidebar extends Component {

  static propTypes = {
    expanded: PropTypes.bool,
    jobMonitor: PropTypes.object,
    username: PropTypes.string,

    loginHandler: PropTypes.func,
    logoutHandler: PropTypes.func,
    resetPasswordHandler: PropTypes.func,
    setJobMonitorVisible: PropTypes.func,
    setSidebarExpanded: PropTypes.func
  }

  constructor (props) {
    super(props)
    this.state = {
      visiblePopover: null
    }
  }

  componentWillReceiveProps (nextProps) {
    if (!this.props.jobMonitor.timer && nextProps.jobMonitor.timer) {
      this.setState({ visiblePopover: 'job' })
    }
  }

  navSelected (key) {
    this.setState({visiblePopover: (key === this.state.visiblePopover) ? null : key})
  }

  render () {
    const messages = DT_CONFIG.messages.active.DatatoolsNavbar

    const navbarStyle = {
      width: this.props.expanded ? 150 : 50,
      height: '100%',
      position: 'fixed',
      borderRadius: 0
    }

    const logoContainerStyle = {
      position: 'fixed',
      top: 10,
      left: 10
    }

    const logoIconStyle = {
      float: 'left',
      background: '#bbb',
      width: 30,
      height: 30,
      fontSize: 24,
      fontWeight: 'bold',
      textAlign: 'center',
      lineHeight: '120%',
    }

    const logoLabelStyle = {
      marginLeft: 40,
      lineHeight: '95%',
      color: '#bbb',
      fontSize: 16
    }

    const closePopover = () => this.setState({visiblePopover: null})

    return <div>
      <Navbar
        inverse
        style={navbarStyle}
      >
        <div style={logoContainerStyle}>
          <div style={logoIconStyle}>G</div>
          {this.props.expanded
            ? <div style={logoLabelStyle}>GTFS Data<br/>Manager</div>
            : null
          }
          <div style={{ clear: 'both' }} />
        </div>

        <div style={{ position: 'absolute', top: 60 }}>
          {this.props.children}
        </div>

        <div style={{ position: 'absolute', bottom: 10 }}>
          <SidebarNavItem ref='jobNav' expanded={this.props.expanded}
            icon='bell' label='Job Monitor'
            onClick={() => this.navSelected('job')} />
          <SidebarNavItem ref='userNav' expanded={this.props.expanded}
            icon='user' label='Account'
            onClick={() => this.navSelected('user')} />
          <SidebarNavItem ref='settingsNav' expanded={this.props.expanded}
            icon='gear' label='Settings'
            onClick={() => this.navSelected('help')} />
        </div>
      </Navbar>

      {/* Job Monitor Popover
      <JobMonitor
        jobMonitor={this.props.jobMonitor}
        target={this.refs.jobNav}
        expanded={this.props.expanded}
        visible={() => this.state.visiblePopover === 'job' }
        close={() => closePopover()}
      />*/}

      {/* User Popover */}
      <SidebarPopover target={this.refs.userNav} title={this.props.username}
        expanded={this.props.expanded}
        visible={() => this.state.visiblePopover === 'user' }
        close={() => closePopover()}
      >
        <ButtonToolbar>
          <Button bsSize='small' bsStyle='info' onClick={() => {
            this.setState({ visiblePopover: null })
            this.props.resetPasswordHandler()<commit_msg>Re-activate job monitor<commit_after>import React, { Component, PropTypes } from 'react'
import { Navbar, Button, ButtonToolbar, Checkbox } from 'react-bootstrap'

import SidebarNavItem from './SidebarNavItem'
import SidebarPopover from './SidebarPopover'
import JobMonitor from './JobMonitor'

export default class Sidebar extends Component {

  static propTypes = {
    expanded: PropTypes.bool,
    jobMonitor: PropTypes.object,
    username: PropTypes.string,

    loginHandler: PropTypes.func,
    logoutHandler: PropTypes.func,
    resetPasswordHandler: PropTypes.func,
    setJobMonitorVisible: PropTypes.func,
    setSidebarExpanded: PropTypes.func
  }

  constructor (props) {
    super(props)
    this.state = {
      visiblePopover: null
    }
  }

  componentWillReceiveProps (nextProps) {
    if (!this.props.jobMonitor.timer && nextProps.jobMonitor.timer) {
      this.setState({ visiblePopover: 'job' })
    }
  }

  navSelected (key) {
    this.setState({visiblePopover: (key === this.state.visiblePopover) ? null : key})
  }

  render () {
    const messages = DT_CONFIG.messages.active.DatatoolsNavbar

    const navbarStyle = {
      width: this.props.expanded ? 150 : 50,
      height: '100%',
      position: 'fixed',
      borderRadius: 0
    }

    const logoContainerStyle = {
      position: 'fixed',
      top: 10,
      left: 10
    }

    const logoIconStyle = {
      float: 'left',
      background: '#bbb',
      width: 30,
      height: 30,
      fontSize: 24,
      fontWeight: 'bold',
      textAlign: 'center',
      lineHeight: '120%',
    }

    const logoLabelStyle = {
      marginLeft: 40,
      lineHeight: '95%',
      color: '#bbb',
      fontSize: 16
    }

    const closePopover = () => this.setState({visiblePopover: null})

    return <div>
      <Navbar
        inverse
        style={navbarStyle}
      >
        <div style={logoContainerStyle}>
          <div style={logoIconStyle}>G</div>
          {this.props.expanded
            ? <div style={logoLabelStyle}>GTFS Data<br/>Manager</div>
            : null
          }
          <div style={{ clear: 'both' }} />
        </div>

        <div style={{ position: 'absolute', top: 60 }}>
          {this.props.children}
        </div>

        <div style={{ position: 'absolute', bottom: 10 }}>
          <SidebarNavItem ref='jobNav' expanded={this.props.expanded}
            icon='bell' label='Job Monitor'
            onClick={() => this.navSelected('job')} />
          <SidebarNavItem ref='userNav' expanded={this.props.expanded}
            icon='user' label='Account'
            onClick={() => this.navSelected('user')} />
          <SidebarNavItem ref='settingsNav' expanded={this.props.expanded}
            icon='gear' label='Settings'
            onClick={() => this.navSelected('help')} />
        </div>
      </Navbar>

      {/* Job Monitor Popover */}
      <JobMonitor
        jobMonitor={this.props.jobMonitor}
        target={this.refs.jobNav}
        expanded={this.props.expanded}
        visible={() => this.state.visiblePopover === 'job' }
        close={() => closePopover()}
      />

      {/* User Popover */}
      <SidebarPopover target={this.refs.userNav} title={this.props.username}
        expanded={this.props.expanded}
        visible={() => this.state.visiblePopover === 'user' }
        close={() => closePopover()}
      >
        <ButtonToolbar>
          <Button bsSize='small' bsStyle='info' onClick={() => {
            this.setState({ visiblePopover: null })
            this.props.resetPasswordHandler()
{'fraction_non_alphanumeric': 0.14071983062808752, 'fraction_numerical': 0.00903316866619619, 'mean_word_length': 2.434803683955405, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 63, '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': '5441445', 'n_tokens_mistral': 2143, 'n_tokens_neox': 2108, 'n_words': 431}