1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 15:09:14 +00:00

Open the edit page when the content is not empty (#3458)

* Open the edit page when the content is not empty

* Use size instead of content

* change func name

* Replace getMarkdownSize with showColumnMarkdownFile
This commit is contained in:
zxj96
2019-05-14 16:58:59 +08:00
committed by Daniel Pan
parent b266592463
commit b5bd705516
2 changed files with 15 additions and 4 deletions

View File

@@ -864,7 +864,7 @@ class LibContentView extends React.Component {
this.showDir(direntPath);
} else { // is file
if (this.state.currentMode === 'column' && Utils.isMarkdownFile(direntPath)) {
this.showFile(direntPath);
this.showColumnMarkdownFile(direntPath);
} else {
const w=window.open('about:blank');
const url = siteRoot + 'lib/' + repoID + '/file' + Utils.encodePath(direntPath);
@@ -1177,7 +1177,7 @@ class LibContentView extends React.Component {
} else {
if (Utils.isMarkdownFile(node.path)) {
if (node.path !== this.state.path) {
this.showFile(node.path);
this.showColumnMarkdownFile(node.path);
}
} else {
const w = window.open('about:blank');
@@ -1187,6 +1187,19 @@ class LibContentView extends React.Component {
}
}
showColumnMarkdownFile = (filePath) => {
let repoID = this.props.repoID;
seafileAPI.getFileInfo(repoID, filePath).then((res) => {
if (res.data.size === 0) {
const w = window.open('about:blank');
const url = siteRoot + 'lib/' + repoID + '/file' + Utils.encodePath(filePath);
w.location.href = url;
} else {
this.showFile(filePath);
}
});
}
onTreeNodeCollapse = (node) => {
let tree = treeHelper.collapseNode(this.state.treeData, node);
this.setState({treeData: tree});