diff --git a/src/studio-home/StudioHome.jsx b/src/studio-home/StudioHome.jsx
index 6c63e0b6d6..cc62a40a34 100644
--- a/src/studio-home/StudioHome.jsx
+++ b/src/studio-home/StudioHome.jsx
@@ -52,6 +52,7 @@ const StudioHome = ({ intl }) => {
const libMode = getConfig().LIBRARY_MODE;
const v1LibraryTab = isMixedOrV1LibrariesMode(libMode) && location?.pathname.split('/').pop() === 'libraries-v1';
+ const showV2LibraryURL = isMixedOrV2LibrariesMode(libMode) && !v1LibraryTab;
const {
userIsActive,
@@ -59,6 +60,7 @@ const StudioHome = ({ intl }) => {
studioRequestEmail,
libraryAuthoringMfeUrl,
redirectToLibraryAuthoringMfe,
+ showNewLibraryButton,
} = studioHomeData;
const getHeaderButtons = useCallback(() => {
@@ -88,33 +90,35 @@ const StudioHome = ({ intl }) => {
);
}
- const newLibraryClick = () => {
- if (isMixedOrV2LibrariesMode(libMode) && !v1LibraryTab) {
- if (libraryAuthoringMfeUrl && redirectToLibraryAuthoringMfe) {
- // Library authoring MFE
- window.open(constructLibraryAuthoringURL(libraryAuthoringMfeUrl, 'create'));
+ if (showNewLibraryButton || showV2LibraryURL) {
+ const newLibraryClick = () => {
+ if (showV2LibraryURL) {
+ if (libraryAuthoringMfeUrl && redirectToLibraryAuthoringMfe) {
+ // Library authoring MFE
+ window.open(constructLibraryAuthoringURL(libraryAuthoringMfeUrl, 'create'));
+ } else {
+ // Use course-authoring route
+ navigate('/library/create');
+ }
} else {
- // Use course-authoring route
- navigate('/library/create');
+ // Studio home library for legacy libraries
+ window.open(`${getConfig().STUDIO_BASE_URL}/home_library`);
}
- } else {
- // Studio home library for legacy libraries
- window.open(`${getConfig().STUDIO_BASE_URL}/home_library`);
- }
- };
-
- headerButtons.push(
- ,
- );
+ };
+
+ headerButtons.push(
+ ,
+ );
+ }
return headerButtons;
}, [location, userIsActive, isFailedLoadingPage]);
diff --git a/src/studio-home/StudioHome.test.jsx b/src/studio-home/StudioHome.test.jsx
index 88eeccb587..c130d63195 100644
--- a/src/studio-home/StudioHome.test.jsx
+++ b/src/studio-home/StudioHome.test.jsx
@@ -228,6 +228,32 @@ describe('', () => {
});
});
+ it('do not render new library button for "v1 only" mode if showNewLibraryButton is False', () => {
+ setConfig({
+ ...getConfig(),
+ LIBRARY_MODE: 'v1 only',
+ });
+ useSelector.mockReturnValue({
+ ...studioHomeMock,
+ showNewLibraryButton: false,
+ });
+ const { queryByTestId } = render();
+ expect(queryByTestId('new-library-button')).not.toBeInTheDocument();
+ });
+
+ it('render new library button for "v2 only" mode even if showNewLibraryButton is False', () => {
+ setConfig({
+ ...getConfig(),
+ LIBRARY_MODE: 'v2 only',
+ });
+ useSelector.mockReturnValue({
+ ...studioHomeMock,
+ showNewLibraryButton: false,
+ });
+ const { queryByTestId } = render();
+ expect(queryByTestId('new-library-button')).toBeInTheDocument();
+ });
+
it('should render create new course container', async () => {
useSelector.mockReturnValue({
...studioHomeMock,