<commit_before>import React from 'react';
import {Link} from 'react-router';
import classNames from 'classnames';

import userStore  from '../../stores/users_store';
import tripsStore from '../../stores/trips_store';
import tripActions from '../../actions/trip_actions';
import apiClient from '../../libraries/api_client/api_client';

export default class Header extends React.Component {
  constructor(props) {
    super(props);
    this.state = {currentUser: null, saveSuccessfully: true};
    this.onUsersStoreChange = this.onUsersStoreChange.bind(this);
    this.onTripsStoreChange = this.onTripsStoreChange.bind(this);
    this.onSaveTrip = this.onSaveTrip.bind(this);
  }
  handleLogin() {
    // get Google Auth URL
    apiClient.getGoogleAuthUrl(result => {
      window.top.location.href = result;
    });
  }
  onSaveTrip() {
    tripActions.saveTrip(this.context.router);
  }
  onUsersStoreChange() {
    this.setState({currentUser: userStore.getCurrentUser()});
  }
  onTripsStoreChange() {
    this.setState({saveSuccessfully: tripsStore.saveSuccessfully});
  }
  componentDidMount() {
    userStore.addChangeListener(this.onUsersStoreChange);
    tripsStore.addChangeListener(this.onTripsStoreChange);
  }
  componentWillUnmount() {
    userStore.removeChangeListener(this.onUsersStoreChange);
    tripsStore.removeChangeListener(this.onTripsStoreChange);
  }
  render() {
    var userSection;
    const saveButtonClass = classNames({
      'btn': true,
      'navbar-btn': true,
      'btn-primary': this.state.saveSuccessfully,
      'btn-danger': !this.state.saveSuccessfully
    });

    if (this.state.currentUser) {
      userSection = <div className="navbar-text">
        <span>Welcome {this.state.currentUser.name}</span>
        &nbsp;
        (<Link to="logout">Logout</Link>)
      </div>;
    } else {
      userSection = <a className="btn" onClick={this.handleLogin}>
        <i className="fa fa-google"></i> Login using Google
      </a>;
    }
    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="#bs-example-navbar-collapse-1" 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="home">Plot My Trip</Link>
          </div>
          <div className="collapse navbar-collapse">
            <ul className="nav navbar-nav">
              <li className="active"><Link to="home">Home <span className="sr-only">(current)</span></Link></li>
            </ul>
            <ul className="nav navbar-nav navbar-right">
              <li>
                {userSection}
              </li>
              { this.state.currentUser &&
                <li><button type="button" onClick={this.onSaveTrip} className={saveButtonClass}>Save</button></li>
              }
            </ul>
          </div>
        </div>
      </nav>
    );
  }
}

Header.contextTypes = {
  router: React.PropTypes.func.isRequired
}
<commit_msg>fix save button?<commit_after>import React from 'react';
import {Link} from 'react-router';
import classNames from 'classnames';

import userStore  from '../../stores/users_store';
import tripsStore from '../../stores/trips_store';
import tripActions from '../../actions/trip_actions';
import apiClient from '../../libraries/api_client/api_client';

export default class Header extends React.Component {
  constructor(props) {
    super(props);
    this.state = {currentUser: null, saveSuccessfully: true};
    this.onUsersStoreChange = this.onUsersStoreChange.bind(this);
    this.onTripsStoreChange = this.onTripsStoreChange.bind(this);
    this.onSaveTrip = this.onSaveTrip.bind(this);
  }
  handleLogin() {
    // get Google Auth URL
    apiClient.getGoogleAuthUrl(result => {
      window.top.location.href = result;
    });
  }
  onSaveTrip(e) {
    e.preventDefault();
    tripActions.saveTrip(this.context.router);
  }
  onUsersStoreChange() {
    this.setState({currentUser: userStore.getCurrentUser()});
  }
  onTripsStoreChange() {
    this.setState({saveSuccessfully: tripsStore.saveSuccessfully});
  }
  componentDidMount() {
    userStore.addChangeListener(this.onUsersStoreChange);
    tripsStore.addChangeListener(this.onTripsStoreChange);
  }
  componentWillUnmount() {
    userStore.removeChangeListener(this.onUsersStoreChange);
    tripsStore.removeChangeListener(this.onTripsStoreChange);
  }
  render() {
    var userSection;
    const saveButtonClass = classNames({
      'btn': true,
      'navbar-btn': true,
      'btn-primary': this.state.saveSuccessfully,
      'btn-danger': !this.state.saveSuccessfully
    });

    if (this.state.currentUser) {
      userSection = <div className="navbar-text">
        <span>Welcome {this.state.currentUser.name}</span>
        &nbsp;
        (<Link to="logout">Logout</Link>)
      </div>;
    } else {
      userSection = <a className="btn" onClick={this.handleLogin}>
        <i className="fa fa-google"></i> Login using Google
      </a>;
    }
    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="#bs-example-navbar-collapse-1" 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="home">Plot My Trip</Link>
          </div>
          <div className="collapse navbar-collapse">
            <ul className="nav navbar-nav">
              <li className="active"><Link to="home">Home <span className="sr-only">(current)</span></Link></li>
            </ul>
            <ul className="nav navbar-nav navbar-right">
              <li>
                {userSection}
              </li>
              { this.state.currentUser &&
                <li><a onClick={this.onSaveTrip} className={saveButtonClass}>Save</a></li>
              }
            </ul>
          </div>
        </div>
      </nav>
    );
  }
}

Header.contextTypes = {
  router: React.PropTypes.func.isRequired
}

{'fraction_non_alphanumeric': 0.1460298144204442, 'fraction_numerical': 0.000304228780042592, 'mean_word_length': 2.778735632183908, 'pattern_counts': {'":': 0, '<': 95, '<?xml version=': 0, '>': 97, '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': '6869373', 'n_tokens_mistral': 1928, 'n_tokens_neox': 1912, 'n_words': 338}