Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions src/course-checklist/ChecklistSection/ChecklistItemBody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,18 @@ import { ActionRow, Button, Icon } from '@openedx/paragon';
import { CheckCircle, RadioButtonUnchecked } from '@openedx/paragon/icons';
import { getConfig } from '@edx/frontend-platform';

import { useWaffleFlags } from '@src/data/apiHooks';

import messages from './messages';

const getUpdateLinks = (courseId, waffleFlags) => {
const getUpdateLinks = (courseId) => {
const baseUrl = getConfig().STUDIO_BASE_URL;
const isLegacyCertificateUrl = !waffleFlags.useNewCertificatesPage;
const isLegacyOutlineUrl = !waffleFlags.useNewCourseOutlinePage;

return {
welcomeMessage: `/course/${courseId}/course_info`,
gradingPolicy: `/course/${courseId}/settings/grading`,
certificate: isLegacyCertificateUrl
? `${baseUrl}/certificates/${courseId}` :
`/course/${courseId}/certificates`,
certificate: `/course/${courseId}/certificates`,
courseDates: `/course/${courseId}/settings/details/#schedule`,
proctoringEmail: `${baseUrl}/pages-and-resources/proctoring/settings`,
outline: isLegacyOutlineUrl ? `${baseUrl}/course/${courseId}` : `/course/${courseId}`,
outline: `/course/${courseId}`,
};
};

Expand All @@ -32,8 +26,7 @@ const ChecklistItemBody = ({
isCompleted,
}) => {
const intl = useIntl();
const waffleFlags = useWaffleFlags(courseId);
const updateLinks = getUpdateLinks(courseId, waffleFlags);
const updateLinks = getUpdateLinks(courseId);

return (
<ActionRow>
Expand Down
14 changes: 0 additions & 14 deletions src/course-unit/add-component/AddComponent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/* eslint-disable react/prop-types */
import userEvent, { UserEvent } from '@testing-library/user-event';

import { mockWaffleFlags } from '@src/data/apiHooks.mock';
import { RenderResult } from '@testing-library/react';
import {
act,
Expand Down Expand Up @@ -360,19 +359,6 @@ describe('<AddComponent />', () => {
}, expect.any(Function));
});

it('adds a PDF block and launches the legacy iframe editor', async () => {
const user = userEvent.setup();
mockWaffleFlags({ useNewPdfEditor: false });
const { getByRole, queryAllByRole } = renderComponent();
await createPdfBlock({ getByRole, queryAllByRole, user });
expect(handleCreateNewCourseXBlockMock).toHaveBeenCalled();
expect(handleCreateNewCourseXBlockMock).toHaveBeenCalledWith({
parentLocator: '123',
type: COMPONENT_TYPES.pdf,
// Setting the category and not supplying an additional function launches the traditional editor.
category: COMPONENT_TYPES.pdf,
});
});

it('verifies "Text" component selection in modal', async () => {
const user = userEvent.setup();
Expand Down
6 changes: 3 additions & 3 deletions src/course-unit/add-component/AddComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const AddComponent = ({
const [selectedComponents, setSelectedComponents] = useState<SelectedComponent[]>([]);
const [usageId, setUsageId] = useState(null);
const { sendMessageToIframe } = useIframe();
const { useVideoGalleryFlow, useNewPdfEditor } = useWaffleFlags(courseId ?? undefined);
const { useVideoGalleryFlow } = useWaffleFlags(courseId ?? undefined);

const courseUnit = useSelector(getCourseUnitData);
const sequenceId = courseUnit?.ancestorInfo?.ancestors?.[0]?.id;
Expand Down Expand Up @@ -181,13 +181,13 @@ const AddComponent = ({
// *in code* and not just in UI seems like a mistake in retrospect.
//
// There will be more of these, and soon.
if (moduleName === COMPONENT_TYPES.pdf && useNewPdfEditor) {
if (moduleName === COMPONENT_TYPES.pdf) {
handleCreateNewCourseXBlock(
{ type: moduleName, parentLocator: blockId },
/* istanbul ignore next */
({ courseKey, locator }) => {
setCourseId(courseKey);
setBlockType(moduleName);
setBlockType(moduleName ?? null);
setNewBlockId(locator);
showXBlockEditorModal();
},
Expand Down
19 changes: 0 additions & 19 deletions src/course-unit/breadcrumbs/Breadcrumbs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,4 @@ describe('<Breadcrumbs />', () => {
expect(dropdownItem).toHaveAttribute('href', url);
});

it('falls back to window.location.href when the waffle flag is disabled', async () => {
const user = userEvent.setup();
// eslint-disable-next-line @typescript-eslint/naming-convention
const { ancestor_xblocks: [{ children: [{ display_name, url }] }] } = courseSectionVerticalMock;
axiosMock
.onGet(getApiWaffleFlagsUrl(courseId))
.reply(200, { useNewCourseOutlinePage: false });

const { getByText, getByRole } = renderComponent();

const dropdownBtn = getByText(breadcrumbsExpected.section.displayName);
await user.click(dropdownBtn);

const dropdownItem = getByRole('link', { name: display_name });
// We need waitFor here because the waffle flag defaults to true but asynchronously loads false from our axiosMock
await waitFor(() => {
expect(dropdownItem).toHaveAttribute('href', `${getConfig().STUDIO_BASE_URL}${url}`);
});
});
});
12 changes: 2 additions & 10 deletions src/course-unit/breadcrumbs/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,15 @@ import {
ArrowDropDown as ArrowDropDownIcon,
ChevronRight as ChevronRightIcon,
} from '@openedx/paragon/icons';
import { getConfig } from '@edx/frontend-platform';

import { useWaffleFlags } from '../../data/apiHooks';
import { getCourseSectionVertical } from '../data/selectors';
import { adoptCourseSectionUrl, subsectionFirstUnitEditUrl } from '../utils';

const Breadcrumbs = ({ courseId, parentUnitId }: { courseId: string; parentUnitId: string; }) => {
const { ancestorXblocks = [] } = useSelector(getCourseSectionVertical);
const waffleFlags = useWaffleFlags(courseId);

const getPathToCourseOutlinePage = (url) => (waffleFlags.useNewCourseOutlinePage
? url :
`${getConfig().STUDIO_BASE_URL}${url}`);
const getPathToCourseOutlinePage = (url) => url;

const getPathToCourseUnitPage = (url) => (waffleFlags.useNewUnitPage
? adoptCourseSectionUrl({ url, courseId, parentUnitId })
: `${getConfig().STUDIO_BASE_URL}${url}`);
const getPathToCourseUnitPage = (url) => adoptCourseSectionUrl({ url, courseId, parentUnitId });

// based on the level of breadcrumbs the url will differ
// at the subsection level it should navigate to the first unit if available
Expand Down
7 changes: 2 additions & 5 deletions src/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { getConfig } from '@edx/frontend-platform';
import { useIntl } from '@edx/frontend-platform/i18n';
import { type Container, useToggle } from '@openedx/paragon';

import { useWaffleFlags } from '../data/apiHooks';
import { SearchModal } from '../search-modal';
import {
useContentMenuItems,
Expand Down Expand Up @@ -38,11 +37,9 @@ const Header = ({
readOnly = false,
}: HeaderProps) => {
const intl = useIntl();
const waffleFlags = useWaffleFlags();

const [isShowSearchModalOpen, openSearchModal, closeSearchModal] = useToggle(false);

const studioBaseUrl = getConfig().STUDIO_BASE_URL;
const meiliSearchEnabled = [true, 'true'].includes(getConfig().MEILISEARCH_ENABLED);

const contentMenuItems = useContentMenuItems(contextId);
Expand Down Expand Up @@ -90,7 +87,7 @@ const Header = ({
if (isLibrary) {
return `/library/${contextId}`;
}
return waffleFlags.useNewCourseOutlinePage ? `/course/${contextId}` : `${studioBaseUrl}/course/${contextId}`;
return `/course/${contextId}`;
};

return (
Expand All @@ -104,7 +101,7 @@ const Header = ({
outlineLink={getOutlineLink()}
searchButtonAction={meiliSearchEnabled ? openSearchModal : undefined}
containerProps={containerProps}
isNewHomePage={waffleFlags.useNewHomePage}
isNewHomePage
/>
{meiliSearchEnabled && (
<SearchModal
Expand Down