2016-07-13 22:13:28 +02:00
|
|
|
import React, { PropTypes } from 'react';
|
|
|
|
|
2016-08-30 05:23:10 +02:00
|
|
|
class NewFileForm extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.createFile = this.props.createFile.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
this.refs.fileName.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { fields: { name }, handleSubmit } = this.props;
|
|
|
|
return (
|
|
|
|
<form className="new-file-form" onSubmit={handleSubmit(this.createFile)}>
|
|
|
|
<label className="new-file-form__name-label" htmlFor="name">Name:</label>
|
|
|
|
<input
|
|
|
|
className="new-file-form__name-input"
|
|
|
|
id="name"
|
|
|
|
type="text"
|
|
|
|
placeholder="Name"
|
|
|
|
ref="fileName"
|
|
|
|
{...name}
|
|
|
|
/>
|
|
|
|
<input type="submit" value="Add File" aria-label="add file" />
|
|
|
|
</form>
|
|
|
|
);
|
|
|
|
}
|
2016-07-13 22:13:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
NewFileForm.propTypes = {
|
|
|
|
fields: PropTypes.shape({
|
2016-08-30 05:26:45 +02:00
|
|
|
name: PropTypes.object.isRequired
|
2016-07-13 22:13:28 +02:00
|
|
|
}).isRequired,
|
|
|
|
handleSubmit: PropTypes.func.isRequired,
|
|
|
|
createFile: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
export default NewFileForm;
|