2016-07-13 20:13:28 +00:00
|
|
|
import React, { PropTypes } from 'react';
|
2016-11-16 18:12:36 +00:00
|
|
|
import { domOnlyProps } from '../../../utils/reduxFormUtils';
|
2016-07-13 20:13:28 +00:00
|
|
|
|
2016-08-30 03:23:10 +00:00
|
|
|
class NewFileForm extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.createFile = this.props.createFile.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { fields: { name }, handleSubmit } = this.props;
|
|
|
|
return (
|
2016-11-30 00:18:11 +00:00
|
|
|
<form
|
|
|
|
className="new-file-form"
|
|
|
|
onSubmit={(data) => {
|
|
|
|
this.props.focusOnModal();
|
|
|
|
handleSubmit(this.createFile)(data);
|
|
|
|
}}
|
|
|
|
>
|
2016-08-30 03:23:10 +00:00
|
|
|
<label className="new-file-form__name-label" htmlFor="name">Name:</label>
|
|
|
|
<input
|
|
|
|
className="new-file-form__name-input"
|
|
|
|
id="name"
|
|
|
|
type="text"
|
|
|
|
placeholder="Name"
|
2016-11-16 18:12:36 +00:00
|
|
|
{...domOnlyProps(name)}
|
2016-08-30 03:23:10 +00:00
|
|
|
/>
|
|
|
|
<input type="submit" value="Add File" aria-label="add file" />
|
2016-10-19 21:09:31 +00:00
|
|
|
{name.touched && name.error && <span className="form-error">{name.error}</span>}
|
2016-08-30 03:23:10 +00:00
|
|
|
</form>
|
|
|
|
);
|
|
|
|
}
|
2016-07-13 20:13:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NewFileForm.propTypes = {
|
|
|
|
fields: PropTypes.shape({
|
2016-08-30 03:26:45 +00:00
|
|
|
name: PropTypes.object.isRequired
|
2016-07-13 20:13:28 +00:00
|
|
|
}).isRequired,
|
|
|
|
handleSubmit: PropTypes.func.isRequired,
|
2016-11-30 00:18:11 +00:00
|
|
|
createFile: PropTypes.func.isRequired,
|
|
|
|
focusOnModal: PropTypes.func.isRequired
|
2016-07-13 20:13:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default NewFileForm;
|