1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-08 18:30:53 +00:00

Merge branch '10.0'

This commit is contained in:
lian
2024-02-27 10:42:10 +08:00
3 changed files with 43 additions and 17 deletions

View File

@@ -10,6 +10,8 @@ import { Utils } from '../../utils/utils';
import toaster from '../toast';
const propTypes = {
isCurrentRepo: PropTypes.bool,
currentPath: PropTypes.string,
isShowFile: PropTypes.bool,
isCurrentRepo: PropTypes.bool,
selectedPath: PropTypes.string,
@@ -30,11 +32,43 @@ class RepoListItem extends React.Component {
this.state = {
isShowChildren: this.props.initToShowChildren,
treeData: treeHelper.buildTree(),
hasLoaded: false,
};
}
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 => {
let tree = this.state.treeData.clone();
let direntList = [];
@@ -45,22 +79,11 @@ class RepoListItem extends React.Component {
}
this.addResponseListToNode(direntList, tree.root);
this.setState({treeData: tree}, () => {
const { isCurrentRepo, currentPath } = this.props;
if (isCurrentRepo && currentPath && currentPath != '/') {
const expandNode = true;
this.loadNodeAndParentsByPath(repoID, currentPath, expandNode);
}
});
this.setState({ treeData: tree, hasLoaded: true });
}).catch(error => {
let errMessage = Utils.getErrorMsg(error);
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) => {
@@ -145,6 +168,8 @@ class RepoListItem extends React.Component {
onToggleClick = (e) => {
e.stopPropagation();
let repo = this.props.repo;
this.loadRepoDirentList(repo);
this.setState({isShowChildren: !this.state.isShowChildren});
};
@@ -154,8 +179,9 @@ class RepoListItem extends React.Component {
};
onRepoItemClick = (e) => {
if (!this.isCurrentRepo() || this.props.selectedPath !== '') {
this.props.onRepoItemClick(this.props.repo);
const { repo, selectedPath } = this.props;
if (!this.isCurrentRepo() || (selectedPath !== '' && selectedPath !== '/')) {
this.props.onRepoItemClick(repo);
} else {
this.onToggleClick(e);
}

View File

@@ -28,7 +28,7 @@
"displayName": "{{request.user.username|email2nickname|escapejs}}",
"email": "{{request.user.username|escapejs}}",
"domain": "{{service_url}}",
"provider": "{{site_name}}",
"provider": "seafile",
"userId": "{{request.user.username|escapejs}}",
};
window.AscDesktopEditor.execCommand('portal:login', JSON.stringify(params));

View File

@@ -125,7 +125,7 @@ html, body { padding:0; margin:0; height:100%; }
"displayName": "{{request.user.username|email2nickname|escapejs}}",
"email": "{{request.user.username|escapejs}}",
"domain": "{{service_url}}",
"provider": "{{site_name}}",
"provider": "seafile",
"userId": "{{request.user.username|escapejs}}",
};
window.AscDesktopEditor.execCommand('portal:login', JSON.stringify(params));