Skip to content

Commit

Permalink
fix: new library redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido committed Jun 20, 2024
1 parent 942cbff commit 2d3be09
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/studio-home/StudioHome.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useCallback } from 'react';
import {
Button,
Container,
Expand All @@ -11,6 +11,7 @@ import { Add as AddIcon, Error } from '@openedx/paragon/icons';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { StudioFooter } from '@edx/frontend-component-footer';
import { getConfig, getPath } from '@edx/frontend-platform';
import { useLocation } from 'react-router-dom';

import { constructLibraryAuthoringURL } from '../utils';
import Loading from '../generic/Loading';
Expand All @@ -19,7 +20,7 @@ import Header from '../header';
import SubHeader from '../generic/sub-header/SubHeader';
import HomeSidebar from './home-sidebar';
import TabsSection from './tabs-section';
import { isMixedOrV2LibrariesMode } from './tabs-section/utils';
import { isMixedOrV1LibrariesMode, isMixedOrV2LibrariesMode } from './tabs-section/utils';
import OrganizationSection from './organization-section';
import VerifyEmailLayout from './verify-email-layout';
import CreateNewCourseForm from './create-new-course-form';
Expand All @@ -28,6 +29,8 @@ import { useStudioHome } from './hooks';
import AlertMessage from '../generic/alert-message';

const StudioHome = ({ intl }) => {
const location = useLocation();

const isPaginationCoursesEnabled = getConfig().ENABLE_HOME_PAGE_COURSE_API_V2;
const {
isLoadingPage,
Expand All @@ -47,6 +50,8 @@ const StudioHome = ({ intl }) => {

const libMode = getConfig().LIBRARY_MODE;

const v1LibraryTab = isMixedOrV1LibrariesMode(libMode) && location?.pathname.split('/').pop() === 'libraries-v1';

const {
userIsActive,
studioShortName,
Expand All @@ -55,7 +60,7 @@ const StudioHome = ({ intl }) => {
redirectToLibraryAuthoringMfe,
} = studioHomeData;

function getHeaderButtons() {
const getHeaderButtons = useCallback(() => {
const headerButtons = [];

if (isFailedLoadingPage || !userIsActive) {
Expand Down Expand Up @@ -83,7 +88,7 @@ const StudioHome = ({ intl }) => {
}

let libraryHref = `${getConfig().STUDIO_BASE_URL}/home_library`;
if (isMixedOrV2LibrariesMode(libMode)) {
if (isMixedOrV2LibrariesMode(libMode) && !v1LibraryTab) {
libraryHref = libraryAuthoringMfeUrl && redirectToLibraryAuthoringMfe
? constructLibraryAuthoringURL(libraryAuthoringMfeUrl, 'create')
// Redirection to the placeholder is done in the MFE rather than
Expand All @@ -106,7 +111,7 @@ const StudioHome = ({ intl }) => {
);

return headerButtons;
}
}, [location]);

const headerButtons = userIsActive ? getHeaderButtons() : [];
if (isLoadingPage && !isFiltered) {
Expand Down

0 comments on commit 2d3be09

Please sign in to comment.