import React from 'react'; import PropTypes from 'prop-types'; import { Modal, ModalBody } from 'reactstrap'; import { Utils } from '../../utils/utils'; import { siteRoot, mediaUrl } from '../../utils/constants'; import SeafileMarkdownViewer from '../seafile-markdown-viewer'; import './markdown-viewer-dialog.css'; const propTypes = { path: PropTypes.string.isRequired, repoID: PropTypes.string.isRequired, isFileLoading: PropTypes.bool.isRequired, content: PropTypes.string, lastModified: PropTypes.string, latestContributor: PropTypes.string, onLinkClick: PropTypes.func.isRequired, currentDirent: PropTypes.object, onCloseMarkdownViewDialog: PropTypes.func }; class MarkdownViewerDialog extends React.Component { onOpenFile = (e) => { e.preventDefault(); let { path, repoID, currentDirent } = this.props; let { name } = currentDirent || {}; let newUrl = siteRoot + 'lib/' + repoID + '/file' + Utils.encodePath(path) + (path.endsWith('/') ? '' : '/') + name; window.open(newUrl, '_blank'); }; render() { const { currentDirent } = this.props; const { name } = currentDirent || {}; return (
{name}
); } } MarkdownViewerDialog.propTypes = propTypes; export default MarkdownViewerDialog;