From ea5b2daa3321dee0cf4bfad9a61a8b5747d1b66e Mon Sep 17 00:00:00 2001 From: llj Date: Wed, 16 Feb 2022 11:24:54 +0800 Subject: [PATCH] [move/copy dialog] bugfix for 'mv/cp to current folder' --- .../components/dialog/copy-dirent-dialog.js | 18 ++++++------------ .../components/dialog/move-dirent-dialog.js | 10 +++++----- .../components/file-chooser/file-chooser.js | 1 - 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/frontend/src/components/dialog/copy-dirent-dialog.js b/frontend/src/components/dialog/copy-dirent-dialog.js index 44160469cd..c7ba83ba89 100644 --- a/frontend/src/components/dialog/copy-dirent-dialog.js +++ b/frontend/src/components/dialog/copy-dirent-dialog.js @@ -23,9 +23,9 @@ class CopyDirent extends React.Component { constructor(props) { super(props); this.state = { - repo: null, - selectedPath: '', - errMessage: '', + repo: { repo_id: this.props.repoID }, + selectedPath: this.props.path, + errMessage: '' }; } @@ -92,7 +92,7 @@ class CopyDirent extends React.Component { copyItem = () => { let { repo, repoID, selectedPath } = this.state; let direntPath = Utils.joinPath(this.props.path, this.props.dirent.name); - let message = 'Invalid destination path'; + let message = gettext('Invalid destination path'); if (!repo || (repo.repo_id === repoID && selectedPath === '')) { this.setState({errMessage: message}); @@ -105,12 +105,6 @@ class CopyDirent extends React.Component { return; } - // copy the dirent to current path - if (selectedPath && this.props.path === selectedPath && repo.repo_id === repoID) { - this.setState({errMessage: message}); - return; - } - // copy the dirent to it's child. eg: A/B -> A/B/C if ( selectedPath && selectedPath.length > direntPath.length && selectedPath.indexOf(direntPath) > -1) { message = gettext('Can not copy directory %(src)s to its subdirectory %(des)s'); @@ -132,7 +126,7 @@ class CopyDirent extends React.Component { this.setState({ repo: repo, selectedPath: selectedPath, - errMessage: '', + errMessage: '' }); } @@ -163,7 +157,7 @@ class CopyDirent extends React.Component { onRepoItemClick={this.onRepoItemClick} mode={mode} /> - {this.state.errMessage && {this.state.errMessage}} + {this.state.errMessage && {this.state.errMessage}} diff --git a/frontend/src/components/dialog/move-dirent-dialog.js b/frontend/src/components/dialog/move-dirent-dialog.js index b612d4011a..4e29aaa836 100644 --- a/frontend/src/components/dialog/move-dirent-dialog.js +++ b/frontend/src/components/dialog/move-dirent-dialog.js @@ -23,9 +23,9 @@ class MoveDirent extends React.Component { constructor(props) { super(props); this.state = { - repo: null, - selectedPath: '', - errMessage: '', + repo: { repo_id: this.props.repoID }, + selectedPath: this.props.path, + errMessage: '' }; } @@ -139,7 +139,7 @@ class MoveDirent extends React.Component { this.setState({ repo: repo, selectedPath: selectedPath, - errMessage: '', + errMessage: '' }); } @@ -177,7 +177,7 @@ class MoveDirent extends React.Component { onRepoItemClick={this.onRepoItemClick} mode={mode} /> - {this.state.errMessage && {this.state.errMessage}} + {this.state.errMessage && {this.state.errMessage}} diff --git a/frontend/src/components/file-chooser/file-chooser.js b/frontend/src/components/file-chooser/file-chooser.js index 789b96e7d6..5a357b6e46 100644 --- a/frontend/src/components/file-chooser/file-chooser.js +++ b/frontend/src/components/file-chooser/file-chooser.js @@ -54,7 +54,6 @@ class FileChooser extends React.Component { currentRepoInfo: repoInfo, selectedRepo: repoInfo }); - this.props.onRepoItemClick(repoInfo); }).catch(error => { let errMessage = Utils.getErrorMsg(error); toaster.danger(errMessage);