|
@@ -1,5 +1,5 @@
|
|
|
import React, {
|
|
import React, {
|
|
|
- FC, useState, useCallback, useEffect,
|
|
|
|
|
|
|
+ FC, useState, useCallback, useEffect, useMemo,
|
|
|
} from 'react';
|
|
} from 'react';
|
|
|
|
|
|
|
|
|
|
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
apiv3Get, apiv3Put, apiv3Delete, apiv3Post,
|
|
apiv3Get, apiv3Put, apiv3Delete, apiv3Post,
|
|
|
} from '~/client/util/apiv3-client';
|
|
} from '~/client/util/apiv3-client';
|
|
|
import { IUserGroup, IUserGroupHasId } from '~/interfaces/user';
|
|
import { IUserGroup, IUserGroupHasId } from '~/interfaces/user';
|
|
|
|
|
+import Xss from '~/services/xss';
|
|
|
import { useIsAclEnabled } from '~/stores/context';
|
|
import { useIsAclEnabled } from '~/stores/context';
|
|
|
import { useUpdateUserGroupConfirmModal } from '~/stores/modal';
|
|
import { useUpdateUserGroupConfirmModal } from '~/stores/modal';
|
|
|
import {
|
|
import {
|
|
@@ -20,6 +21,7 @@ import {
|
|
|
useSWRxSelectableParentUserGroups, useSWRxSelectableChildUserGroups, useSWRxAncestorUserGroups,
|
|
useSWRxSelectableParentUserGroups, useSWRxSelectableChildUserGroups, useSWRxAncestorUserGroups,
|
|
|
} from '~/stores/user-group';
|
|
} from '~/stores/user-group';
|
|
|
|
|
|
|
|
|
|
+
|
|
|
const UserGroupPageList = dynamic(() => import('./UserGroupPageList'), { ssr: false });
|
|
const UserGroupPageList = dynamic(() => import('./UserGroupPageList'), { ssr: false });
|
|
|
const UserGroupUserModal = dynamic(() => import('./UserGroupUserModal'), { ssr: false });
|
|
const UserGroupUserModal = dynamic(() => import('./UserGroupUserModal'), { ssr: false });
|
|
|
const UserGroupUserTable = dynamic(() => import('./UserGroupUserTable'), { ssr: false });
|
|
const UserGroupUserTable = dynamic(() => import('./UserGroupUserTable'), { ssr: false });
|
|
@@ -33,12 +35,14 @@ const UpdateParentConfirmModal = dynamic(() => import('./UpdateParentConfirmModa
|
|
|
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
|
|
|
+ adminUserGroupDetailContainer: any;
|
|
|
userGroupId?: string,
|
|
userGroupId?: string,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const UserGroupDetailPage = (props: Props) => {
|
|
const UserGroupDetailPage = (props: Props) => {
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
|
|
|
+ const xss = useMemo(() => new Xss(), []);
|
|
|
const { userGroupId: currentUserGroupId } = props;
|
|
const { userGroupId: currentUserGroupId } = props;
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -176,9 +180,16 @@ const UserGroupDetailPage = (props: Props) => {
|
|
|
}, [currentUserGroupId, mutateUserGroupRelations]);
|
|
}, [currentUserGroupId, mutateUserGroupRelations]);
|
|
|
|
|
|
|
|
const removeUserByUsername = useCallback(async(username: string) => {
|
|
const removeUserByUsername = useCallback(async(username: string) => {
|
|
|
- await apiv3Delete(`/user-groups/${currentUserGroupId}/users/${username}`);
|
|
|
|
|
- mutateUserGroupRelations();
|
|
|
|
|
- }, [currentUserGroupId, mutateUserGroupRelations]);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ await apiv3Delete(`/user-groups/${currentUserGroupId}/users/${username}`);
|
|
|
|
|
+ toastSuccess(`Removed "${xss.process(username)}" from "${xss.process(currentUserGroup?.name)}"`);
|
|
|
|
|
+ mutateUserGroupRelations();
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (err) {
|
|
|
|
|
+ // eslint-disable-next-line max-len
|
|
|
|
|
+ toastError(new Error(`Unable to remove "${xss.process(username)}" from "${xss.process(currentUserGroup?.name)}"`));
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [currentUserGroup?.name, currentUserGroupId, mutateUserGroupRelations, xss]);
|
|
|
|
|
|
|
|
const showUpdateModal = useCallback((group: IUserGroupHasId) => {
|
|
const showUpdateModal = useCallback((group: IUserGroupHasId) => {
|
|
|
setUpdateModalShown(true);
|
|
setUpdateModalShown(true);
|