<commit_before>import deepAssign from 'deep-assign'
import React, { PropTypes } from 'react'
import SimpleFormMixin from 'mixins/SimpleFormMixin'
import { connect } from 'react-redux'
import { createConnection } from 'actions/ConnectionActions'

require('./styles/Credentials')

const CredentialsModal = React.createClass({
  propTypes: {
    dispatch: PropTypes.func.isRequired,
    unsetModal: PropTypes.func.isRequired,
    providers: PropTypes.object.isRequired
  },

  mixins: [SimpleFormMixin],

  /**
   * Initialize SimpleFormMixin with the first provider.
   * @todo Stop defaulting to rTorrent! :)
   */
  componentDidMount () {
    this.setState(deepAssign({}, this.state, {
      form: {
        provider: Object.keys(this.props.providers)[0]
      }
    }))
  },

  /**
   * Unsets Modal, and dispatches `setCredentials()` with form data.
   * @param  {[type]} ev [description]
   * @return {[type]}    [description]
   */
  handleSubmit (ev) {
    ev.preventDefault()
    this.props.unsetModal(true)
    this.simpleFormMixinHandleSubmit(createConnection)
  },

  render () {
    const { providers } = this.props
    return (
      <div className='credentials__container'>
        <form className='credentials' onSubmit={this.handleSubmit}>
          <div className='input__row'>
            <div className='input__group input__group--full'>
              <label className='input__label'>Provider</label>
              <select className='input input--select' name='provider' onChange={this.simpleFormMixinHandleChange} value='rtorrent'>
                {Object.keys(providers).map(provider =>
                  <option key={provider} value={provider}>{providers[provider].prettyName}</option>
                )}
              </select>
            </div>
          </div>
          <div className='input__row'>
            <div className='input__group input__group--full'>
              <label className='input__label'>Host</label>
              <input className='input input--text' type='text' name='host' placeholder='ex. http://127.0.0.1/RPC2' onChange={this.simpleFormMixinHandleChange} />
            </div>
          </div>
          <div className='input__row'>
            <div className='input__group'>
              <label className='input__label'>Username</label><commit_msg>fixes provider chooser in auth modal<commit_after>import deepAssign from 'deep-assign'
import React, { PropTypes } from 'react'
import SimpleFormMixin from 'mixins/SimpleFormMixin'
import { connect } from 'react-redux'
import { createConnection } from 'actions/ConnectionActions'

require('./styles/Credentials')

const CredentialsModal = React.createClass({
  propTypes: {
    dispatch: PropTypes.func.isRequired,
    unsetModal: PropTypes.func.isRequired,
    providers: PropTypes.object.isRequired
  },

  mixins: [SimpleFormMixin],

  /**
   * Initialize SimpleFormMixin with the first provider.
   * @todo Stop defaulting to rTorrent! :)
   */
  componentDidMount () {
    this.setState(deepAssign({}, this.state, {
      form: {
        provider: Object.keys(this.props.providers)[0]
      }
    }))
  },

  /**
   * Unsets Modal, and dispatches `setCredentials()` with form data.
   * @param  {[type]} ev [description]
   * @return {[type]}    [description]
   */
  handleSubmit (ev) {
    ev.preventDefault()
    this.props.unsetModal(true)
    this.simpleFormMixinHandleSubmit(createConnection)
  },

  render () {
    const { providers } = this.props
    return (
      <div className='credentials__container'>
        <form className='credentials' onSubmit={this.handleSubmit}>
          <div className='input__row'>
            <div className='input__group input__group--full'>
              <label className='input__label'>Provider</label>
              <select className='input input--select' name='provider' onChange={this.simpleFormMixinHandleChange}>
                {Object.keys(providers).map(provider =>
                  <option key={provider} value={provider}>{providers[provider].prettyName}</option>
                )}
              </select>
            </div>
          </div>
          <div className='input__row'>
            <div className='input__group input__group--full'>
              <label className='input__label'>Host</label>
              <input className='input input--text' type='text' name='host' placeholder='ex. http://127.0.0.1/RPC2' onChange={this.simpleFormMixinHandleChange} />
            </div>
          </div>
          <div className='input__row'>
            <div className='input__group'>
              <label className='input__label'>Username</label>
{'fraction_non_alphanumeric': 0.13140747176368375, 'fraction_numerical': 0.0034752389226759338, 'mean_word_length': 2.8860759493670884, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '6536233', 'n_tokens_mistral': 1287, 'n_tokens_neox': 1278, 'n_words': 251}