fix: update the library scope according to the backend requirements

This commit is contained in:
Diana Olarte
2025-10-09 23:45:58 +11:00
committed by Adolfo R. Brandes
parent 78665d97a5
commit 9e2ab6d647
3 changed files with 6 additions and 5 deletions

View File

@@ -16,7 +16,7 @@ export type PermissionsByRole = {
// TODO: replece api path once is created
export const getTeamMembers = async (object: string): Promise<TeamMember[]> => {
const { data } = await getAuthenticatedHttpClient().get(getApiUrl(`/api/authz/v1/roles/users?scope=${object}`));
const { data } = await getAuthenticatedHttpClient().get(getApiUrl(`/api/authz/v1/roles/users/?scope=${object}`));
return camelCaseObject(data.results);
};
@@ -32,8 +32,8 @@ export const getLibrary = async (libraryId: string): Promise<LibraryMetadata> =>
};
export const getPermissionsByRole = async (scope: string): Promise<PermissionsByRole[]> => {
const url = new URL(getApiUrl('/api/authz/v1/roles'));
const url = new URL(getApiUrl('/api/authz/v1/roles/'));
url.searchParams.append('scope', scope);
const { data } = await getAuthenticatedHttpClient().get(url);
return camelCaseObject(data);
return camelCaseObject(data.results);
};

View File

@@ -132,7 +132,7 @@ describe('usePermissionsByRole', () => {
];
getAuthenticatedHttpClient.mockReturnValue({
get: jest.fn().mockResolvedValue({ data: mockRoles }),
get: jest.fn().mockResolvedValue({ data: { results: mockRoles } }),
});
const wrapper = createWrapper();

View File

@@ -9,7 +9,8 @@ import { PermissionMetadata, ResourceMetadata, Role } from 'types';
import { libraryPermissions, libraryResourceTypes, libraryRolesMetadata } from './constants';
const LIBRARY_TEAM_PERMISSIONS = ['view_library_team', 'manage_library_team'];
const LIBRARY_AUTHZ_SCOPE = 'lib:*';
// Note: This value can change in the future
const LIBRARY_AUTHZ_SCOPE = '*';
export type AppContextType = {
authenticatedUser: {