<commit_before>import React, { PropTypes, Component } from 'react';
import { shell } from 'electron';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Link } from 'react-router';
import _ from 'lodash';
import classNames from 'classnames';
import ConnectedPlayerListItem from '../components/player/PlayerListItem';
import ConnectedHeader from '../components/Header';
import metrics from '../utils/MetricsUtil';
import * as PlayerActions from '../actions/player';
import * as BidActions from '../actions/bid';

export class Players extends Component {
  constructor(props) {
    super(props);
    this.state = {
      sidebarOffset: 0
    };
  }

  handleScroll(e) {
    if (e.target.scrollTop > 0 && !this.state.sidebarOffset) {
      this.setState({
        sidebarOffset: e.target.scrollTop
      });
    } else if (e.target.scrollTop === 0 && this.state.sidebarOffset) {
      this.setState({
        sidebarOffset: 0
      });
    }
  }

  handleClickClearList() {
    this.props.clear();
    this.context.router.push('/players');
  }

  handleClickReportIssue() {
    metrics.track('Opened Issue Reporter', {
      from: 'app'
    });
    shell.openExternal('https://github.com/hunterjm/fifa-autobuyer/issues');
  }

  handleToggleBidding() {
    if (this.props.bidding) {
      this.props.stop();
    } else {
      this.props.start();
      this.context.router.push('/players/overview');
    }
  }

  render() {
    let sidebarHeaderClass = 'sidebar-header';
    if (this.state.sidebarOffset) {
      sidebarHeaderClass += ' sep';
    }

    const players = _.map(
      _.get(this.props, 'player.list', {}),
      player => <ConnectedPlayerListItem key={player.id} player={player} />
    );

    const overviewClasses = classNames({
      state: true,
      'state-stopped': !this.props.bidding,
      'state-running': this.props.bidding,
    });

    return (
      <div className="containers">
        <ConnectedHeader hideLogin={false} />
        <div className="containers-body">
          <div className="sidebar">
            <section className={sidebarHeaderClass}>
              <h4>Player List</h4>
              <div className="create">
                {
                  this.props.location.pathname === '/players'
                  ?
                    <Link to="/settings">
                      <span className="btn btn-new btn-action has-icon btn-hollow">
                        <span className="icon icon-preferences" />Settings
                      </span>
                    </Link>
                  :
                    <Link to="/players">
                      <span className="btn btn-new btn-action has-icon btn-hollow">
                        <span className="icon icon-search" />Search
                      </span>
                    </Link>
                }
              </div>
            </section>
            <section className="sidebar-containers" onScroll={this.handleScroll.bind(this)}>
              <ul>
                <div ref={node => (this.node = node)}>
                  <Link to="/players/overview">
                    <li id="overview">
                      <div className={overviewClasses} />
                      <div className="info">
                        <div className="name">
                          Bidding Overview
                        </div>
                        <div className="image">
                          Review bidding status
                        </div>
                      </div>
                    </li>
                  </Link>
                </div>
                {players}
              </ul>
            </section>
            <section className="sidebar-buttons">
              <span className="btn-sidebar btn-database" onClick={this.handleClickClearList.bind(this)}>
                <span className="text">Clear List</span>
              </span>
              <span className="btn-sidebar btn-feedback" onClick={this.handleClickReportIssue}>
                <span className="icon icon-feedback" />
              </span>
              {
                this.props.bidding
                ?
                  (<span className="btn-sidebar btn-stop" onClick={() => this.handleToggleBidding()}>
                    <span className="icon icon-stop" />
                  </span>)
                :
                  (<span className="btn-sidebar btn-start" onClick={() => this.handleToggleBidding()}>
                    <span className="icon icon-start" />
                  </span>)
              }
            </section>
          </div>
          {this.props.children}
        </div>
      </div>
    );
  }
}

Players.propTypes = {
  children: PropTypes.element.isRequired,
  player: PropTypes.shape({}),
  location: PropTypes.shape({
    pathname: PropTypes.string
  }),
  bidding: PropTypes.bool.isRequired,
  start: PropTypes.func.isRequired,
  stop: PropTypes.func.isRequired,
  clear: PropTypes.func.isRequired,
};

Players.contextTypes = {
  router: PropTypes.object.isRequired
};

function mapStateToProps(state) {
  return {
    player: state.player,
    bidding: state.bid.bidding
  };
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators({ ...PlayerActions, ...BidActions }, dispatch);
}

export default connect(mapStateToProps, mapDispatchToProps)(Players);<commit_msg>more test fixes<commit_after>import React, { PropTypes, Component } from 'react';
import { shell } from 'electron';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Link } from 'react-router';
import _ from 'lodash';
import classNames from 'classnames';
import ConnectedPlayerListItem from '../components/player/PlayerListItem';
import ConnectedHeader from '../components/Header';
import metrics from '../utils/MetricsUtil';
import * as PlayerActions from '../actions/player';
import * as BidActions from '../actions/bid';

export class Players extends Component {
  constructor(props) {
    super(props);
    this.state = {
      sidebarOffset: 0
    };
  }

  handleScroll(e) {
    if (e.target.scrollTop > 0 && !this.state.sidebarOffset) {
      this.setState({
        sidebarOffset: e.target.scrollTop
      });
    } else if (e.target.scrollTop === 0 && this.state.sidebarOffset) {
      this.setState({
        sidebarOffset: 0
      });
    }
  }

  handleClickClearList() {
    this.props.clear();
    this.context.router.push('/players');
  }

  handleClickReportIssue() {
    metrics.track('Opened Issue Reporter', {
      from: 'app'
    });
    shell.openExternal('https://github.com/hunterjm/fifa-autobuyer/issues');
  }

  handleToggleBidding() {
    if (this.props.bidding) {
      this.props.stop();
    } else {
      this.props.start();
      this.context.router.push('/players/overview');
    }
  }

  render() {
    let sidebarHeaderClass = 'sidebar-header';
    if (this.state.sidebarOffset) {
      sidebarHeaderClass += ' sep';
    }

    const players = _.map(
      _.get(this.props, 'player.list', {}),
      player => <ConnectedPlayerListItem key={player.id} player={player} />
    );

    const overviewClasses = classNames({
      state: true,
      'state-stopped': !this.props.bidding,
      'state-running': this.props.bidding,
    });

    return (
      <div className="containers">
        <ConnectedHeader hideLogin={false} />
        <div className="containers-body">
          <div className="sidebar">
            <section className={sidebarHeaderClass}>
              <h4>Player List</h4>
              <div className="create">
                {
                  this.props.location.pathname === '/players'
                  ?
                    <Link to="/settings">
                      <span className="btn btn-new btn-action has-icon btn-hollow">
                        <span className="icon icon-preferences" />Settings
                      </span>
                    </Link>
                  :
                    <Link to="/players">
                      <span className="btn btn-new btn-action has-icon btn-hollow">
                        <span className="icon icon-search" />Search
                      </span>
                    </Link>
                }
              </div>
            </section>
            <section className="sidebar-containers" onScroll={this.handleScroll.bind(this)}>
              <ul>
                <div ref={node => (this.node = node)}>
                  <Link to="/players/overview">
                    <li id="overview">
                      <div className={overviewClasses} />
                      <div className="info">
                        <div className="name">
                          Bidding Overview
                        </div>
                        <div className="image">
                          Review bidding status
                        </div>
                      </div>
                    </li>
                  </Link>
                </div>
                {players}
              </ul>
            </section>
            <section className="sidebar-buttons">
              <span className="btn-sidebar btn-database" onClick={this.handleClickClearList.bind(this)}>
                <span className="text">Clear List</span>
              </span>
              <span className="btn-sidebar btn-feedback" onClick={this.handleClickReportIssue}>
                <span className="icon icon-feedback" />
              </span>
              {
                this.props.bidding
                ?
                  (<span className="btn-sidebar btn-stop" onClick={() => this.handleToggleBidding()}>
                    <span className="icon icon-stop" />
                  </span>)
                :
                  (<span className="btn-sidebar btn-start" onClick={() => this.handleToggleBidding()}>
                    <span className="icon icon-start" />
                  </span>)
              }
            </section>
          </div>
          {this.props.children}
        </div>
      </div>
    );
  }
}

Players.propTypes = {
  children: PropTypes.element.isRequired,
  player: PropTypes.shape({}),
  location: PropTypes.shape({
    pathname: PropTypes.string
  }),
  bidding: PropTypes.bool,
  start: PropTypes.func,
  stop: PropTypes.func,
  clear: PropTypes.func,
};

Players.contextTypes = {
  router: PropTypes.object.isRequired
};

function mapStateToProps(state) {
  return {
    player: state.player,
    bidding: state.bid.bidding
  };
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators({ ...PlayerActions, ...BidActions }, dispatch);
}

export default connect(mapStateToProps, mapDispatchToProps)(Players);
{'fraction_non_alphanumeric': 0.13184546136534134, 'fraction_numerical': 0.0011252813203300824, 'mean_word_length': 1.740940632228219, 'pattern_counts': {'":': 0, '<': 115, '<?xml version=': 0, '>': 125, 'https://': 2, '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': '1519347', 'n_tokens_mistral': 2902, 'n_tokens_neox': 2780, 'n_words': 563}