<commit_before>import React from 'react';

import SearchControl from '../components/SearchControl.jsx';


var KeySearchControl = React.createClass({
  propTypes: {
    search: React.PropTypes.object.isRequired,
    updateState: React.PropTypes.func.isRequired,
  },

  getInitialState() {
    return {
      key: this.props.search.keySearchField || 'regi',
      text: this.props.search.keySearchText || '',
      params: this.props.search.keySearchParams || null,
    };
  },

  updated(state) {
    // update local state
    this.setState(state, () => {
      // then update parent state
      this.props.updateState({
        keySearchField: this.state.key,
        keySearchText: this.state.text,
        keySearchParams: this.state.params,
      });
    });
  },

  render() {
    return <SearchControl { ...this.props } search={ this.state } updateState={ this.updated }
      items={[
        { id: 'regi',  name: 'Registration' },
        { id: 'vin',   name: 'VIN' },
        { id: 'plate', name: 'Plate' },
      ]}
    />;
  },
});

export default KeySearchControl;<commit_msg>SB-223 HETS-136 Tweak to KeySearchControl.<commit_after>import React from 'react';

import _ from 'lodash';

import SearchControl from '../components/SearchControl.jsx';


const KEY_SEARCH_ITEMS = [
  { id: 'regi',  name: 'Registration' },
  { id: 'vin',   name: 'VIN' },
  { id: 'plate', name: 'Plate' },
];

var KeySearchControl = React.createClass({
  propTypes: {
    search: React.PropTypes.object.isRequired,
    updateState: React.PropTypes.func.isRequired,
  },

  getInitialState() {
    var item = _.find(KEY_SEARCH_ITEMS, { name: this.props.search.keySearchField });

    return {
      key: item ? item.id : KEY_SEARCH_ITEMS[0].id,
      text: this.props.search.keySearchText || '',
      params: this.props.search.keySearchParams || null,
    };
  },

  updated(state) {
    // update local state
    this.setState(state, () => {
      // then update parent state
      var item = _.find(KEY_SEARCH_ITEMS, { id: this.state.key });

      this.props.updateState({
        keySearchField: item ? item.name : '',
        keySearchText: this.state.text,
        keySearchParams: this.state.params,
      });
    });
  },

  render() {
    return <SearchControl { ...this.props } search={ this.state } updateState={ this.updated } items={ KEY_SEARCH_ITEMS }/>;
  },
});

export default KeySearchControl;
{'fraction_non_alphanumeric': 0.15214672780325136, 'fraction_numerical': 0.0029178824510212586, 'mean_word_length': 2.8585209003215435, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1450546', 'n_tokens_mistral': 778, 'n_tokens_neox': 759, 'n_words': 153}