import React from 'react'; import PropTypes from 'prop-types'; import { SeafileMetadata } from '../../metadata'; import { Utils } from '../../utils/utils'; import { gettext, siteRoot, lang, mediaUrl } from '../../utils/constants'; import SeafileMarkdownViewer from '../seafile-markdown-viewer'; const propTypes = { path: PropTypes.string.isRequired, repoID: PropTypes.string.isRequired, hash: PropTypes.string, isFileLoading: PropTypes.bool.isRequired, isFileLoadedErr: PropTypes.bool.isRequired, filePermission: PropTypes.string, content: PropTypes.string, lastModified: PropTypes.string, latestContributor: PropTypes.string, onLinkClick: PropTypes.func.isRequired, currentRepoInfo: PropTypes.object, }; class DirColumnFile extends React.Component { componentDidMount() { if (this.props.hash) { let hash = this.props.hash; setTimeout(function() { window.location.hash = hash; }, 500); } } onEditClick = (e) => { e.preventDefault(); let { path, repoID } = this.props; let url = siteRoot + 'lib/' + repoID + '/file' + Utils.encodePath(path) + '?mode=edit'; window.open(url); }; onOpenFile = (e) => { e.preventDefault(); let { path, repoID } = this.props; let newUrl = siteRoot + 'lib/' + repoID + '/file' + Utils.encodePath(path); window.open(newUrl, '_blank'); }; render() { if (this.props.isFileLoadedErr) { return (