diff --git a/.env b/.env index 7c027d7713..d0bb7ec0d8 100644 --- a/.env +++ b/.env @@ -9,7 +9,6 @@ EXAMS_BASE_URL='' FAVICON_URL='' LANGUAGE_PREFERENCE_COOKIE_NAME='' LMS_BASE_URL='' -PREVIEW_BASE_URL='' LEARNING_BASE_URL='' LOGIN_URL='' LOGO_TRADEMARK_URL='' diff --git a/.env.development b/.env.development index 31c11a560f..045c52f2df 100644 --- a/.env.development +++ b/.env.development @@ -42,4 +42,3 @@ HOTJAR_VERSION=6 HOTJAR_DEBUG=true INVITE_STUDENTS_EMAIL_TO="someone@domain.com" AI_TRANSLATIONS_BASE_URL='http://localhost:18760' -PREVIEW_BASE_URL='http://preview.localhost:18000' diff --git a/.env.test b/.env.test index 6a6b7d4dd0..67ad2994bb 100644 --- a/.env.test +++ b/.env.test @@ -8,7 +8,6 @@ EXAMS_BASE_URL= FAVICON_URL='https://edx-cdn.org/v3/default/favicon.ico' LANGUAGE_PREFERENCE_COOKIE_NAME='openedx-language-preference' LMS_BASE_URL='http://localhost:18000' -PREVIEW_BASE_URL='http://preview.localhost:18000' LEARNING_BASE_URL='http://localhost:2000' LOGIN_URL='http://localhost:18000/login' LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg diff --git a/src/course-unit/CourseUnit.jsx b/src/course-unit/CourseUnit.jsx index b532fe0be2..28d3675f0d 100644 --- a/src/course-unit/CourseUnit.jsx +++ b/src/course-unit/CourseUnit.jsx @@ -66,9 +66,7 @@ const CourseUnit = ({ courseId }) => { /> )} breadcrumbs={( - + )} headerActions={( ', () => { const { open } = window; window.open = jest.fn(); const { getByRole } = render(); + const { + draft_preview_link: draftPreviewLink, + published_preview_link: publishedPreviewLink, + } = courseSectionVerticalMock; await waitFor(() => { const viewLiveButton = getByRole('button', { name: headerNavigationsMessages.viewLiveButton.defaultMessage }); userEvent.click(viewLiveButton); expect(window.open).toHaveBeenCalled(); - const VIEW_LIVE_LINK = getConfig().LMS_BASE_URL + getUnitViewLivePath(courseId, blockId); - expect(window.open).toHaveBeenCalledWith(VIEW_LIVE_LINK, '_blank'); + expect(window.open).toHaveBeenCalledWith(publishedPreviewLink, '_blank'); const previewButton = getByRole('button', { name: headerNavigationsMessages.previewButton.defaultMessage }); userEvent.click(previewButton); expect(window.open).toHaveBeenCalled(); - // eslint-disable-next-line max-len - const PREVIEW_LINK = getConfig().PREVIEW_BASE_URL + getUnitPreviewPath(courseId, sectionId, subsectionId, blockId); - expect(window.open).toHaveBeenCalledWith(PREVIEW_LINK, '_blank'); + expect(window.open).toHaveBeenCalledWith(draftPreviewLink, '_blank'); }); window.open = open; diff --git a/src/course-unit/breadcrumbs/Breadcrumbs.jsx b/src/course-unit/breadcrumbs/Breadcrumbs.jsx index ff09ce98ea..17e9953644 100644 --- a/src/course-unit/breadcrumbs/Breadcrumbs.jsx +++ b/src/course-unit/breadcrumbs/Breadcrumbs.jsx @@ -1,4 +1,3 @@ -import PropTypes from 'prop-types'; import { useSelector } from 'react-redux'; import { useIntl } from '@edx/frontend-platform/i18n'; import { Dropdown, Icon } from '@edx/paragon'; @@ -7,34 +6,14 @@ import { ChevronRight as ChevronRightIcon, } from '@edx/paragon/icons'; -import { useCourseOutline } from '../../course-outline/hooks'; -import { getCourseUnitData } from '../data/selectors'; +import { createCorrectInternalRoute } from '../../utils'; +import { getCourseSectionVertical } from '../data/selectors'; import messages from './messages'; -const Breadcrumbs = ({ courseId }) => { +const Breadcrumbs = () => { const intl = useIntl(); - const { ancestorInfo } = useSelector(getCourseUnitData); - const { sectionsList, isLoading: isLoadingCourseOutline } = useCourseOutline({ courseId }); - const activeCourseSectionInfo = sectionsList.find((block) => block.id === ancestorInfo?.ancestors[1]?.id); - - const breadcrumbs = { - section: { - id: ancestorInfo?.ancestors[1]?.id, - displayName: ancestorInfo?.ancestors[1]?.displayName, - dropdownItems: sectionsList, - }, - subsection: { - id: ancestorInfo?.ancestors[0]?.id, - displayName: ancestorInfo?.ancestors[0]?.displayName, - dropdownItems: activeCourseSectionInfo?.childInfo.children || [], - }, - }; - - const getLoadingPlaceholder = () => ( -
- {intl.formatMessage(messages.loading)} -
- ); + const { ancestorXblocks } = useSelector(getCourseSectionVertical); + const [section, subsection] = ancestorXblocks ?? []; return (