<commit_before>/* jslint node: true, esnext: true */

var React = require('react'), {Input, Button, Panel, Row} = require('react-bootstrap');

module.exports = React.createClass({
  render: function() {
    let {caller, trsets} = this.props, seltr;

    if (trsets) {
      let tropts = trsets.map(t => <option key={t}>{t}</option>);
      seltr = (
        <Input onChange={this.changeDest} type="select" defaultValue={this.props.options.trset} ref="trset" label='TR Set' labelClassName='col-md-4' wrapperClassName='col-md-6' help="Use a predefined set of destinations">
          <option value="">Enter below</option>
          {tropts}
        </Input>
      );
    }

    return (
      <div>
        <h1>Destination</h1>
        <Panel disabled>
          {seltr}
          <div style={{'text-align': 'center', padding: '1em' }}><i>Or</i></div>
          <Input onChange={this.changeDest} ref='dest' type='text' label='Destination' defaultValue={this.props.options.dest} labelClassName='col-md-4' wrapperClassName='col-md-6' />
        </Panel>
        <Button disabled={!this.state.canTrace} className="pull-right" onClick={this.use.bind(this, 'Trace')}>Submit Trace</Button>
        <Button className="pull-right" onClick={this.use.bind(this, 'Options')}>Options</Button>
        <Button className="pull-right" onClick={this.cancel}>Go back</Button>
      </div>
    );
  },
  changeDest: function() {
    this.setState({
      canTrace : !!(this.refs.dest.getValue() || this.refs.trset.getValue())
    });
  },
  use: function(next) {
    let options = {};
    ['trset', 'dest'].forEach(i => {
      options[i] = this.refs[i].getValue();
    });

    this.props.caller.stepCall(next || 'Trace', options);
  },
  cancel: function() {
    this.props.caller.stepCall('Submitter');
  },
  getInitialState: function() {
    return {
      canTrace: !!(this.props.dest || this.props.trset)
    };
  }
});<commit_msg>determine canTrace based on props/state fixes #19<commit_after>/* jslint node: true, esnext: true */

var React = require('react'), {Input, Button, Panel, Row} = require('react-bootstrap');

module.exports = React.createClass({
  render: function() {
    let {caller, trsets} = this.props, seltr;
    var canTrace = !!(this.state.dest || this.state.trset);

    if (trsets) {
      let tropts = trsets.map(t => <option key={t}>{t}</option>);
      seltr = (
        <div>
          <p>Select a batch of hostnames to target from among those listed here:</p>

          <Input onChange={this.changeDest} type="select" defaultValue={this.props.options.trset} ref="trset" label='TR Set' labelClassName='col-md-4' wrapperClassName='col-md-6' help="Use a predefined set of destinations">
            <option value="">Enter below</option>
            {tropts}
          </Input>
          <div style={{'textAlign': 'center', padding: '1em' }}><i>Or</i></div>
        </div>
      );
    }

    return (
      <div>
        <h1>Destination</h1>
        <Panel disabled>
          {seltr}
          <p>Enter a hostname of your own to target</p>
          <Input onChange={this.changeDest} ref='dest' type='text' label='Destination' defaultValue={this.props.options.dest} labelClassName='col-md-4' wrapperClassName='col-md-6' />
        </Panel>
        <Button disabled={!canTrace} className="pull-right" onClick={this.use.bind(this, 'Trace')}>Submit Trace</Button>
        <Button className="pull-right" onClick={this.use.bind(this, 'Options')}>Options</Button>
        <Button className="pull-right" onClick={this.cancel}>Go back</Button>
      </div>
    );
  },
  changeDest: function() {
    this.setState({
      dest: this.refs.dest.getValue(),
      trset: this.refs.trset.getValue()
    });
  },
  use: function(next) {
    let options = {};
    ['trset', 'dest'].forEach(i => {
      options[i] = this.refs[i].getValue();
    });

    this.props.caller.stepCall(next || 'Trace', options);
  },
  cancel: function() {
    this.props.caller.stepCall('Submitter');
  },
  getInitialState: function() {
    return {
      trset: this.props.options.trset,
      dest: this.props.options.dest
    };
  }
});
{'fraction_non_alphanumeric': 0.18131067961165048, 'fraction_numerical': 0.003883495145631068, 'mean_word_length': 3.032289628180039, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 59, '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': '4083649', 'n_tokens_mistral': 1329, 'n_tokens_neox': 1321, 'n_words': 260}