From 15e2acc21f522552bccb9e1ad88589db4f81a7a2 Mon Sep 17 00:00:00 2001 From: llj Date: Wed, 15 Dec 2021 14:55:16 +0800 Subject: [PATCH] [file chooser] directly open current folder for 'mv/cp dialog' --- .../components/dialog/copy-dirent-dialog.js | 1 + ...-sub-folder-set-group-permission-dialog.js | 3 ++- ...b-sub-folder-set-user-permission-dialog.js | 3 ++- .../components/dialog/move-dirent-dialog.js | 1 + .../components/file-chooser/file-chooser.js | 6 ++++-- .../components/file-chooser/repo-list-item.js | 21 ++++++++++++++----- .../components/file-chooser/repo-list-view.js | 4 +++- 7 files changed, 29 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/dialog/copy-dirent-dialog.js b/frontend/src/components/dialog/copy-dirent-dialog.js index 1fc8b6cf41..44160469cd 100644 --- a/frontend/src/components/dialog/copy-dirent-dialog.js +++ b/frontend/src/components/dialog/copy-dirent-dialog.js @@ -158,6 +158,7 @@ class CopyDirent extends React.Component { - - { let tree = this.state.treeData.clone(); let direntList = []; @@ -43,7 +43,13 @@ class RepoListItem extends React.Component { } this.addResponseListToNode(direntList, tree.root); - this.setState({treeData: tree}); + this.setState({treeData: tree}, () => { + const { isCurrentRepo, currentPath } = this.props; + if (isCurrentRepo && currentPath && currentPath != '/') { + const expandNode = true; + this.loadNodeAndParentsByPath(repoID, currentPath, expandNode); + } + }); }).catch(error => { let errMessage = Utils.getErrorMsg(error); toaster.danger(errMessage); @@ -98,7 +104,7 @@ class RepoListItem extends React.Component { this.setState({treeData: tree}); } - loadNodeAndParentsByPath = (repoID, path) => { + loadNodeAndParentsByPath = (repoID, path, expandNode) => { let tree = this.state.treeData.clone(); @@ -121,8 +127,13 @@ class RepoListItem extends React.Component { this.addResponseListToNode(results[key], node); } } + this.setState({ treeData: tree + }, () => { + if (expandNode) { + this.onNodeExpanded(tree.getNodeByPath(path)); + } }); }).catch(error => { let errMessage = Utils.getErrorMsg(error); @@ -156,7 +167,7 @@ class RepoListItem extends React.Component { render() { let repoActive = false; let isCurrentRepo = this.isCurrentRepo(); - if (isCurrentRepo && !this.props.selectedPath) { + if (isCurrentRepo && this.props.selectedPath == '/') { repoActive = true; } @@ -164,7 +175,7 @@ class RepoListItem extends React.Component {
  • - {this.props.repo.repo_name} + {this.props.repo.repo_name}
    diff --git a/frontend/src/components/file-chooser/repo-list-view.js b/frontend/src/components/file-chooser/repo-list-view.js index 4bb77683fa..6db4091297 100644 --- a/frontend/src/components/file-chooser/repo-list-view.js +++ b/frontend/src/components/file-chooser/repo-list-view.js @@ -19,7 +19,7 @@ const propTypes = { class RepoListView extends React.Component { render() { - let { currentRepoInfo, repoList } = this.props; + let { currentRepoInfo, currentPath, repoList } = this.props; if (currentRepoInfo) { repoList = []; repoList.push(currentRepoInfo); @@ -30,6 +30,8 @@ class RepoListView extends React.Component { return (