<commit_before>import React from 'react';
import { compose } from 'recompose';
import { connect } from 'react-redux';
import { reduxForm, Field } from 'redux-form';

import { Modal, Header, Button, Icon, Form } from 'semantic-ui-react';
import { InputField } from 'react-semantic-redux-form';

import { required, minLength2 } from 'lib/reduxFormUtils';
import { actionCreators } from './redux';
import DocPickerModal from './DocPickerModal';
import DocRefTypePicker from './DocRefTypePicker';
import explorerClient from './explorerClient';

import PermissionInheritancePicker from 'components/PermissionInheritancePicker';

const { createDocument } = explorerClient;

const { completeDocRefCreation } = actionCreators;

const enhance = compose(
  connect(
    ({
      docExplorer: {
        newDoc: { isOpen, destination },
      },
      form,
    }) => ({
      isOpen,
      newDocRefForm: form.newDocRef,
      initialValues: {
        destination,
      },
    }),
    { completeDocRefCreation, createDocument },
  ),
  reduxForm({
    form: 'newDocRef',
  }),
);

const NewDocDialog = ({
  isOpen, stage, completeDocRefCreation, createDocument, newDocRefForm,
}) => (
  <Modal
    open={isOpen}
    onClose={completeDocRefCreation}
    size="small"
    dimmer="inverted"
    closeOnDimmerClick={false}
  >
    <Header icon="plus" content="Create a New Doc Ref" />
    <Modal.Content>
      <Form>
        <Form.Field>
          <label>Doc Ref Type</label>
          <Field
            name="docRefType"
            component={({ input: { onChange, value } }) => (
              <DocRefTypePicker pickerId="new-doc-ref-type" onChange={onChange} value={value} />
            )}
          />
        </Form.Field>
        <Form.Field>
          <label>Name</label>
          <Field
            name="docRefName"
            component={InputField}
            type="text"
            placeholder="Name"
            validate={[required, minLength2]}
          />
        </Form.Field>
        <Form.Field>
          <label>Destination</label>
          <Field
            name="destination"
            component={({ input: { onChange, value } }) => (
              <DocPickerModal
                explorerId="new-doc-ref-destination"
                typeFilters={['Folder']}
                onChange={onChange}
                value={value}
              />
            )}
          />
        </Form.Field>
        <Form.Field>
          <label>Permission Inheritance</label>
          <Field
            name="permissionInheritance"
            component={({ input: { onChange, value } }) => (
              <PermissionInheritancePicker onChange={onChange} value={value} />
            )}
          />
        </Form.Field>
      </Form>
    </Modal.Content>
    <Modal.Actions>
      <Button negative onClick={completeDocRefCreation} inverted>
        <Icon name="checkmark" /> Cancel
      </Button>
      <Button
        positive
        onClick={() =>
          createDocument(
            newDocRefForm.values.docRefType,
            newDocRefForm.values.docRefName,
            newDocRefForm.values.destination,
            newDocRefForm.values.permissionInheritance,
          )
        }
        labelPosition="right"
        icon="checkmark"
        content="Choose"
      />
    </Modal.Actions>
  </Modal>
);

export default enhance(NewDocDialog);
<commit_msg>fixed creating a new doc ref in place<commit_after>import React from 'react';
import { compose } from 'recompose';
import { connect } from 'react-redux';
import { reduxForm, Field } from 'redux-form';

import { Modal, Header, Button, Icon, Form } from 'semantic-ui-react';
import { InputField } from 'react-semantic-redux-form';

import { required, minLength2 } from 'lib/reduxFormUtils';
import { actionCreators } from './redux';
import DocPickerModal from './DocPickerModal';
import DocRefTypePicker from './DocRefTypePicker';
import explorerClient from './explorerClient';

import PermissionInheritancePicker from 'components/PermissionInheritancePicker';

const { createDocument } = explorerClient;

const { completeDocRefCreation } = actionCreators;

const enhance = compose(
  connect(
    ({
      docExplorer: {
        newDoc: { isOpen, destination },
      },
      form,
    }) => ({
      isOpen,
      newDocRefForm: form.newDocRef,
      initialValues: {
        destination,
      },
    }),
    { completeDocRefCreation, createDocument },
  ),
  reduxForm({
    form: 'newDocRef',
    enableReinitialize: true,
    touchOnChange: true,
  }),
);

const NewDocDialog = ({
  isOpen, stage, completeDocRefCreation, createDocument, newDocRefForm,
}) => (
  <Modal
    open={isOpen}
    onClose={completeDocRefCreation}
    size="small"
    dimmer="inverted"
    closeOnDimmerClick={false}
  >
    <Header icon="plus" content="Create a New Doc Ref" />
    <Modal.Content>
      <Form>
        <Form.Field>
          <label>Doc Ref Type</label>
          <Field
            name="docRefType"
            component={({ input: { onChange, value } }) => (
              <DocRefTypePicker pickerId="new-doc-ref-type" onChange={onChange} value={value} />
            )}
          />
        </Form.Field>
        <Form.Field>
          <label>Name</label>
          <Field
            name="docRefName"
            component={InputField}
            type="text"
            placeholder="Name"
            validate={[required, minLength2]}
          />
        </Form.Field>
        <Form.Field>
          <label>Destination</label>
          <Field
            name="destination"
            component={({ input: { onChange, value } }) => (
              <DocPickerModal
                explorerId="new-doc-ref-destination"
                typeFilters={['Folder']}
                onChange={onChange}
                value={value}
              />
            )}
          />
        </Form.Field>
        <Form.Field>
          <label>Permission Inheritance</label>
          <Field
            name="permissionInheritance"
            component={({ input: { onChange, value } }) => (
              <PermissionInheritancePicker onChange={onChange} value={value} />
            )}
          />
        </Form.Field>
      </Form>
    </Modal.Content>
    <Modal.Actions>
      <Button negative onClick={completeDocRefCreation} inverted>
        <Icon name="checkmark" /> Cancel
      </Button>
      <Button
        positive
        onClick={() =>
          createDocument(
            newDocRefForm.values.docRefType,
            newDocRefForm.values.docRefName,
            newDocRefForm.values.destination,
            newDocRefForm.values.permissionInheritance,
          )
        }
        labelPosition="right"
        icon="checkmark"
        content="Choose"
      />
    </Modal.Actions>
  </Modal>
);

export default enhance(NewDocDialog);

{'fraction_non_alphanumeric': 0.12501829893134242, 'fraction_numerical': 0.0005855658029571073, 'mean_word_length': 2.088607594936709, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 87, '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': '4664946', 'n_tokens_mistral': 1922, 'n_tokens_neox': 1899, 'n_words': 371}