<commit_before>define('setup_manage_taxonomies', ['reactaddons', 'lodash', 'jquery', 'utils'],
  function (React, _, $, Utils) {
  'use strict';

  var TermComponent = React.createClass({
    render: function () {
      return <li><label
        htmlFor="minimal-checkbox-1-11">{this.props.term.label}</label></li>;
    }
  });

  var VocabularyComponent = React.createClass({
    mixins: [React.addons.LinkedStateMixin],
    render: function () {
      var items = _.map(this.props.terms, function (term) {
        return <TermComponent term={term} key={term.slug} />;
      });

      return <ul className="icheck-list">
          <div className="panel-heading">
            <h4 className="panel-title">
              <a className="accordion-toggle" data-toggle="collapse"
                 data-parent="#accordion"
                 href={'#collapse-' + this.props.vocabulary.slug}>
                {this.props.vocabulary.name}
              </a>
            </h4>
          </div>
          <div id={'collapse-' + this.props.vocabulary.slug}
               className="panel-collapse collapse in">
            <div className="panel-body">
              <ul>
                {items}
              </ul>
            </div>
          </div>
        <li>
          <div className="input-group">
            <input type="text" valueLink={this.linkState('newTermLabel')}
              className="form-control" onKeyUp={this.onKeyUp}
              placeholder="Add new term..."
              />
              <span className="input-group-btn">
                <a className="btn btn-white"
                  type="button" onClick={this.handleAddTermClick}><i
                  className="fa fa-plus-circle"
                ></i></a>
              </span>
          </div>
        </li>
      </ul>;
    },
    onKeyUp: function(e) {
      if (e.key === "Enter") {
        this.handleAddTermClick();
      }
    },
    handleAddTermClick: function() {
      var thiz = this;
      var API_ROOT_VOCAB_URL = '/api/v1/repositories/' + this.props.repoSlug +
        '/vocabularies/';
      $.ajax({
          type: "POST",
          url: API_ROOT_VOCAB_URL + this.props.vocabulary.slug + "/terms/",
          data: JSON.stringify({
            label: this.state.newTermLabel,
            weight: 1
          }),
          contentType: "application/json; charset=utf-8"
        }
      ).fail(function() {
          thiz.props.reportError("Error occurred while adding new term.");
        })
      .done(function(newTerm) {
          thiz.props.addTerm(thiz.props.vocabulary.slug, newTerm);
          thiz.setState({
            newTermLabel: null
          });

          // clear errors
          thiz.props.reportError(null);
        });
    },
    getInitialState: function() {
      return {
        newTermLabel: "",
        terms: this.props.terms
      };
    },
  });

  var AddTermsComponent = React.createClass({
    render: function () {
      var repoSlug = this.props.repoSlug;
      var thiz = this;
      var items = _.map(this.props.vocabularies, function (obj) {
        return <VocabularyComponent
          vocabulary={obj.vocabulary}
          terms={obj.terms}<commit_msg>Removed unused piece of state<commit_after>define('setup_manage_taxonomies', ['reactaddons', 'lodash', 'jquery', 'utils'],
  function (React, _, $, Utils) {
  'use strict';

  var TermComponent = React.createClass({
    render: function () {
      return <li><label
        htmlFor="minimal-checkbox-1-11">{this.props.term.label}</label></li>;
    }
  });

  var VocabularyComponent = React.createClass({
    mixins: [React.addons.LinkedStateMixin],
    render: function () {
      var items = _.map(this.props.terms, function (term) {
        return <TermComponent term={term} key={term.slug} />;
      });

      return <ul className="icheck-list">
          <div className="panel-heading">
            <h4 className="panel-title">
              <a className="accordion-toggle" data-toggle="collapse"
                 data-parent="#accordion"
                 href={'#collapse-' + this.props.vocabulary.slug}>
                {this.props.vocabulary.name}
              </a>
            </h4>
          </div>
          <div id={'collapse-' + this.props.vocabulary.slug}
               className="panel-collapse collapse in">
            <div className="panel-body">
              <ul>
                {items}
              </ul>
            </div>
          </div>
        <li>
          <div className="input-group">
            <input type="text" valueLink={this.linkState('newTermLabel')}
              className="form-control" onKeyUp={this.onKeyUp}
              placeholder="Add new term..."
              />
              <span className="input-group-btn">
                <a className="btn btn-white"
                  type="button" onClick={this.handleAddTermClick}><i
                  className="fa fa-plus-circle"
                ></i></a>
              </span>
          </div>
        </li>
      </ul>;
    },
    onKeyUp: function(e) {
      if (e.key === "Enter") {
        this.handleAddTermClick();
      }
    },
    handleAddTermClick: function() {
      var thiz = this;
      var API_ROOT_VOCAB_URL = '/api/v1/repositories/' + this.props.repoSlug +
        '/vocabularies/';
      $.ajax({
          type: "POST",
          url: API_ROOT_VOCAB_URL + this.props.vocabulary.slug + "/terms/",
          data: JSON.stringify({
            label: this.state.newTermLabel,
            weight: 1
          }),
          contentType: "application/json; charset=utf-8"
        }
      ).fail(function() {
          thiz.props.reportError("Error occurred while adding new term.");
        })
      .done(function(newTerm) {
          thiz.props.addTerm(thiz.props.vocabulary.slug, newTerm);
          thiz.setState({
            newTermLabel: null
          });

          // clear errors
          thiz.props.reportError(null);
        });
    },
    getInitialState: function() {
      return {
        newTermLabel: ""
      };
    },
  });

  var AddTermsComponent = React.createClass({
    render: function () {
      var repoSlug = this.props.repoSlug;
      var thiz = this;
      var items = _.map(this.props.vocabularies, function (obj) {
        return <VocabularyComponent
          vocabulary={obj.vocabulary}
          terms={obj.terms}
{'fraction_non_alphanumeric': 0.14436564223798265, 'fraction_numerical': 0.00252167060677699, 'mean_word_length': 1.7699694456569184, 'pattern_counts': {'":': 0, '<': 65, '<?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': '4317026', 'n_tokens_mistral': 1886, 'n_tokens_neox': 1853, 'n_words': 327}