<commit_before>import React, { PropTypes, Component } from 'react';
import { connect } from 'react-redux';
import { changeLanguage, changeLevel, leavePage } from '../actions/index';
import { bindActionCreators } from 'redux';


class LanguageSelect extends Component {
  constructor(props) {
    super(props);

    this.state = {
    }
  };

  componentWillUpdate() {

  }

  componentDidUpdate() {
    // if (this.levels) {
    //   for (let i = 0; i < this.levels.length ; i++) {
    //     $("#selectLevel" + i).unbind('click').click(function() {
    //       this.props.changeLevel({'currentLevel': this.levels[i]});
    //       this.props.leavePage();
    //     }.bind(this));
    //   }
    // } else { // Call set timeout to re-render component after 500ms if no data yet to fix bug
    //   setTimeout(function() {
    //     this.setState({loading: true});
    //   }.bind(this), 500);
    // }
  }

  componentDidMount() {
    console.log('ComponentDidMount : ', this.props.currentLanguage)

    $("#javascript").unbind('click').click(function() {
      this.props.changeLanguage({language: "javascript"});
      console.log('Current Language : ', this.props.currentLanguage)

    }.bind(this));
    $("#python").unbind('click').click(function() {
      // Action to change to python
      this.props.changeLanguage({language: "python"});

      console.log('Current Language : ', this.props.currentLanguage)

    }.bind(this));
  }


  render() {

    return (
        <div className="dropdown pull-right singleplayer-switch">
          <button className="btn btn-raised dropdown-toggle" type="button" id="menu1" data-toggle="dropdown">Language
          <span className="caret"></span></button>
          <ul className="dropdown-menu" role="menu" aria-labelledby="menu1">
            <li role="presentation"><a role="menuitem" tabIndex="-1" id="javascript" href="#/singleplayer/">Javascript</a></li>
            <li role="presentation"><a role="menuitem" tabIndex="-1" id="python" href="#/singleplayer/">Python</a></li>
          </ul>
        </div>
    );
  }
}

function mapStateToProps(state) {
  return {
    currentLevel: state.currentLevel,
    listOfPrompts: state.listOfPrompts,
    currentLanguage: state.currentLanguage
  }
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators({
    changeLevel: changeLevel,
    leavePage: leavePage,
    changeLanguage: changeLanguage
  }, dispatch);
}

export default connect(mapStateToProps, mapDispatchToProps)(LanguageSelect);

<commit_msg>[add] adds dropdown functionality for language select<commit_after>import React, { PropTypes, Component } from 'react';
import { connect } from 'react-redux';
import { changeLanguage, changeLevel, leavePage } from '../actions/index';
import { bindActionCreators } from 'redux';


class LanguageSelect extends Component {
  constructor(props) {
    super(props);

    this.state = {
      language: "Javascript"
    }
  };

  componentWillUpdate() {

  }

  componentDidUpdate() {
    // if (this.levels) {
    //   for (let i = 0; i < this.levels.length ; i++) {
    //     $("#selectLevel" + i).unbind('click').click(function() {
    //       this.props.changeLevel({'currentLevel': this.levels[i]});
    //       this.props.leavePage();
    //     }.bind(this));
    //   }
    // } else { // Call set timeout to re-render component after 500ms if no data yet to fix bug
    //   setTimeout(function() {
    //     this.setState({loading: true});
    //   }.bind(this), 500);
    // }
  }

  componentDidMount() {

    $("#javascript").unbind('click').click(function() {
      this.props.changeLanguage({language: "js"});
      this.props.changeLevel({'currentLevel': '00-forLoop'});
      this.props.leavePage();
      this.setState({language: 'Javascript'})

    }.bind(this));

    $("#python").unbind('click').click(function() {
      this.props.changeLanguage({language: "py"});
      this.props.changeLevel({'currentLevel': '00-helloWorld'});
      this.props.leavePage();
      this.setState({language: 'Python'})

    }.bind(this));
  }


  render() {

    return (
        <div className="dropdown pull-right singleplayer-switch">
          <button className="btn btn-raised dropdown-toggle" type="button" id="menu1" data-toggle="dropdown">{this.state.language}
          <span className="caret"></span></button>
          <ul className="dropdown-menu" role="menu" aria-labelledby="menu1">
            <li role="presentation"><a role="menuitem" tabIndex="-1" id="javascript" href="#/singleplayer/00-forLoop">Javascript</a></li>
            <li role="presentation"><a role="menuitem" tabIndex="-1" id="python" href="#/singleplayer/00-helloWorld">Python</a></li>
          </ul>
        </div>
    );
  }
}

function mapStateToProps(state) {
  return {
    currentLevel: state.currentLevel,
    listOfPrompts: state.listOfPrompts,
    currentLanguage: state.currentLanguage
  }
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators({
    changeLevel: changeLevel,
    leavePage: leavePage,
    changeLanguage: changeLanguage
  }, dispatch);
}

export default connect(mapStateToProps, mapDispatchToProps)(LanguageSelect);


{'fraction_non_alphanumeric': 0.16518375241779498, 'fraction_numerical': 0.005802707930367505, 'mean_word_length': 3.2177814029363785, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 35, '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': '6796755', 'n_tokens_mistral': 1580, 'n_tokens_neox': 1513, 'n_words': 293}