import React from 'react'; import PropTypes from 'prop-types'; import { gettext } from '../../utils/constants'; import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input, Label } from 'reactstrap'; const propTypes = { toggleCancel: PropTypes.func.isRequired, addWiki: PropTypes.func.isRequired, }; class AddWikiDialog extends React.Component { constructor(props) { super(props); this.state = { name: '', isSubmitBtnActive: false, }; } inputNewName = (e) => { this.setState({ name: e.target.value, isSubmitBtnActive: !!e.target.value.trim(), }); }; handleKeyDown = (e) => { if (e.key === 'Enter') { this.handleSubmit(); } }; handleSubmit = () => { const wikiName = this.state.name.trim(); if (!wikiName) return; this.props.addWiki(wikiName); this.props.toggleCancel(); }; toggle = () => { this.props.toggleCancel(); }; render() { return ( {gettext('Add Wiki')} ); } } AddWikiDialog.propTypes = propTypes; export default AddWikiDialog;