From ea5741351d5444f45a034ddac10ecd68ff1daafc Mon Sep 17 00:00:00 2001
From: Michael An <1822852997@qq.com>
Date: Wed, 19 Jun 2019 13:36:57 +0800
Subject: [PATCH] get infos
---
frontend/src/markdown-editor.js | 83 +++++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
diff --git a/frontend/src/markdown-editor.js b/frontend/src/markdown-editor.js
index c736c7f158..32c64e760c 100644
--- a/frontend/src/markdown-editor.js
+++ b/frontend/src/markdown-editor.js
@@ -13,6 +13,8 @@ import InsertRepoImageDialog from './components/dialog/insert-repo-image-dialog'
import { serialize, deserialize } from '@seafile/seafile-editor/dist/utils/slate2markdown';
import LocalDraftDialog from './components/dialog/local-draft-dialog';
import MarkdownViewerToolbar from './components/toolbar/markdown-viewer-toolbar';
+import EditFileTagDialog from './components/dialog/edit-filetag-dialog';
+import RelatedFileDialogs from './components/dialog/related-file-dialogs';
import './css/markdown-viewer/markdown-editor.css';
@@ -294,6 +296,11 @@ class MarkdownEditor extends React.Component {
saving: false,
isLocked: isLocked,
lockedByMe: lockedByMe,
+ relatedFiles: [],
+ fileTagList: [],
+ showRelatedFileDialog: false,
+ showEditFileTagDialog: false,
+ viewMode: 'list_related_file',
};
if (this.state.collabServer) {
@@ -391,6 +398,8 @@ class MarkdownEditor extends React.Component {
showShareLinkDialog: false,
showInsertFileDialog: false,
showInsertRepoImageDialog: false,
+ showRelatedFileDialog: false,
+ showEditFileTagDialog: false,
});
}
@@ -485,6 +494,28 @@ class MarkdownEditor extends React.Component {
showInsertRepoImageDialog: true,
});
break;
+ case 'related_files':
+ if (this.state.relatedFiles.length > 0) {
+ this.setState({
+ showRelatedFileDialog: true,
+ showMarkdownEditorDialog: true,
+ viewMode: 'list_related_file',
+ });
+ }
+ else {
+ this.setState({
+ showRelatedFileDialog: true,
+ showMarkdownEditorDialog: true,
+ viewMode: 'add_related_file',
+ });
+ }
+ break;
+ case 'file_tags':
+ this.setState({
+ showEditFileTagDialog: true,
+ showMarkdownEditorDialog: true,
+ });
+ break;
default:
return;
}
@@ -562,6 +593,8 @@ class MarkdownEditor extends React.Component {
});
}
this.checkDraft();
+ this.listRelatedFiles();
+ this.listFileTags();
setTimeout(() => {
let url = new URL(window.location.href);
@@ -571,6 +604,30 @@ class MarkdownEditor extends React.Component {
}, 100);
}
+ listRelatedFiles = () => {
+ seafileAPI.listRelatedFiles(repoID, filePath).then(res => {
+ this.setState({ relatedFiles: res.data.related_files });
+ });
+ }
+
+ listFileTags = () => {
+ seafileAPI.listFileTags(repoID, filePath).then(res => {
+ let fileTagList = res.data.file_tags;
+ for (let i = 0; i < fileTagList.length; i++) {
+ fileTagList[i].id = fileTagList[i].file_tag_id;
+ }
+ this.setState({ fileTagList: fileTagList });
+ });
+ }
+
+ onRelatedFileChange = () => {
+ this.listRelatedFiles();
+ }
+
+ onFileTagChanged = () => {
+ this.listFileTags();
+ }
+
setFileInfoMtime = (fileInfo) => {
this.setState({
fileInfo: Object.assign({}, this.state.fileInfo, { mtime: fileInfo.mtime, id: fileInfo.id, lastModifier: fileInfo.last_modifier_name })
@@ -736,6 +793,8 @@ class MarkdownEditor extends React.Component {
onSaving={this.onSaving}
contentChanged={this.state.contentChanged}
saving={this.state.saving}
+ fileTagList={this.state.fileTagList}
+ relatedFiles={this.state.relatedFiles}
/>
);
@@ -787,6 +846,30 @@ class MarkdownEditor extends React.Component {
/>
}
+ {this.state.showEditFileTagDialog &&
+
+
+
+ }
+ {this.state.showRelatedFileDialog &&
+
+
+
+ }
)}