import React from 'react'; import { Button, Modal, ModalHeader, Input, ModalBody, ModalFooter, Form, FormGroup, Label, Col, FormText } from 'reactstrap'; import { gettext } from '../../utils/constants'; class CreateForder extends React.Component { constructor(props) { super(props); this.state = { parentPath: '', childName: '' }; this.newInput = React.createRef() } handleChange = (e) => { this.setState({ childName: e.target.value, }) } handleSubmit = () => { let path = this.state.parentPath + this.state.childName this.props.onAddFolder(path); } handleKeyPress = (e) => { if (e.key === 'Enter') { this.handleSubmit(); } } toggle = () => { this.props.addFolderCancel(); } componentDidMount() { if (this.props.parentPath === "/") { this.setState({parentPath: this.props.parentPath}); } else { this.setState({parentPath: this.props.parentPath + "/"}); } this.newInput.focus(); this.newInput.setSelectionRange(0,0); } render() { return ( {gettext("New Folder")}
{this.state.parentPath} {this.newInput = input}} id="fileName" placeholder={gettext("newName")} value={this.state.childName} onChange={this.handleChange}/>
) } } export default CreateForder;