From 2b93273dee8b5a5b8664d427de7610a0cadbb18a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Thu, 28 Sep 2023 15:55:46 +0100 Subject: [PATCH] fix: permissions in the role payload (#4861) Fixes the role payload to include only the needed properties from permissions. Fixes `400` (oneOf schema validation error) in project role creation. --- frontend/src/component/admin/roles/RoleForm/useRoleForm.ts | 4 +++- frontend/src/hooks/api/actions/useRolesApi/useRolesApi.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/component/admin/roles/RoleForm/useRoleForm.ts b/frontend/src/component/admin/roles/RoleForm/useRoleForm.ts index 0b1dfcc4f103..f0fd300a4f86 100644 --- a/frontend/src/component/admin/roles/RoleForm/useRoleForm.ts +++ b/frontend/src/component/admin/roles/RoleForm/useRoleForm.ts @@ -44,7 +44,9 @@ export const useRoleForm = ( name, description, type: type === ROOT_ROLE_TYPE ? 'root-custom' : 'custom', - permissions: Object.values(checkedPermissions), + permissions: Object.values(checkedPermissions).map( + ({ name, environment }) => ({ name, environment }) + ), }); const isNameUnique = (name: string) => { diff --git a/frontend/src/hooks/api/actions/useRolesApi/useRolesApi.ts b/frontend/src/hooks/api/actions/useRolesApi/useRolesApi.ts index f71447f51cb6..d5a9984d5ba6 100644 --- a/frontend/src/hooks/api/actions/useRolesApi/useRolesApi.ts +++ b/frontend/src/hooks/api/actions/useRolesApi/useRolesApi.ts @@ -4,7 +4,7 @@ import useAPI from '../useApi/useApi'; interface IRolePayload { name: string; description: string; - permissions: IPermission[]; + permissions: Pick[]; } export const useRolesApi = () => {