Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/move file to searched dir failed #7197

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions frontend/src/components/dialog/move-dirent-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ class MoveDirent extends React.Component {
this.setState({ errMessage: message });
};

clearErrMessage = () => {
this.setState({ errMessage: '' });
};

updateMode = (mode) => {
if (mode === this.state.mode) return;

Expand Down Expand Up @@ -229,6 +233,7 @@ class MoveDirent extends React.Component {
}

this.setState({ selectedSearchedItem: { repoID: '', filePath: '' } });
this.clearErrMessage();
};

onUpdateSearchStatus = (status) => {
Expand All @@ -237,20 +242,23 @@ class MoveDirent extends React.Component {

onUpdateSearchResults = (results) => {
this.setState({
searchResults: results
searchResults: results,
selectedRepo: results.length > 0 ? new RepoInfo(results[0]) : null,
selectedPath: results.length > 0 ? results[0].path : '',
});
};

onDirentItemClick = (repo, selectedPath) => {
this.setState({
selectedPath: selectedPath,
repo,
errMessage: '',
selectedRepo: repo,
});
this.clearErrMessage();
};

onOpenSearchBar = () => {
this.setState({ showSearchBar: true });
this.clearErrMessage();
};

onCloseSearchBar = () => {
Expand All @@ -263,12 +271,14 @@ class MoveDirent extends React.Component {
showSearchBar: false,
initToShowChildren: mode === MODE_TYPE_MAP.ONLY_CURRENT_LIBRARY,
});
this.clearErrMessage();
};

onSearchedItemClick = (item) => {
item['type'] = item.is_dir ? 'dir' : 'file';
let repo = new RepoInfo(item);
this.onDirentItemClick(repo, item.path, item);
this.clearErrMessage();
};

onSearchedItemDoubleClick = (item) => {
Expand Down Expand Up @@ -311,7 +321,7 @@ class MoveDirent extends React.Component {

render() {
const { dirent, selectedDirentList, isMultipleOperation, path } = this.props;
const { mode, currentRepo, selectedRepo, selectedPath, showSearchBar, searchStatus, searchResults, selectedSearchedRepo } = this.state;
const { mode, currentRepo, selectedRepo, selectedPath, showSearchBar, searchStatus, searchResults, selectedSearchedRepo, errMessage } = this.state;
const movedDirent = dirent || selectedDirentList[0];
const { permission } = movedDirent;
const { isCustomPermission } = Utils.getUserPermission(permission);
Expand Down Expand Up @@ -356,7 +366,9 @@ class MoveDirent extends React.Component {
onCancel={this.toggle}
selectRepo={this.selectRepo}
setSelectedPath={this.setSelectedPath}
errMessage={errMessage}
setErrMessage={this.setErrMessage}
clearErrMessage={this.clearErrMessage}
handleSubmit={this.handleSubmit}
onUpdateMode={this.updateMode}
searchStatus={searchStatus}
Expand Down
12 changes: 7 additions & 5 deletions frontend/src/components/dialog/select-dirent-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class SelectDirentBody extends React.Component {
constructor(props) {
super(props);
this.state = {
errMessage: '',
showCreateFolderDialog: false,
folderListOfSelectedRepo: [],
};
Expand Down Expand Up @@ -52,13 +51,13 @@ class SelectDirentBody extends React.Component {
onDirentItemClick = (repo, selectedPath) => {
this.props.selectRepo(repo);
this.props.setSelectedPath(selectedPath);
this.props.setErrMessage('');
this.props.clearErrMessage();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SelectDirentBody 是公共组件,copy-dirent-dialog 也使用这个组件,this.props.clearErrMessage() 获取不到会出错

};

onRepoItemClick = (repo) => {
this.props.selectRepo(repo);
this.props.setSelectedPath('/');
this.props.setErrMessage('');
this.props.clearErrMessage();
};

loadRepoDirentList = async (repo, path) => {
Expand All @@ -72,7 +71,7 @@ class SelectDirentBody extends React.Component {

createFolder = (fullPath) => {
if (!this.props.selectedRepo) {
this.setState({ errMessage: gettext('Please select a library or folder first.') });
this.props.setErrMessage(gettext('Please select a library or folder first.'));
return;
}
this.newFolderName = fullPath.split('/').pop();
Expand Down Expand Up @@ -103,7 +102,8 @@ class SelectDirentBody extends React.Component {
} else {
this.setState({ folderListOfSelectedRepo: [] });
}
this.setState({ showCreateFolderDialog: !this.state.showCreateFolderDialog, errMessage: '' });
this.setState({ showCreateFolderDialog: !this.state.showCreateFolderDialog });
this.props.clearErrMessage();
};

checkDuplicatedName = (newName) => {
Expand All @@ -120,6 +120,7 @@ class SelectDirentBody extends React.Component {
this.props.selectRepo(null);
}
this.props.setSelectedPath('/');
this.props.clearErrMessage();
};

render() {
Expand Down Expand Up @@ -219,6 +220,7 @@ SelectDirentBody.propTypes = {
selectRepo: PropTypes.func.isRequired,
setSelectedPath: PropTypes.func,
setErrMessage: PropTypes.func,
clearErrMessage: PropTypes.func,
mode: PropTypes.string,
onUpdateMode: PropTypes.func,
searchStatus: PropTypes.string,
Expand Down
Loading