import React from 'react'; import PropTypes from 'prop-types'; import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; import { MarkdownViewer } from '@seafile/seafile-editor'; import Loading from '../../components/loading'; import { seafileAPI } from '../../utils/seafile-api'; import { gettext, mediaUrl } from '../../utils/constants'; import { Utils } from '../../utils/utils'; import toaster from '../toast'; const propTypes = { repoID: PropTypes.string.isRequired, filePath: PropTypes.string.isRequired, fileName: PropTypes.string.isRequired, href: PropTypes.string, toggleCancel: PropTypes.func.isRequired, }; class ReadmeDialog extends React.Component { constructor(props) { super(props); this.state = { readmeContent: null, isLoading: true, }; } componentDidMount() { seafileAPI.getFileDownloadLink(this.props.repoID, this.props.filePath).then(res => { seafileAPI.getFileContent(res.data).then(res => { this.setState({ readmeContent: res.data, isLoading: false, }); }); }).catch(error => { let errMessage = Utils.getErrorMsg(error); toaster.danger(errMessage); }); } render() { return ( {this.props.fileName} {this.state.isLoading ? : } ); } } ReadmeDialog.propTypes = propTypes; export default ReadmeDialog;