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 { {gettext('New group')} - + + {this.state.errorMsg} - + ); @@ -53,7 +71,7 @@ class CreateGroupDialog extends React.Component { const CreateGroupDialogPropTypes = { toggleAddGroupModal: PropTypes.func.isRequired, - listGroups: PropTypes.func.isRequired, + onCreateGroup: PropTypes.func.isRequired, showAddGroupModal: PropTypes.bool.isRequired, }; diff --git a/frontend/src/components/toolbar/groups-toolbar.js b/frontend/src/components/toolbar/groups-toolbar.js index 5f3e821c76..e0038ef9b5 100644 --- a/frontend/src/components/toolbar/groups-toolbar.js +++ b/frontend/src/components/toolbar/groups-toolbar.js @@ -21,7 +21,7 @@ class GroupsToolbar extends React.Component { let { onShowSidePanel, onSearchedClick } = this.props; return (
-
+