Skip to content

Commit

Permalink
fix: new library redirect
Browse files Browse the repository at this point in the history
This reverts commit efe0bed.
  • Loading branch information
rpenido committed Jun 20, 2024
1 parent 942cbff commit 18a8482
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 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,9 @@ const StudioHome = ({ intl }) => {

const libMode = getConfig().LIBRARY_MODE;

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

Check warning on line 54 in src/studio-home/StudioHome.jsx

View workflow job for this annotation

GitHub Actions / tests

Unexpected console statement

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

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

if (isFailedLoadingPage || !userIsActive) {
Expand Down Expand Up @@ -83,14 +89,15 @@ 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
// through the backend i.e. redirection from cms, because this this will probably change,
// hence why we use the MFE's origin
: `${window.location.origin}${getPath(getConfig().PUBLIC_PATH)}library/create`;
}
console.log('libraryHref', libraryHref);

Check warning on line 100 in src/studio-home/StudioHome.jsx

View workflow job for this annotation

GitHub Actions / tests

Unexpected console statement

headerButtons.push(
<Button
Expand All @@ -106,7 +113,7 @@ const StudioHome = ({ intl }) => {
);

return headerButtons;
}
}, [location]);

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

0 comments on commit 18a8482

Please sign in to comment.