From 273b4d932a91d1874d9fdf49ae66736f6cce8ba6 Mon Sep 17 00:00:00 2001 From: shanghaikid Date: Mon, 28 Aug 2023 15:35:36 +0800 Subject: [PATCH] this fix #251 Signed-off-by: shanghaikid --- client/src/pages/user/Roles.tsx | 6 +++++- client/src/pages/user/UpdateRoleDialog.tsx | 4 +++- server/src/users/users.controller.ts | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/client/src/pages/user/Roles.tsx b/client/src/pages/user/Roles.tsx index dfb29b51..ce60a032 100644 --- a/client/src/pages/user/Roles.tsx +++ b/client/src/pages/user/Roles.tsx @@ -66,7 +66,11 @@ const Roles = () => { const onUpdate = async (data: { isEditing: boolean }) => { fetchRoles(); - openSnackBar(successTrans('create', { name: userTrans('role') })); + openSnackBar( + successTrans(data.isEditing ? 'update' : 'create', { + name: userTrans('role'), + }) + ); handleCloseDialog(); }; diff --git a/client/src/pages/user/UpdateRoleDialog.tsx b/client/src/pages/user/UpdateRoleDialog.tsx index 378d1936..21e3cc76 100644 --- a/client/src/pages/user/UpdateRoleDialog.tsx +++ b/client/src/pages/user/UpdateRoleDialog.tsx @@ -116,7 +116,9 @@ const UpdateRoleDialog: FC = ({ }; const onChange = (newSelection: any) => { - setForm(v => ({ ...v, privileges: [...newSelection] })); + setForm(v => { + return { ...v, privileges: [...newSelection] }; + }); }; const optionGroups: PrivilegeOptionsProps[] = [ diff --git a/server/src/users/users.controller.ts b/server/src/users/users.controller.ts index 1cd40f1d..ef97cf85 100644 --- a/server/src/users/users.controller.ts +++ b/server/src/users/users.controller.ts @@ -231,7 +231,7 @@ export class UserController { try { // revoke all - this.userService.revokeAllRolePrivileges({ roleName }); + await this.userService.revokeAllRolePrivileges({ roleName }); // assign new user roles for (let i = 0; i < privileges.length; i++) {