Skip to content

Commit

Permalink
fix: permissions in the role payload (#4861)
Browse files Browse the repository at this point in the history
Fixes the role payload to include only the needed properties from
permissions. Fixes `400` (oneOf schema validation error) in project role
creation.
  • Loading branch information
nunogois authored and gastonfournier committed Sep 28, 2023
1 parent 3d427a9 commit 2b93273
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion frontend/src/component/admin/roles/RoleForm/useRoleForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hooks/api/actions/useRolesApi/useRolesApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import useAPI from '../useApi/useApi';
interface IRolePayload {
name: string;
description: string;
permissions: IPermission[];
permissions: Pick<IPermission, 'name' | 'environment'>[];
}

export const useRolesApi = () => {
Expand Down

0 comments on commit 2b93273

Please sign in to comment.