}
+ title={}
subtitle={intl.formatMessage(messages.headingSubtitle)}
- headerActions={[
- ,
- ]}
+ headerActions={}
/>
diff --git a/src/library-authoring/components/LibraryComponents.test.tsx b/src/library-authoring/components/LibraryComponents.test.tsx
index a68309812..c21036b30 100644
--- a/src/library-authoring/components/LibraryComponents.test.tsx
+++ b/src/library-authoring/components/LibraryComponents.test.tsx
@@ -21,6 +21,7 @@ const searchEndpoint = 'http://mock.meilisearch.local/multi-search';
const mockUseLibraryBlockTypes = jest.fn();
const mockFetchNextPage = jest.fn();
const mockUseSearchContext = jest.fn();
+const mockUseContentLibrary = jest.fn();
const data = {
totalHits: 1,
@@ -75,6 +76,7 @@ const blockTypeData = {
jest.mock('../data/apiHooks', () => ({
useLibraryBlockTypes: () => mockUseLibraryBlockTypes(),
+ useContentLibrary: () => mockUseContentLibrary(),
}));
jest.mock('../../search-manager', () => ({
@@ -128,9 +130,31 @@ describe('', () => {
...data,
totalHits: 0,
});
+ mockUseContentLibrary.mockReturnValue({
+ data: {
+ canEditLibrary: true,
+ },
+ });
render();
expect(await screen.findByText(/you have not added any content to this library yet\./i));
+ expect(screen.getByRole('button', { name: /add component/i })).toBeInTheDocument();
+ });
+
+ it('should render empty state without add content button', async () => {
+ mockUseSearchContext.mockReturnValue({
+ ...data,
+ totalHits: 0,
+ });
+ mockUseContentLibrary.mockReturnValue({
+ data: {
+ canEditLibrary: false,
+ },
+ });
+
+ render();
+ expect(await screen.findByText(/you have not added any content to this library yet\./i));
+ expect(screen.queryByRole('button', { name: /add component/i })).not.toBeInTheDocument();
});
it('should render components in full variant', async () => {
diff --git a/src/library-authoring/components/LibraryComponents.tsx b/src/library-authoring/components/LibraryComponents.tsx
index 0e4d97872..24140abac 100644
--- a/src/library-authoring/components/LibraryComponents.tsx
+++ b/src/library-authoring/components/LibraryComponents.tsx
@@ -19,10 +19,7 @@ type LibraryComponentsProps = {
* - 'full': Show all components with Infinite scroll pagination.
* - 'preview': Show first 4 components without pagination.
*/
-const LibraryComponents = ({
- libraryId,
- variant,
-}: LibraryComponentsProps) => {
+const LibraryComponents = ({ libraryId, variant }: LibraryComponentsProps) => {
const {
hits,
totalHits: componentCount,
diff --git a/src/library-authoring/messages.ts b/src/library-authoring/messages.ts
index eb9a9f21f..38332b543 100644
--- a/src/library-authoring/messages.ts
+++ b/src/library-authoring/messages.ts
@@ -100,6 +100,11 @@ const messages = defineMessages({
defaultMessage: 'Close',
description: 'Alt text of close button',
},
+ readOnlyBadge: {
+ id: 'course-authoring.library-authoring.badge.read-only',
+ defaultMessage: 'Read Only',
+ description: 'Text in badge when the user has read only access',
+ },
});
export default messages;