feat(authz): [FC-0099] create toggle to make a library public read (#25)
* refactor: modify actions to add splitter * feat: add API function to update the library metadata * feat: create a toggle component to make the library public read * refactor: update behaviour depending on user permissions * feat: add success toast * refactor: use stack to display the actions * style: fix typo * style: add mx-5 to divider to avoid wide growth * chore: update paragon to work with useMediaQuery
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
|
||||
import { LibraryMetadata, TeamMember } from '@src/types';
|
||||
import { camelCaseObject } from '@edx/frontend-platform';
|
||||
import { camelCaseObject, snakeCaseObject } from '@edx/frontend-platform';
|
||||
import { getApiUrl, getStudioApiUrl } from '@src/data/utils';
|
||||
|
||||
export interface QuerySettings {
|
||||
@@ -85,6 +85,7 @@ export const getLibrary = async (libraryId: string): Promise<LibraryMetadata> =>
|
||||
org: data.org,
|
||||
title: data.title,
|
||||
slug: data.slug,
|
||||
allowPublicRead: data.allow_public_read,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -107,3 +108,17 @@ export const revokeUserRoles = async (
|
||||
const res = await getAuthenticatedHttpClient().delete(url.toString());
|
||||
return camelCaseObject(res.data);
|
||||
};
|
||||
|
||||
export const updateLibrary = async (libraryId, updatedData): Promise<LibraryMetadata> => {
|
||||
const { data } = await getAuthenticatedHttpClient().patch(
|
||||
getStudioApiUrl(`/api/libraries/v2/${libraryId}/`),
|
||||
snakeCaseObject(updatedData),
|
||||
);
|
||||
return {
|
||||
id: data.id,
|
||||
org: data.org,
|
||||
title: data.title,
|
||||
slug: data.slug,
|
||||
allowPublicRead: data.allow_public_read,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user