import React from 'react'; import PropTypes from 'prop-types'; import { Button, Modal, ModalBody, ModalFooter } from 'reactstrap'; import { gettext } from '../../utils/constants'; import FileChooser from '../file-chooser'; import SeahubModalHeader from '@/components/common/seahub-modal-header'; const propTypes = { repoID: PropTypes.string.isRequired, filePath: PropTypes.string.isRequired, toggleCancel: PropTypes.func.isRequired, getInsertLink: PropTypes.func.isRequired, }; class InsertFileDialog extends React.Component { constructor(props) { super(props); this.state = { repo: null, selectedPath: '', }; } handleInsert = () => { this.props.getInsertLink(this.state.repo.repo_id, this.state.selectedPath); this.props.toggleCancel(); }; onDirentItemClick = (repo, selectedPath, dirent) => { if (dirent.type === 'file') { this.setState({ repo: repo, selectedPath: selectedPath, }); } else { this.setState({ repo: null, selectedPath: '', }); } }; onRepoItemClick = () => { this.setState({ repo: null, selectedPath: '', }); }; render() { const toggle = this.props.toggleCancel; return ( {gettext('Select File')} {this.state.selectedPath ? : } ); } } InsertFileDialog.propTypes = propTypes; export default InsertFileDialog;