mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-22 03:47:09 +00:00
[related files] removed all the related functions
This commit is contained in:
@@ -1,13 +1,9 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import MarkdownViewer from '@seafile/seafile-editor/dist/viewer/markdown-viewer';
|
||||
import { gettext, repoID, slug, serviceURL, isPublicWiki, siteRoot, sharedToken, mediaUrl } from '../utils/constants';
|
||||
import { Card, CardTitle, CardText } from 'reactstrap';
|
||||
import { gettext, repoID, slug, serviceURL, isPublicWiki, sharedToken, mediaUrl } from '../utils/constants';
|
||||
import Loading from './loading';
|
||||
import { seafileAPI } from '../utils/seafile-api';
|
||||
import { Utils } from '../utils/utils';
|
||||
import toaster from './toast';
|
||||
import '../css/related-files-list.css';
|
||||
|
||||
const propTypes = {
|
||||
children: PropTypes.object,
|
||||
@@ -31,7 +27,6 @@ class WikiMarkdownViewer extends React.Component {
|
||||
super(props);
|
||||
this.state = {
|
||||
activeTitleIndex: 0,
|
||||
relatedFiles: [],
|
||||
};
|
||||
this.markdownContainer = React.createRef();
|
||||
this.links = [];
|
||||
@@ -44,7 +39,6 @@ class WikiMarkdownViewer extends React.Component {
|
||||
this.links.forEach(link => {
|
||||
link.addEventListener('click', this.onLinkClick);
|
||||
});
|
||||
this.listRelatedFiles();
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
@@ -55,7 +49,6 @@ class WikiMarkdownViewer extends React.Component {
|
||||
this.links.forEach(link => {
|
||||
link.removeEventListener('click', this.onLinkClick);
|
||||
});
|
||||
this.listRelatedFiles();
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
@@ -77,20 +70,6 @@ class WikiMarkdownViewer extends React.Component {
|
||||
this.titlesInfo = markdownViewer.titlesInfo;
|
||||
}
|
||||
|
||||
listRelatedFiles = () => {
|
||||
// for dir-column-file component(import repoID is undefined)
|
||||
if (this.props.repoID && this.props.path) {
|
||||
seafileAPI.listRelatedFiles(this.props.repoID, this.props.path).then(res => {
|
||||
this.setState({
|
||||
relatedFiles: res.data.related_files
|
||||
});
|
||||
}).catch(error => {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onLinkClick = (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
@@ -208,37 +187,6 @@ class WikiMarkdownViewer extends React.Component {
|
||||
);
|
||||
}
|
||||
|
||||
renderRelatedFiles = () => {
|
||||
const relatedFiles = this.state.relatedFiles;
|
||||
if (relatedFiles.length > 0) {
|
||||
return (
|
||||
<div className="sf-releted-files" id="sf-releted-files">
|
||||
<div className="sf-releted-files-header">
|
||||
<h4>{gettext('related files')}</h4>
|
||||
</div>
|
||||
{
|
||||
relatedFiles.map((relatedFile, index) => {
|
||||
let href = siteRoot + 'lib/' + relatedFile.repo_id + '/file' + Utils.encodePath(relatedFile.path);
|
||||
return(
|
||||
<div className="sf-releted-file" key={index}>
|
||||
<a href={href} target="_blank">
|
||||
<Card body size="sm">
|
||||
<CardTitle>{relatedFile.name}</CardTitle>
|
||||
<CardText>{relatedFile.repo_name}</CardText>
|
||||
<span className="sf-releted-file-arrow"></span>
|
||||
</Card>
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
})
|
||||
}
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.props.isFileLoading) {
|
||||
return <Loading />;
|
||||
@@ -250,7 +198,6 @@ class WikiMarkdownViewer extends React.Component {
|
||||
<div className={contentClassName}>
|
||||
{this.props.children}
|
||||
{this.renderMarkdown()}
|
||||
{this.props.isWiki && this.renderRelatedFiles()}
|
||||
<p id="wiki-page-last-modified">{gettext('Last modified by')} {this.props.latestContributor}, <span>{this.props.lastModified}</span></p>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user