<commit_before>import * as _ from 'lodash';
import * as React from 'react';
import * as Reflux from 'reflux';
import { DriverActions } from '../actions/driver-action'
import { MachineActions } from '../actions/machine-action'
import { MachineNameOperatingStore } from '../stores/machine-store';
import { DriversStore, SelectedDriverStore } from '../stores/driver-store'
import {
  Form,
  Field,
  InputField,
  HiddenField,
  SubmitButton,
  SubmitButtonControlMixin
} from './form';
import {
  MachineActionLoadingMixin,
  MachineOperationMixin
} from './mixin/machine-mixin';

const History = require('react-router').History;
const reactSemantify = require('react-semantify');
const Dropdown = reactSemantify.Dropdown;
const Divider = reactSemantify.Divider;

const MachineFormMixin = {
  getInitialState: function() {
    return {
      submitLoading: false
    };
  },
  create: function(data) {
    this.setState({
      machineName: data.name
    });
    MachineActions.create(data.name, data.driver, data.swarm);
  },
  componentWillUpdate: function(nextProps, nextState) {
    if (this.state.operating === true && nextState.operating === false) {
      this.history.pushState(null, '/');
    }
  }
}

export const VirtualBoxForm = React.createClass<any, any>({
  mixins: [
    History,
    SubmitButtonControlMixin,
    MachineFormMixin,
    MachineActionLoadingMixin('create'),
    MachineOperationMixin
  ],
  render: function() {
    return (
      <Form className={this.state.loading ? 'loading' : ''} onValidSubmit={this.create} onValid={this.enableButton} onInvalid={this.disableButton}>
        <HiddenField name="driver.name" value="virtualbox" />
        <InputField
          name="name"
          label="Machine Name"
          required />
        <InputField
          type="number"
          name="driver.options.virtualbox-memory"
          label="Memory"
          value="512" />
        <SubmitButton className="green" disabled={this.state.disableSubmit || this.state.operating} loading={this.state.loading} text="Create" />
      </Form>
    );
  }
});

const DriverFormMap = {
  'virtualbox': VirtualBoxForm
}

export const DriverSelection = React.createClass<any, any>({
  mixins: [Reflux.connect(DriversStore, 'drivers')],
  componentDidMount: function () {
    DriverActions.load();
  },
  select: function(driver) {
    DriverActions.select(driver);
  },
  render: function() {
    var options = [];<commit_msg>Add more field for virtualbox driver<commit_after>import * as _ from 'lodash';
import * as React from 'react';
import * as Reflux from 'reflux';
import { DriverActions } from '../actions/driver-action'
import { MachineActions } from '../actions/machine-action'
import { MachineNameOperatingStore } from '../stores/machine-store';
import { DriversStore, SelectedDriverStore } from '../stores/driver-store'
import {
  Form,
  Field,
  InputField,
  HiddenField,
  CheckboxField,
  SubmitButton,
  SubmitButtonControlMixin
} from './form';
import {
  MachineActionLoadingMixin,
  MachineOperationMixin
} from './mixin/machine-mixin';

const History = require('react-router').History;
const reactSemantify = require('react-semantify');
const Dropdown = reactSemantify.Dropdown;
const Divider = reactSemantify.Divider;

const MachineFormMixin = {
  getInitialState: function() {
    return {
      submitLoading: false
    };
  },
  create: function(data) {
    this.setState({
      machineName: data.name
    });
    MachineActions.create(data.name, data.driver, data.swarm);
  },
  componentWillUpdate: function(nextProps, nextState) {
    if (this.state.operating === true && nextState.operating === false) {
      this.history.pushState(null, '/');
    }
  }
}

export const VirtualBoxForm = React.createClass<any, any>({
  mixins: [
    History,
    SubmitButtonControlMixin,
    MachineFormMixin,
    MachineActionLoadingMixin('create'),
    MachineOperationMixin
  ],
  render: function() {
    return (
      <Form className={this.state.loading ? 'loading' : ''} onValidSubmit={this.create} onValid={this.enableButton} onInvalid={this.disableButton}>
        <HiddenField name="driver.name" value="virtualbox" />
        <InputField
          name="name"
          label="Machine Name"
          required />
        <InputField
          type="number"
          name="driver.options.virtualbox-memory"
          label="Memory" />
        <InputField
          type="number"
          name="driver.options.virtualbox-cpu-count"
          label="CPU Count" />
        <InputField
          type="number"
          name="driver.options.virtualbox-disk-size"
          label="Disk Size (MB)" />
        <InputField
          type="text"
          name="driver.options.virtualbox-boot2docker-url"
          label="Boot2Docker Image URL" />
        <InputField
          type="text"
          name="driver.options.virtualbox-import-boot2docker-vm"
          label="Boot2Docker VM to import" />
        <InputField
          type="text"
          name="driver.options.virtualbox-hostonly-cidr"
          label="CIDR of the host only adapter" />
        <InputField
          type="text"
          name="driver.options.virtualbox-hostonly-nictype"
          label="Host Only Network Adapter Type" />
        <InputField
          type="text"
          name="driver.options.virtualbox-hostonly-nicpromisc"
          label="Host Only Network Adapter Promiscuous Mode" />
        <CheckboxField
          name="driver.options.virtualbox-no-share"
          label="Disable the mount of your home directory" />
        <SubmitButton className="green" disabled={this.state.disableSubmit || this.state.operating} loading={this.state.loading} text="Create" />
      </Form>
    );
  }
});

const DriverFormMap = {
  'virtualbox': VirtualBoxForm
}

export const DriverSelection = React.createClass<any, any>({
  mixins: [Reflux.connect(DriversStore, 'drivers')],
  componentDidMount: function () {
    DriverActions.load();
  },
  select: function(driver) {
    DriverActions.select(driver);
  },
  render: function() {
    var options = [];
{'fraction_non_alphanumeric': 0.1298187808896211, 'fraction_numerical': 0.0011532125205930808, 'mean_word_length': 3.152530779753762, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '3090752', 'n_tokens_mistral': 1784, 'n_tokens_neox': 1756, 'n_words': 350}