mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-14 15:35:35 +00:00
Merge pull request #5129 from haiwen/mv-cp-fixup
[move/copy dialog] bugfix for 'mv/cp to current folder'
This commit is contained in:
commit
b7ca40d729
@ -23,9 +23,9 @@ class CopyDirent extends React.Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
repo: null,
|
repo: { repo_id: this.props.repoID },
|
||||||
selectedPath: '',
|
selectedPath: this.props.path,
|
||||||
errMessage: '',
|
errMessage: ''
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ class CopyDirent extends React.Component {
|
|||||||
copyItem = () => {
|
copyItem = () => {
|
||||||
let { repo, repoID, selectedPath } = this.state;
|
let { repo, repoID, selectedPath } = this.state;
|
||||||
let direntPath = Utils.joinPath(this.props.path, this.props.dirent.name);
|
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 === '')) {
|
if (!repo || (repo.repo_id === repoID && selectedPath === '')) {
|
||||||
this.setState({errMessage: message});
|
this.setState({errMessage: message});
|
||||||
@ -105,12 +105,6 @@ class CopyDirent extends React.Component {
|
|||||||
return;
|
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
|
// copy the dirent to it's child. eg: A/B -> A/B/C
|
||||||
if ( selectedPath && selectedPath.length > direntPath.length && selectedPath.indexOf(direntPath) > -1) {
|
if ( selectedPath && selectedPath.length > direntPath.length && selectedPath.indexOf(direntPath) > -1) {
|
||||||
message = gettext('Can not copy directory %(src)s to its subdirectory %(des)s');
|
message = gettext('Can not copy directory %(src)s to its subdirectory %(des)s');
|
||||||
@ -132,7 +126,7 @@ class CopyDirent extends React.Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
repo: repo,
|
repo: repo,
|
||||||
selectedPath: selectedPath,
|
selectedPath: selectedPath,
|
||||||
errMessage: '',
|
errMessage: ''
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +157,7 @@ class CopyDirent extends React.Component {
|
|||||||
onRepoItemClick={this.onRepoItemClick}
|
onRepoItemClick={this.onRepoItemClick}
|
||||||
mode={mode}
|
mode={mode}
|
||||||
/>
|
/>
|
||||||
{this.state.errMessage && <Alert color="danger" style={{margin: '0.5rem'}}>{this.state.errMessage}</Alert>}
|
{this.state.errMessage && <Alert color="danger" className="mt-2">{this.state.errMessage}</Alert>}
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button>
|
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button>
|
||||||
|
@ -23,9 +23,9 @@ class MoveDirent extends React.Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
repo: null,
|
repo: { repo_id: this.props.repoID },
|
||||||
selectedPath: '',
|
selectedPath: this.props.path,
|
||||||
errMessage: '',
|
errMessage: ''
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ class MoveDirent extends React.Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
repo: repo,
|
repo: repo,
|
||||||
selectedPath: selectedPath,
|
selectedPath: selectedPath,
|
||||||
errMessage: '',
|
errMessage: ''
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ class MoveDirent extends React.Component {
|
|||||||
onRepoItemClick={this.onRepoItemClick}
|
onRepoItemClick={this.onRepoItemClick}
|
||||||
mode={mode}
|
mode={mode}
|
||||||
/>
|
/>
|
||||||
{this.state.errMessage && <Alert color="danger" style={{margin: '0.5rem'}}>{this.state.errMessage}</Alert>}
|
{this.state.errMessage && <Alert color="danger" className="mt-2">{this.state.errMessage}</Alert>}
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button>
|
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button>
|
||||||
|
@ -54,7 +54,6 @@ class FileChooser extends React.Component {
|
|||||||
currentRepoInfo: repoInfo,
|
currentRepoInfo: repoInfo,
|
||||||
selectedRepo: repoInfo
|
selectedRepo: repoInfo
|
||||||
});
|
});
|
||||||
this.props.onRepoItemClick(repoInfo);
|
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
let errMessage = Utils.getErrorMsg(error);
|
||||||
toaster.danger(errMessage);
|
toaster.danger(errMessage);
|
||||||
|
Loading…
Reference in New Issue
Block a user