2016-08-30 05:23:10 +02:00
|
|
|
import React, { PropTypes } from 'react';
|
2016-11-16 19:12:36 +01:00
|
|
|
import { domOnlyProps } from '../../../utils/reduxFormUtils';
|
2016-08-30 05:23:10 +02:00
|
|
|
|
|
|
|
class NewFolderForm extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.createFolder = this.props.createFolder.bind(this);
|
|
|
|
}
|
|
|
|
|
2016-09-04 01:42:23 +02:00
|
|
|
componentDidMount() {
|
2017-02-22 20:29:35 +01:00
|
|
|
this.fileName.focus();
|
2016-09-04 01:42:23 +02:00
|
|
|
}
|
|
|
|
|
2016-08-30 05:23:10 +02:00
|
|
|
render() {
|
|
|
|
const { fields: { name }, handleSubmit } = this.props;
|
|
|
|
return (
|
2016-11-30 01:18:11 +01:00
|
|
|
<form
|
|
|
|
className="new-folder-form"
|
|
|
|
onSubmit={(data) => {
|
|
|
|
handleSubmit(this.createFolder)(data);
|
|
|
|
this.props.closeModal();
|
|
|
|
}}
|
|
|
|
>
|
2016-08-30 05:23:10 +02:00
|
|
|
<label className="new-folder-form__name-label" htmlFor="name">Name:</label>
|
|
|
|
<input
|
|
|
|
className="new-folder-form__name-input"
|
|
|
|
id="name"
|
|
|
|
type="text"
|
|
|
|
placeholder="Name"
|
2017-02-22 20:29:35 +01:00
|
|
|
ref={(element) => { this.fileName = element; }}
|
2016-11-16 19:12:36 +01:00
|
|
|
{...domOnlyProps(name)}
|
2016-08-30 05:23:10 +02:00
|
|
|
/>
|
|
|
|
<input type="submit" value="Add Folder" aria-label="add folder" />
|
|
|
|
</form>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NewFolderForm.propTypes = {
|
|
|
|
fields: PropTypes.shape({
|
2016-08-30 05:26:45 +02:00
|
|
|
name: PropTypes.object.isRequired
|
2016-08-30 05:23:10 +02:00
|
|
|
}).isRequired,
|
|
|
|
handleSubmit: PropTypes.func.isRequired,
|
2016-11-30 01:18:11 +01:00
|
|
|
createFolder: PropTypes.func.isRequired,
|
|
|
|
closeModal: PropTypes.func.isRequired
|
2016-08-30 05:23:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default NewFolderForm;
|