Skip to content

Commit b3e0e61

Browse files
committed
refactor: Remove Legacy UI Waffle Flag Consumers
1 parent fc51f17 commit b3e0e61

12 files changed

Lines changed: 18 additions & 170 deletions

File tree

src/authz/hooks.test.ts

Lines changed: 0 additions & 79 deletions
This file was deleted.

src/course-checklist/ChecklistSection/ChecklistItemBody.jsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +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 isLegacyCertificateUrl = !waffleFlags.useNewCertificatesPage;
15-
const isLegacyOutlineUrl = !waffleFlags.useNewCourseOutlinePage;
1612

1713
return {
1814
welcomeMessage: `/course/${courseId}/course_info`,
1915
gradingPolicy: `/course/${courseId}/settings/grading`,
20-
certificate: isLegacyCertificateUrl
21-
? `${baseUrl}/certificates/${courseId}` :
22-
`/course/${courseId}/certificates`,
16+
certificate: `/course/${courseId}/certificates`,
2317
courseDates: `/course/${courseId}/settings/details/#schedule`,
2418
proctoringEmail: `${baseUrl}/pages-and-resources/proctoring/settings`,
25-
outline: isLegacyOutlineUrl ? `${baseUrl}/course/${courseId}` : `/course/${courseId}`,
19+
outline: `/course/${courseId}`,
2620
};
2721
};
2822

@@ -32,8 +26,7 @@ const ChecklistItemBody = ({
3226
isCompleted,
3327
}) => {
3428
const intl = useIntl();
35-
const waffleFlags = useWaffleFlags(courseId);
36-
const updateLinks = getUpdateLinks(courseId, waffleFlags);
29+
const updateLinks = getUpdateLinks(courseId);
3730

3831
return (
3932
<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/header/Header.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { getConfig } from '@edx/frontend-platform';
33
import { useIntl } from '@edx/frontend-platform/i18n';
44
import { type Container, useToggle } from '@openedx/paragon';
55

6-
import { useWaffleFlags } from '../data/apiHooks';
76
import { SearchModal } from '../search-modal';
87
import {
98
useContentMenuItems,
@@ -38,11 +37,9 @@ const Header = ({
3837
readOnly = false,
3938
}: HeaderProps) => {
4039
const intl = useIntl();
41-
const waffleFlags = useWaffleFlags();
4240

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

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

4845
const contentMenuItems = useContentMenuItems(contextId);
@@ -90,7 +87,7 @@ const Header = ({
9087
if (isLibrary) {
9188
return `/library/${contextId}`;
9289
}
93-
return waffleFlags.useNewCourseOutlinePage ? `/course/${contextId}` : `${studioBaseUrl}/course/${contextId}`;
90+
return `/course/${contextId}`;
9491
};
9592

9693
return (
@@ -104,7 +101,7 @@ const Header = ({
104101
outlineLink={getOutlineLink()}
105102
searchButtonAction={meiliSearchEnabled ? openSearchModal : undefined}
106103
containerProps={containerProps}
107-
isNewHomePage={waffleFlags.useNewHomePage}
104+
isNewHomePage
108105
/>
109106
{meiliSearchEnabled && (
110107
<SearchModal

src/studio-home/card-item/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
1818
import { getConfig } from '@edx/frontend-platform';
1919
import { Link } from 'react-router-dom';
2020

21-
import { useWaffleFlags } from '@src/data/apiHooks';
2221
import { COURSE_CREATOR_STATES } from '@src/constants';
2322
import classNames from 'classnames';
2423
import { getStudioHomeData } from '../data/selectors';
@@ -248,11 +247,10 @@ export const CardItem: React.FC<Props> = ({
248247
courseCreatorStatus,
249248
rerunCreatorStatus,
250249
} = useSelector(getStudioHomeData);
251-
const waffleFlags = useWaffleFlags();
252250
const cardRef = useRef<HTMLDivElement>(null);
253251

254252
const destinationUrl: string = path ?? (
255-
waffleFlags.useNewCourseOutlinePage && !isLibraries
253+
!isLibraries
256254
? url
257255
: new URL(url, getConfig().STUDIO_BASE_URL).toString()
258256
);

0 commit comments

Comments
 (0)