import React from 'react'; import PropTypes from 'prop-types'; import { Button, Modal, ModalBody, ModalFooter, Alert } from 'reactstrap'; import { gettext } from '../../utils/constants'; import FileChooser from '../file-chooser'; import SeahubModalHeader from '@/components/common/seahub-modal-header'; const propTypes = { sharedToken: PropTypes.string.isRequired, parentDir: PropTypes.string.isRequired, items: PropTypes.array.isRequired, toggleCancel: PropTypes.func.isRequired, handleSaveSharedDir: PropTypes.func.isRequired, }; class SaveSharedDirDialog extends React.Component { constructor(props) { super(props); this.state = { repo: null, selectedPath: '', errMessage: '', }; } onSaveSharedFile = () => { this.props.handleSaveSharedDir(this.state.repo.repo_id, this.state.selectedPath); }; onDirentItemClick = (repo, selectedPath, dirent) => { if (dirent.type === 'dir') { this.setState({ repo: repo, selectedPath: selectedPath, }); } else { this.setState({ repo: null, selectedPath: '', }); } }; onRepoItemClick = (repo) => { this.setState({ repo: repo, selectedPath: '/', }); }; render() { return ( {gettext('Save to:')} {this.state.errMessage && {this.state.errMessage}} { this.state.selectedPath ? : } ); } } SaveSharedDirDialog.propTypes = propTypes; export default SaveSharedDirDialog;