<commit_before>import React, { Component } from 'react'
import { Input, Form } from 'antd'
import { ipcRenderer } from 'electron'
import PropTypes from 'prop-types'

import { validPort, validName } from '../validators'
import Modal from '../../Common/Modal'

function FormItem(props) {
  const formItemLayout = {
    labelCol: { span: 4 },
    wrapperCol: { span: 14 },
  }
  return <Form.Item {...formItemLayout} {...props} />
}

const validForm = (form, callback) => {
  form.validateFields((err, options) => {
    if (err) {
      callback(err)
      return
    }
    ipcRenderer.send('setup', options)
    callback()
  })
}

@Form.create()
export default class Login extends Component {
  static propTypes = {
    hide: PropTypes.func.isRequired,
    visible: PropTypes.bool.isRequired,
    form: PropTypes.object.isRequired,
  }

  handleCancel = () => {
    this.props.hide()
  }

  handleCreate = () => {
    const { form } = this.props
    validForm(form, (err) => {
      if (!err) {
        this.props.form.resetFields()
        this.props.hide()
      }
    })
  }

  render() {
    const { getFieldDecorator } = this.props.form
    const { visible } = this.props

    return (
      <Modal
        visible={visible}
        title="Settings/Login"
        okText="OK"
        cancelText="Cancel"
        onCancel={this.handleCancel}
        onOk={this.handleCreate}
      >
        <Form>
          <FormItem label="Username">
            {getFieldDecorator('username', {
              initialValue: this.props.username,
              rules: [
                {
                  required: true,
                  message: 'Please input your username!',
                },
                {
                  validator: validName,
                },
              ],
            })(<Input />)}
          </FormItem>
          <FormItem label="Port">
            {getFieldDecorator('port', {
              initialValue: this.props.port,
              rules: [
                {
                  required: true,
                },
                {
                  validator: validPort,
                },<commit_msg>login: rename title<commit_after>import React, { Component } from 'react'
import { Input, Form } from 'antd'
import { ipcRenderer } from 'electron'
import PropTypes from 'prop-types'

import { validPort, validName } from '../validators'
import Modal from '../../Common/Modal'

function FormItem(props) {
  const formItemLayout = {
    labelCol: { span: 4 },
    wrapperCol: { span: 14 },
  }
  return <Form.Item {...formItemLayout} {...props} />
}

const validForm = (form, callback) => {
  form.validateFields((err, options) => {
    if (err) {
      callback(err)
      return
    }
    ipcRenderer.send('setup', options)
    callback()
  })
}

@Form.create()
export default class Login extends Component {
  static propTypes = {
    hide: PropTypes.func.isRequired,
    visible: PropTypes.bool.isRequired,
    form: PropTypes.object.isRequired,
  }

  handleCancel = () => {
    this.props.hide()
  }

  handleCreate = () => {
    const { form } = this.props
    validForm(form, (err) => {
      if (!err) {
        this.props.form.resetFields()
        this.props.hide()
      }
    })
  }

  render() {
    const { getFieldDecorator } = this.props.form
    const { visible } = this.props

    return (
      <Modal
        visible={visible}
        title="Login"
        okText="Login"
        cancelText="Cancel"
        onCancel={this.handleCancel}
        onOk={this.handleCreate}
      >
        <Form>
          <FormItem label="Username">
            {getFieldDecorator('username', {
              initialValue: this.props.username,
              rules: [
                {
                  required: true,
                  message: 'Please input your username!',
                },
                {
                  validator: validName,
                },
              ],
            })(<Input />)}
          </FormItem>
          <FormItem label="Port">
            {getFieldDecorator('port', {
              initialValue: this.props.port,
              rules: [
                {
                  required: true,
                },
                {
                  validator: validPort,
                },
{'fraction_non_alphanumeric': 0.12916862376702679, 'fraction_numerical': 0.0014091122592766556, 'mean_word_length': 1.6552369077306732, 'pattern_counts': {'":': 0, '<': 17, '<?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': '1067891', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1193, 'n_words': 250}