diff --git a/frontend/src/components/dialog/create-group-dialog.js b/frontend/src/components/dialog/create-group-dialog.js
index 030bebe2b7..a28b0d433e 100644
--- a/frontend/src/components/dialog/create-group-dialog.js
+++ b/frontend/src/components/dialog/create-group-dialog.js
@@ -10,6 +10,7 @@ class CreateGroupDialog extends React.Component {
super(props);
this.state = {
groupName: '',
+ errorMsg: '',
};
}
@@ -18,6 +19,11 @@ class CreateGroupDialog extends React.Component {
this.setState({
groupName: name
});
+ if (this.state.errorMsg) {
+ this.setState({
+ errorMsg: ''
+ })
+ }
}
handleSubmitGroup = () => {
@@ -25,13 +31,23 @@ class CreateGroupDialog extends React.Component {
if (name) {
let that = this;
seafileAPI.createGroup(name).then((res)=> {
- that.props.listGroups();
+ that.props.onCreateGroup();
+ }).catch((error) => {
+ let errorMsg = gettext(error.response.data.error_msg);
+ this.setState({
+ errorMsg: errorMsg
+ });
});
}
this.setState({
groupName: '',
});
- this.props.toggleAddGroupModal();
+ }
+
+ handleKeyDown = (e) => {
+ if (e.keyCode === 13) {
+ this.handleSubmitGroup();
+ }
}
render() {
@@ -40,11 +56,13 @@ class CreateGroupDialog extends React.Component {