Skip to content

Commit a2e33d4

Browse files
committed
fix: use role insted of key for roles identifier
1 parent a07b972 commit a2e33d4

6 files changed

Lines changed: 14 additions & 11 deletions

File tree

src/authz-module/data/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface GetTeamMembersResponse {
99
}
1010

1111
export type PermissionsByRole = {
12-
key: string;
12+
role: string;
1313
permissions: string[];
1414
userCount: number;
1515
};

src/authz-module/data/hooks.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ describe('useLibrary', () => {
127127
describe('usePermissionsByRole', () => {
128128
it('fetches roles for a given scope', async () => {
129129
const mockRoles = [
130-
{ key: 'admin', permissions: ['perm1'], userCount: 1 },
131-
{ key: 'user', permissions: ['perm2'], userCount: 2 },
130+
{ role: 'admin', permissions: ['perm1'], userCount: 1 },
131+
{ role: 'user', permissions: ['perm2'], userCount: 2 },
132132
];
133133

134134
getAuthenticatedHttpClient.mockReturnValue({

src/authz-module/libraries-manager/constants.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { PermissionMetadata, ResourceMetadata, RoleMetadata } from 'types';
33
// Note: this information will eventually come from the backend API
44
// but for the MVP we decided to manage it in the frontend
55
export const libraryRolesMetadata: RoleMetadata[] = [
6-
{ key: 'library_admin', name: 'Library Admin', description: 'The Library Admin has full control over the library, including managing users, modifying content, and handling publishing workflows. They ensure content is properly maintained and accessible as needed.' },
7-
{ key: 'library_author', name: 'Library Author', description: 'The Library Author is responsible for creating, editing, and publishing content within a library. They can manage tags and collections but cannot delete libraries or manage users.' },
8-
{ key: 'library_collaborator', name: 'Library Collaborator', description: 'The Library Collaborator can create and edit content within a library but cannot publish it. They support the authoring process while leaving final publishing to Authors or Admins.' },
9-
{ key: 'library_user', name: 'Library User', description: 'The Library User can view and reuse content but cannot edit or delete any resource.' },
6+
{ role: 'library_admin', name: 'Library Admin', description: 'The Library Admin has full control over the library, including managing users, modifying content, and handling publishing workflows. They ensure content is properly maintained and accessible as needed.' },
7+
{ role: 'library_author', name: 'Library Author', description: 'The Library Author is responsible for creating, editing, and publishing content within a library. They can manage tags and collections but cannot delete libraries or manage users.' },
8+
{ role: 'library_collaborator', name: 'Library Collaborator', description: 'The Library Collaborator can create and edit content within a library but cannot publish it. They support the authoring process while leaving final publishing to Authors or Admins.' },
9+
{ role: 'library_user', name: 'Library User', description: 'The Library User can view and reuse content but cannot edit or delete any resource.' },
1010
];
1111

1212
export const libraryResourceTypes: ResourceMetadata[] = [

src/authz-module/libraries-manager/context.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jest.mock('@src/authz-module/data/hooks', () => ({
1616
usePermissionsByRole: jest.fn().mockReturnValue({
1717
data: [
1818
{
19-
key: 'library_author',
19+
role: 'library_author',
2020
permissions: [
2121
'view_library_team',
2222
'edit_library',

src/authz-module/libraries-manager/context.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ export const LibraryAuthZProvider: React.FC<AuthZProviderProps> = ({ children }:
5151
}
5252

5353
const { data: libraryRoles } = usePermissionsByRole(LIBRARY_AUTHZ_SCOPE);
54-
const roles = libraryRoles.map(role => ({ ...role, ...libraryRolesMetadata.find(r => r.key === role.key) } as Role));
54+
const roles = libraryRoles.map(role => ({
55+
...role,
56+
...libraryRolesMetadata.find(r => r.role === role.role),
57+
} as Role));
5558

5659
const value = useMemo((): LibraryAuthZContextType => ({
5760
username: authenticatedUser.username,

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export interface PermissionValidationRequest {
22
action: string;
3-
object?: string;
43
scope?: string;
54
}
65

@@ -11,6 +10,7 @@ export interface PermissionValidationResponse extends PermissionValidationReques
1110
// Libraries AuthZ types
1211
export interface TeamMember {
1312
username: string;
13+
fullName: string;
1414
email: string;
1515
roles: string[];
1616
}
@@ -23,7 +23,7 @@ export interface LibraryMetadata {
2323
}
2424

2525
export interface RoleMetadata {
26-
key: string;
26+
role: string;
2727
name: string;
2828
description: string;
2929
}

0 commit comments

Comments
 (0)