Skip to content

Commit c630456

Browse files
farhanclaude
andcommitted
refactor: remove legacy waffle flags, use MFE routes exclusively
Removes all conditional routing based on deprecated waffle flags (useNewCourseOutlinePage, useNewUnitPage, useNewFilesUploadsPage, useNewTextbooksPage, useNewCustomPages, useNewVideoUploadsPage, useNewImportPage, useNewExportPage, useNewUpdatesPage, useNewHomePage, useNewPdfEditor). MFE paths are now always used. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 94900a0 commit c630456

20 files changed

Lines changed: 39 additions & 170 deletions

File tree

plugins/course-apps/proctoring/Settings.test.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,8 @@ describe('ProctoredExamSettings', () => {
471471
screen.getByDisplayValue('mockproc');
472472
});
473473
// (1) for studio settings
474-
// (2) waffle flags
475-
// (3) for course details
476-
expect(axiosMock.history.get.length).toBe(3);
474+
// (2) for course details
475+
expect(axiosMock.history.get.length).toBe(2);
477476
expect(axiosMock.history.get[0].url.includes('proctored_exam_settings')).toEqual(true);
478477
});
479478

src/CourseAuthoringContext.tsx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { getConfig } from '@edx/frontend-platform';
21
import {
32
createContext,
43
useContext,
@@ -10,7 +9,7 @@ import { useNavigate } from 'react-router';
109
import { useToggleWithValue } from '@src/hooks';
1110
import { type UnitXBlock, type XBlock } from '@src/data/types';
1211
import { CourseDetailsData } from './data/api';
13-
import { useCourseDetails, useWaffleFlags } from './data/apiHooks';
12+
import { useCourseDetails } from './data/apiHooks';
1413
import { RequestStatusType } from './data/constants';
1514
import { getOutlineIndexData } from './course-outline/data/selectors';
1615

@@ -53,7 +52,6 @@ export const CourseAuthoringProvider = ({
5352
courseId,
5453
}: CourseAuthoringProviderProps) => {
5554
const navigate = useNavigate();
56-
const waffleFlags = useWaffleFlags();
5755
const { data: courseDetails, status: courseDetailStatus } = useCourseDetails(courseId);
5856
const canChangeProviders = getAuthenticatedUser().administrator || new Date(courseDetails?.start ?? 0) > new Date();
5957
const { courseStructure } = useSelector(getOutlineIndexData);
@@ -65,25 +63,13 @@ export const CourseAuthoringProvider = ({
6563
closeUnlinkModal,
6664
] = useToggleWithValue<ModalState>();
6765

68-
const getUnitUrl = (locator: string) => {
69-
if (getConfig().ENABLE_UNIT_PAGE === 'true' && waffleFlags.useNewUnitPage) {
70-
// instanbul ignore next
71-
return `/course/${courseId}/container/${locator}`;
72-
}
73-
return `${getConfig().STUDIO_BASE_URL}/container/${locator}`;
74-
};
66+
const getUnitUrl = (locator: string) => `/course/${courseId}/container/${locator}`;
7567

7668
/**
7769
* Open the unit page for a given locator.
7870
*/
7971
const openUnitPage = async (locator: string) => {
80-
const url = getUnitUrl(locator);
81-
if (getConfig().ENABLE_UNIT_PAGE === 'true' && waffleFlags.useNewUnitPage) {
82-
// instanbul ignore next
83-
navigate(url);
84-
} else {
85-
window.location.assign(url);
86-
}
72+
navigate(getUnitUrl(locator));
8773
};
8874

8975
const context = useMemo<CourseAuthoringContextData>(() => ({

src/course-checklist/ChecklistSection/ChecklistItemBody.jsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,18 @@ import { ActionRow, Button, Icon } from '@openedx/paragon';
55
import { CheckCircle, RadioButtonUnchecked } from '@openedx/paragon/icons';
66
import { getConfig } from '@edx/frontend-platform';
77

8-
import { useWaffleFlags } from '@src/data/apiHooks';
9-
108
import messages from './messages';
119

12-
const getUpdateLinks = (courseId, waffleFlags) => {
10+
const getUpdateLinks = (courseId) => {
1311
const baseUrl = getConfig().STUDIO_BASE_URL;
14-
const isLegacyOutlineUrl = !waffleFlags.useNewCourseOutlinePage;
1512

1613
return {
1714
welcomeMessage: `/course/${courseId}/course_info`,
1815
gradingPolicy: `/course/${courseId}/settings/grading`,
1916
certificate: `/course/${courseId}/certificates`,
2017
courseDates: `/course/${courseId}/settings/details/#schedule`,
2118
proctoringEmail: `${baseUrl}/pages-and-resources/proctoring/settings`,
22-
outline: isLegacyOutlineUrl ? `${baseUrl}/course/${courseId}` : `/course/${courseId}`,
19+
outline: `/course/${courseId}`,
2320
};
2421
};
2522

@@ -29,8 +26,7 @@ const ChecklistItemBody = ({
2926
isCompleted,
3027
}) => {
3128
const intl = useIntl();
32-
const waffleFlags = useWaffleFlags(courseId);
33-
const updateLinks = getUpdateLinks(courseId, waffleFlags);
29+
const updateLinks = getUpdateLinks(courseId);
3430

3531
return (
3632
<ActionRow>

src/course-checklist/ChecklistSection/ChecklistItemComment.jsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,14 @@ import { FormattedMessage, FormattedNumber } from '@edx/frontend-platform/i18n';
33
import { Icon } from '@openedx/paragon';
44
import { Link } from 'react-router-dom';
55
import { ModeComment } from '@openedx/paragon/icons';
6-
import { getConfig } from '@edx/frontend-platform';
7-
import { useWaffleFlags } from '../../data/apiHooks';
86
import messages from './messages';
97

108
const ChecklistItemComment = ({
119
courseId,
1210
checkId,
1311
data,
1412
}) => {
15-
const waffleFlags = useWaffleFlags(courseId);
16-
17-
const getPathToCourseOutlinePage = (assignmentId) => (waffleFlags.useNewCourseOutlinePage
18-
? `/course/${courseId}#${assignmentId}` :
19-
`${getConfig().STUDIO_BASE_URL}/course/${courseId}#${assignmentId}`);
13+
const getPathToCourseOutlinePage = (assignmentId) => `/course/${courseId}#${assignmentId}`;
2014

2115
const commentWrapper = (comment) => (
2216
<div className="row m-0 mt-3 pt-3 border-top align-items-center" data-identifier="comment">

src/course-unit/add-component/AddComponent.test.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
/* eslint-disable react/prop-types */
33
import userEvent, { UserEvent } from '@testing-library/user-event';
44

5-
import { mockWaffleFlags } from '@src/data/apiHooks.mock';
65
import { RenderResult } from '@testing-library/react';
76
import {
87
act,
@@ -360,20 +359,6 @@ describe('<AddComponent />', () => {
360359
}, expect.any(Function));
361360
});
362361

363-
it('adds a PDF block and launches the legacy iframe editor', async () => {
364-
const user = userEvent.setup();
365-
mockWaffleFlags({ useNewPdfEditor: false });
366-
const { getByRole, queryAllByRole } = renderComponent();
367-
await createPdfBlock({ getByRole, queryAllByRole, user });
368-
expect(handleCreateNewCourseXBlockMock).toHaveBeenCalled();
369-
expect(handleCreateNewCourseXBlockMock).toHaveBeenCalledWith({
370-
parentLocator: '123',
371-
type: COMPONENT_TYPES.pdf,
372-
// Setting the category and not supplying an additional function launches the traditional editor.
373-
category: COMPONENT_TYPES.pdf,
374-
});
375-
});
376-
377362
it('verifies "Text" component selection in modal', async () => {
378363
const user = userEvent.setup();
379364
const { getByRole, getByText } = renderComponent();

src/course-unit/add-component/AddComponent.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const AddComponent = ({
8686
const [selectedComponents, setSelectedComponents] = useState<SelectedComponent[]>([]);
8787
const [usageId, setUsageId] = useState(null);
8888
const { sendMessageToIframe } = useIframe();
89-
const { useVideoGalleryFlow, useNewPdfEditor } = useWaffleFlags(courseId ?? undefined);
89+
const { useVideoGalleryFlow } = useWaffleFlags(courseId ?? undefined);
9090

9191
const courseUnit = useSelector(getCourseUnitData);
9292
const sequenceId = courseUnit?.ancestorInfo?.ancestors?.[0]?.id;
@@ -181,13 +181,13 @@ const AddComponent = ({
181181
// *in code* and not just in UI seems like a mistake in retrospect.
182182
//
183183
// There will be more of these, and soon.
184-
if (moduleName === COMPONENT_TYPES.pdf && useNewPdfEditor) {
184+
if (moduleName === COMPONENT_TYPES.pdf) {
185185
handleCreateNewCourseXBlock(
186186
{ type: moduleName, parentLocator: blockId },
187187
/* istanbul ignore next */
188188
({ courseKey, locator }) => {
189189
setCourseId(courseKey);
190-
setBlockType(moduleName);
190+
setBlockType(moduleName ?? null);
191191
setNewBlockId(locator);
192192
showXBlockEditorModal();
193193
},

src/course-unit/breadcrumbs/Breadcrumbs.test.tsx

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import userEvent from '@testing-library/user-event';
2-
import { getConfig } from '@edx/frontend-platform';
32
import {
43
initializeMocks,
54
waitFor,
@@ -150,24 +149,4 @@ describe('<Breadcrumbs />', () => {
150149
await user.click(dropdownItem);
151150
expect(dropdownItem).toHaveAttribute('href', url);
152151
});
153-
154-
it('falls back to window.location.href when the waffle flag is disabled', async () => {
155-
const user = userEvent.setup();
156-
// eslint-disable-next-line @typescript-eslint/naming-convention
157-
const { ancestor_xblocks: [{ children: [{ display_name, url }] }] } = courseSectionVerticalMock;
158-
axiosMock
159-
.onGet(getApiWaffleFlagsUrl(courseId))
160-
.reply(200, { useNewCourseOutlinePage: false });
161-
162-
const { getByText, getByRole } = renderComponent();
163-
164-
const dropdownBtn = getByText(breadcrumbsExpected.section.displayName);
165-
await user.click(dropdownBtn);
166-
167-
const dropdownItem = getByRole('link', { name: display_name });
168-
// We need waitFor here because the waffle flag defaults to true but asynchronously loads false from our axiosMock
169-
await waitFor(() => {
170-
expect(dropdownItem).toHaveAttribute('href', `${getConfig().STUDIO_BASE_URL}${url}`);
171-
});
172-
});
173152
});

src/course-unit/breadcrumbs/Breadcrumbs.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,21 @@ import {
55
ArrowDropDown as ArrowDropDownIcon,
66
ChevronRight as ChevronRightIcon,
77
} from '@openedx/paragon/icons';
8-
import { getConfig } from '@edx/frontend-platform';
9-
10-
import { useWaffleFlags } from '../../data/apiHooks';
118
import { getCourseSectionVertical } from '../data/selectors';
129
import { adoptCourseSectionUrl, subsectionFirstUnitEditUrl } from '../utils';
1310

1411
const Breadcrumbs = ({ courseId, parentUnitId }: { courseId: string; parentUnitId: string; }) => {
1512
const { ancestorXblocks = [] } = useSelector(getCourseSectionVertical);
16-
const waffleFlags = useWaffleFlags(courseId);
17-
18-
const getPathToCourseOutlinePage = (url) => (waffleFlags.useNewCourseOutlinePage
19-
? url :
20-
`${getConfig().STUDIO_BASE_URL}${url}`);
2113

22-
const getPathToCourseUnitPage = (url) => (waffleFlags.useNewUnitPage
23-
? adoptCourseSectionUrl({ url, courseId, parentUnitId })
24-
: `${getConfig().STUDIO_BASE_URL}${url}`);
14+
const getPathToCourseUnitPage = (url) => adoptCourseSectionUrl({ url, courseId, parentUnitId });
2515

2616
// based on the level of breadcrumbs the url will differ
2717
// at the subsection level it should navigate to the first unit if available
2818
// if no unit then navigate to the subsection outline
2919
function getPathToCoursePage(index, url, usageKey: string) {
3020
let navUrl: string;
3121
if (index === 0) {
32-
navUrl = getPathToCourseOutlinePage(url);
22+
navUrl = url;
3323
} else if (index === 1) {
3424
navUrl = subsectionFirstUnitEditUrl({ courseId, subsectionId: usageKey });
3525
} else {

src/custom-pages/CustomPages.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import DraggableList, { SortableItem } from '@src/generic/DraggableList';
2828
import ErrorAlert from '@src/editors/sharedComponents/ErrorAlerts/ErrorAlert';
2929
import { RequestStatus } from '@src/data/constants';
3030
import { useModels } from '@src/generic/model-store';
31-
import { useWaffleFlags } from '@src/data/apiHooks';
3231
import getPageHeadTitle from '@src/generic/utils';
3332
import { getPagePath } from '@src/utils';
3433
import { DeprecatedReduxState } from '@src/store';
@@ -70,8 +69,6 @@ const CustomPages = () => {
7069
const deletePageStatus = useSelector((state: DeprecatedReduxState) => state.customPages.deletingStatus);
7170
const savingStatus = useSelector(getSavingStatus);
7271
const loadingStatus = useSelector(getLoadingStatus);
73-
const waffleFlags = useWaffleFlags(courseId);
74-
7572
const pages = useModels('customPages', customPagesIds);
7673

7774
const handleAddPage = () => {
@@ -128,9 +125,7 @@ const CustomPages = () => {
128125
links={[
129126
{
130127
label: 'Content',
131-
to: waffleFlags.useNewCourseOutlinePage
132-
? `/course/${courseId}`
133-
: `${config.STUDIO_BASE_URL}/course/${courseId}`,
128+
to: `/course/${courseId}`,
134129
},
135130
{ label: 'Pages and Resources', to: getPagePath(courseId, 'true', 'tabs') },
136131
]}

src/editors/containers/VideoEditor/components/VideoEditorModal.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useEffect } from 'react';
22
import { useDispatch, useSelector } from 'react-redux';
33
import { useLocation } from 'react-router-dom';
4-
import { useWaffleFlags } from '@src/data/apiHooks';
54
import * as appHooks from '../../../hooks';
65
import { thunkActions, selectors } from '../../../data/redux';
76
import VideoSettingsModal from './VideoSettingsModal';
@@ -42,7 +41,6 @@ const VideoEditorModal: React.FC<Props> = ({
4241
const isLoaded = useSelector(
4342
(state) => selectors.requests.isFinished(state, { requestKey: RequestKeys.fetchVideos }),
4443
);
45-
const { useNewVideoUploadsPage } = useWaffleFlags();
4644

4745
useEffect(() => {
4846
hooks.initialize(dispatch, selectedVideoId, selectedVideoUrl);
@@ -54,7 +52,6 @@ const VideoEditorModal: React.FC<Props> = ({
5452
onReturn: onSettingsReturn,
5553
isLibrary,
5654
onClose,
57-
useNewVideoUploadsPage,
5855
}}
5956
/>
6057
);

0 commit comments

Comments
 (0)