Skip to content

Commit

Permalink
update err message
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouwenxuan authored and zhouwenxuan committed Dec 16, 2024
1 parent dd329af commit fc90007
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
14 changes: 12 additions & 2 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 @@ -247,12 +252,13 @@ class MoveDirent extends React.Component {
this.setState({
selectedPath: selectedPath,
selectedRepo: repo,
errMessage: '',
});
this.clearErrMessage();
};

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

onCloseSearchBar = () => {
Expand All @@ -265,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 @@ -313,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 @@ -358,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();
};

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

0 comments on commit fc90007

Please sign in to comment.