mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-08 10:22:46 +00:00
Merge branch '10.0'
This commit is contained in:
@@ -10,6 +10,8 @@ import { Utils } from '../../utils/utils';
|
|||||||
import toaster from '../toast';
|
import toaster from '../toast';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
|
isCurrentRepo: PropTypes.bool,
|
||||||
|
currentPath: PropTypes.string,
|
||||||
isShowFile: PropTypes.bool,
|
isShowFile: PropTypes.bool,
|
||||||
isCurrentRepo: PropTypes.bool,
|
isCurrentRepo: PropTypes.bool,
|
||||||
selectedPath: PropTypes.string,
|
selectedPath: PropTypes.string,
|
||||||
@@ -30,11 +32,43 @@ class RepoListItem extends React.Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
isShowChildren: this.props.initToShowChildren,
|
isShowChildren: this.props.initToShowChildren,
|
||||||
treeData: treeHelper.buildTree(),
|
treeData: treeHelper.buildTree(),
|
||||||
|
hasLoaded: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
const repoID = this.props.repo.repo_id;
|
const { isCurrentRepo, currentPath, repo, selectedItemInfo } = this.props;
|
||||||
|
|
||||||
|
// render search result
|
||||||
|
const { repoID, filePath } = selectedItemInfo || {};
|
||||||
|
if (repoID && repoID === repo.repo_id) {
|
||||||
|
this.loadRepoDirentList(repo);
|
||||||
|
setTimeout(() => {
|
||||||
|
this.setState({isShowChildren: true});
|
||||||
|
this.loadNodeAndParentsByPath(repoID, filePath);
|
||||||
|
}, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the repo is current repo and currentPath is not '/'
|
||||||
|
if (isCurrentRepo && !repoID) {
|
||||||
|
this.loadRepoDirentList(repo);
|
||||||
|
setTimeout(() => {
|
||||||
|
const repoID = repo.repo_id;
|
||||||
|
if (isCurrentRepo && currentPath && currentPath != '/') {
|
||||||
|
const expandNode = true;
|
||||||
|
this.loadNodeAndParentsByPath(repoID, currentPath, expandNode);
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loadRepoDirentList = (repo) => {
|
||||||
|
const { hasLoaded } = this.state;
|
||||||
|
if (hasLoaded) return;
|
||||||
|
|
||||||
|
const repoID = repo.repo_id;
|
||||||
|
|
||||||
seafileAPI.listDir(repoID, '/').then(res => {
|
seafileAPI.listDir(repoID, '/').then(res => {
|
||||||
let tree = this.state.treeData.clone();
|
let tree = this.state.treeData.clone();
|
||||||
let direntList = [];
|
let direntList = [];
|
||||||
@@ -45,22 +79,11 @@ class RepoListItem extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.addResponseListToNode(direntList, tree.root);
|
this.addResponseListToNode(direntList, tree.root);
|
||||||
this.setState({treeData: tree}, () => {
|
this.setState({ treeData: tree, hasLoaded: true });
|
||||||
const { isCurrentRepo, currentPath } = this.props;
|
|
||||||
if (isCurrentRepo && currentPath && currentPath != '/') {
|
|
||||||
const expandNode = true;
|
|
||||||
this.loadNodeAndParentsByPath(repoID, currentPath, expandNode);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
let errMessage = Utils.getErrorMsg(error);
|
||||||
toaster.danger(errMessage);
|
toaster.danger(errMessage);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.props.selectedItemInfo.repoID === this.props.repo.repo_id) {
|
|
||||||
this.setState({isShowChildren: true});
|
|
||||||
this.loadNodeAndParentsByPath(this.props.selectedItemInfo.repoID, this.props.selectedItemInfo.filePath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addResponseListToNode = (list, node) => {
|
addResponseListToNode = (list, node) => {
|
||||||
@@ -145,6 +168,8 @@ class RepoListItem extends React.Component {
|
|||||||
|
|
||||||
onToggleClick = (e) => {
|
onToggleClick = (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
let repo = this.props.repo;
|
||||||
|
this.loadRepoDirentList(repo);
|
||||||
this.setState({isShowChildren: !this.state.isShowChildren});
|
this.setState({isShowChildren: !this.state.isShowChildren});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -154,8 +179,9 @@ class RepoListItem extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onRepoItemClick = (e) => {
|
onRepoItemClick = (e) => {
|
||||||
if (!this.isCurrentRepo() || this.props.selectedPath !== '') {
|
const { repo, selectedPath } = this.props;
|
||||||
this.props.onRepoItemClick(this.props.repo);
|
if (!this.isCurrentRepo() || (selectedPath !== '' && selectedPath !== '/')) {
|
||||||
|
this.props.onRepoItemClick(repo);
|
||||||
} else {
|
} else {
|
||||||
this.onToggleClick(e);
|
this.onToggleClick(e);
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
"displayName": "{{request.user.username|email2nickname|escapejs}}",
|
"displayName": "{{request.user.username|email2nickname|escapejs}}",
|
||||||
"email": "{{request.user.username|escapejs}}",
|
"email": "{{request.user.username|escapejs}}",
|
||||||
"domain": "{{service_url}}",
|
"domain": "{{service_url}}",
|
||||||
"provider": "{{site_name}}",
|
"provider": "seafile",
|
||||||
"userId": "{{request.user.username|escapejs}}",
|
"userId": "{{request.user.username|escapejs}}",
|
||||||
};
|
};
|
||||||
window.AscDesktopEditor.execCommand('portal:login', JSON.stringify(params));
|
window.AscDesktopEditor.execCommand('portal:login', JSON.stringify(params));
|
||||||
|
@@ -125,7 +125,7 @@ html, body { padding:0; margin:0; height:100%; }
|
|||||||
"displayName": "{{request.user.username|email2nickname|escapejs}}",
|
"displayName": "{{request.user.username|email2nickname|escapejs}}",
|
||||||
"email": "{{request.user.username|escapejs}}",
|
"email": "{{request.user.username|escapejs}}",
|
||||||
"domain": "{{service_url}}",
|
"domain": "{{service_url}}",
|
||||||
"provider": "{{site_name}}",
|
"provider": "seafile",
|
||||||
"userId": "{{request.user.username|escapejs}}",
|
"userId": "{{request.user.username|escapejs}}",
|
||||||
};
|
};
|
||||||
window.AscDesktopEditor.execCommand('portal:login', JSON.stringify(params));
|
window.AscDesktopEditor.execCommand('portal:login', JSON.stringify(params));
|
||||||
|
Reference in New Issue
Block a user