|
@@ -1,12 +1,12 @@
|
|
|
import React, { Fragment } from 'react';
|
|
import React, { Fragment } from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
-import * as toastr from 'toastr';
|
|
|
|
|
-
|
|
|
|
|
import UserGroupTable from './UserGroupTable';
|
|
import UserGroupTable from './UserGroupTable';
|
|
|
import UserGroupCreateForm from './UserGroupCreateForm';
|
|
import UserGroupCreateForm from './UserGroupCreateForm';
|
|
|
import UserGroupDeleteModal from './UserGroupDeleteModal';
|
|
import UserGroupDeleteModal from './UserGroupDeleteModal';
|
|
|
|
|
|
|
|
|
|
+import apiErrorHandler from '../../../util/apiErrorHandler';
|
|
|
|
|
+
|
|
|
class UserGroupPage extends React.Component {
|
|
class UserGroupPage extends React.Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
constructor(props) {
|
|
@@ -20,7 +20,8 @@ class UserGroupPage extends React.Component {
|
|
|
|
|
|
|
|
this.showDeleteModal = this.showDeleteModal.bind(this);
|
|
this.showDeleteModal = this.showDeleteModal.bind(this);
|
|
|
this.hideDeleteModal = this.hideDeleteModal.bind(this);
|
|
this.hideDeleteModal = this.hideDeleteModal.bind(this);
|
|
|
- this.addGroup = this.addGroup.bind(this);
|
|
|
|
|
|
|
+ this.addUserGroup = this.addUserGroup.bind(this);
|
|
|
|
|
+ this.removeUserGroupAt = this.removeUserGroupAt.bind(this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async showDeleteModal(group) {
|
|
async showDeleteModal(group) {
|
|
@@ -39,20 +40,28 @@ class UserGroupPage extends React.Component {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- addGroup(newUserGroup) {
|
|
|
|
|
|
|
+ addUserGroup(newUserGroup) {
|
|
|
this.setState((prevState) => {
|
|
this.setState((prevState) => {
|
|
|
return {
|
|
return {
|
|
|
userGroups: [...prevState.userGroups, newUserGroup],
|
|
userGroups: [...prevState.userGroups, newUserGroup],
|
|
|
- isDeleteModalShow: false,
|
|
|
|
|
};
|
|
};
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ removeUserGroupAt(index) {
|
|
|
|
|
+ // this.setState((prevState) => {
|
|
|
|
|
+ // return {
|
|
|
|
|
+ // userGroups: [...prevState.userGroups, newUserGroup],
|
|
|
|
|
+ // isDeleteModalShow: false,
|
|
|
|
|
+ // };
|
|
|
|
|
+ // });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
async syncUserGroupState() {
|
|
async syncUserGroupState() {
|
|
|
let userGroups = [];
|
|
let userGroups = [];
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- const res = await this.props.crowi.apiGet('/admin/user-groups');
|
|
|
|
|
|
|
+ const res = await this.props.crowi.apiGet('/v3/user-groups');
|
|
|
if (res.ok) {
|
|
if (res.ok) {
|
|
|
userGroups = res.userGroups;
|
|
userGroups = res.userGroups;
|
|
|
}
|
|
}
|
|
@@ -61,31 +70,19 @@ class UserGroupPage extends React.Component {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
catch (err) {
|
|
catch (err) {
|
|
|
- this.handleError(err);
|
|
|
|
|
|
|
+ apiErrorHandler(err);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
this.setState({ userGroups });
|
|
this.setState({ userGroups });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- handleError(err) {
|
|
|
|
|
- this.logger.error(err);
|
|
|
|
|
- toastr.error(err, 'Error occured', {
|
|
|
|
|
- closeButton: true,
|
|
|
|
|
- progressBar: true,
|
|
|
|
|
- newestOnTop: false,
|
|
|
|
|
- showDuration: '100',
|
|
|
|
|
- hideDuration: '100',
|
|
|
|
|
- timeOut: '3000',
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
render() {
|
|
render() {
|
|
|
return (
|
|
return (
|
|
|
<Fragment>
|
|
<Fragment>
|
|
|
<UserGroupCreateForm
|
|
<UserGroupCreateForm
|
|
|
crowi={this.props.crowi}
|
|
crowi={this.props.crowi}
|
|
|
isAclEnabled={this.props.isAclEnabled}
|
|
isAclEnabled={this.props.isAclEnabled}
|
|
|
- addGroup={this.addGroup}
|
|
|
|
|
|
|
+ onCreate={this.addUserGroup}
|
|
|
/>
|
|
/>
|
|
|
<UserGroupTable
|
|
<UserGroupTable
|
|
|
crowi={this.props.crowi}
|
|
crowi={this.props.crowi}
|