From 0f536028ee99725076fae09237014ef4cc4f8908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Wed, 4 Dec 2024 12:10:09 -0300 Subject: [PATCH] fix: content libraries permission --- src/studio-home/StudioHome.tsx | 6 +++--- src/studio-home/__mocks__/studioHomeMock.js | 1 + src/studio-home/factories/mockApiResponses.jsx | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/studio-home/StudioHome.tsx b/src/studio-home/StudioHome.tsx index aff75fc6bb..bb18984aa1 100644 --- a/src/studio-home/StudioHome.tsx +++ b/src/studio-home/StudioHome.tsx @@ -11,7 +11,7 @@ import { Add as AddIcon, Error } from '@openedx/paragon/icons'; import { useIntl } from '@edx/frontend-platform/i18n'; import { StudioFooter } from '@edx/frontend-component-footer'; import { getConfig } from '@edx/frontend-platform'; -import { useLocation, useNavigate } from 'react-router-dom'; +import { Link, useLocation, useNavigate } from 'react-router-dom'; import Loading from '../generic/Loading'; import InternetConnectionAlert from '../generic/internet-connection-alert'; @@ -57,6 +57,7 @@ const StudioHome = () => { studioShortName, studioRequestEmail, showNewLibraryButton, + showNewLibraryV2Button, } = studioHomeData; const getHeaderButtons = useCallback(() => { @@ -86,7 +87,7 @@ const StudioHome = () => { ); } - if (showNewLibraryButton || showV2LibraryURL) { + if ((showNewLibraryButton && !showV2LibraryURL) || (showV2LibraryURL && showNewLibraryV2Button)) { const newLibraryClick = () => { if (showV2LibraryURL) { navigate('/library/create'); @@ -101,7 +102,6 @@ const StudioHome = () => { variant="outline-primary" iconBefore={AddIcon} size="sm" - disabled={showNewCourseContainer} onClick={newLibraryClick} data-testid="new-library-button" > diff --git a/src/studio-home/__mocks__/studioHomeMock.js b/src/studio-home/__mocks__/studioHomeMock.js index b9aedf3549..dcd313c511 100644 --- a/src/studio-home/__mocks__/studioHomeMock.js +++ b/src/studio-home/__mocks__/studioHomeMock.js @@ -67,6 +67,7 @@ module.exports = { requestCourseCreatorUrl: '/request_course_creator', rerunCreatorStatus: true, showNewLibraryButton: true, + showNewLibraryV2Button: true, splitStudioHome: false, studioName: 'Studio', studioShortName: 'Studio', diff --git a/src/studio-home/factories/mockApiResponses.jsx b/src/studio-home/factories/mockApiResponses.jsx index 8d86e22d4a..4f9ee03eda 100644 --- a/src/studio-home/factories/mockApiResponses.jsx +++ b/src/studio-home/factories/mockApiResponses.jsx @@ -37,6 +37,7 @@ export const generateGetStudioHomeDataApiResponse = () => ({ requestCourseCreatorUrl: '/request_course_creator', rerunCreatorStatus: true, showNewLibraryButton: true, + showNewLibraryV2Button: true, splitStudioHome: false, studioName: 'Studio', studioShortName: 'Studio',