<commit_before>import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';

import {
  ScaleRequest,
  BounceRequest
} from '../../actions/api/requests';

import FormModal from '../common/modal/FormModal';

class ScaleModal extends Component {
  static propTypes = {
    requestId: PropTypes.string.isRequired,
    scaleRequest: PropTypes.func.isRequired,
    bounceRequest: PropTypes.func.isRequired,
    currentInstances: PropTypes.number
  };

  // NOTE: currentInstances
  // because there are many different places where the request object could be
  // in the store, we don't try to mapStateToProps this

  static INCREMENTAL_BOUNCE_VALUE = {
    INCREMENTAL: {
      label: 'Kill old tasks as new tasks become healthy',
      value: true
    },
    ALL: {
      label: 'Kill old tasks once ALL new tasks are healthy',
      value: false
    }
  };

  handleScale(data) {
    const { instances, durationMillis, message } = data;
    this.props.scaleRequest(
      {
        instances,
        durationMillis,
        message
      }
    );
    if (data.bounce) {
      this.props.bounceRequest(
        {
          incremental: !!data.incremental
        }
      );
    }
  }

  show() {
    this.refs.scaleModal.show();
  }

  render() {
    return (
      <FormModal
        ref="scaleModal"
        action="Scale Request"
        onConfirm={(data) => this.handleScale(data)}
        buttonStyle="primary"
        formElements={[
          {
            name: 'instances',
            min: 1,
            type: FormModal.INPUT_TYPES.NUMBER,
            label: 'Number of instances:',
            defaultValue: this.props.currentInstances,
            isRequired: true
          },
          {
            name: 'bounce',
            type: FormModal.INPUT_TYPES.BOOLEAN,
            label: 'Bounce after scaling',
            defaultValue: false
          },
          {
            name: 'incremental',
            type: FormModal.INPUT_TYPES.RADIO,<commit_msg>Fix bug in scale modal<commit_after>import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';

import {
  ScaleRequest,
  BounceRequest
} from '../../actions/api/requests';

import FormModal from '../common/modal/FormModal';

class ScaleModal extends Component {
  static propTypes = {
    requestId: PropTypes.string.isRequired,
    scaleRequest: PropTypes.func.isRequired,
    bounceRequest: PropTypes.func.isRequired,
    currentInstances: PropTypes.number
  };

  // NOTE: currentInstances
  // because there are many different places where the request object could be
  // in the store, we don't try to mapStateToProps this

  static INCREMENTAL_BOUNCE_VALUE = {
    INCREMENTAL: {
      label: 'Kill old tasks as new tasks become healthy',
      value: true
    },
    ALL: {
      label: 'Kill old tasks once ALL new tasks are healthy',
      value: false
    }
  };

  handleScale(data) {
    const { instances, durationMillis, message } = data;
    this.props.scaleRequest(
      {
        instances,
        durationMillis,
        message
      }
    ).then(() => {
      if (data.bounce) {
        this.props.bounceRequest(
          {
            incremental: !!data.incremental
          }
        );
      }
    });
  }

  show() {
    this.refs.scaleModal.show();
  }

  render() {
    return (
      <FormModal
        ref="scaleModal"
        action="Scale Request"
        onConfirm={(data) => this.handleScale(data)}
        buttonStyle="primary"
        formElements={[
          {
            name: 'instances',
            min: 1,
            type: FormModal.INPUT_TYPES.NUMBER,
            label: 'Number of instances:',
            defaultValue: this.props.currentInstances,
            isRequired: true
          },
          {
            name: 'bounce',
            type: FormModal.INPUT_TYPES.BOOLEAN,
            label: 'Bounce after scaling',
            defaultValue: false
          },
          {
            name: 'incremental',
            type: FormModal.INPUT_TYPES.RADIO,
{'fraction_non_alphanumeric': 0.10457354758961682, 'fraction_numerical': 0.0004944375772558715, 'mean_word_length': 2.00817843866171, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '4224621', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1153, 'n_words': 280}