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