Skip to content

Commit fb6f110

Browse files
feat: standardize slot ids (#1685)
1 parent 1656b73 commit fb6f110

File tree

60 files changed

+369
-124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+369
-124
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"@fortawesome/free-solid-svg-icons": "5.15.4",
4747
"@fortawesome/react-fontawesome": "^0.1.4",
4848
"@openedx/frontend-build": "^14.5.0",
49-
"@openedx/frontend-plugin-framework": "^1.6.0",
49+
"@openedx/frontend-plugin-framework": "^1.7.0",
5050
"@openedx/frontend-slot-footer": "^1.0.2",
5151
"@openedx/paragon": "^22.16.0",
5252
"@popperjs/core": "2.11.8",

src/course-home/outline-tab/OutlineTab.jsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { sendTrackEvent } from '@edx/frontend-platform/analytics';
55
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
66
import { useIntl } from '@edx/frontend-platform/i18n';
77
import { Button } from '@openedx/paragon';
8-
import { PluginSlot } from '@openedx/frontend-plugin-framework';
8+
import { CourseOutlineTabNotificationsSlot } from '../../plugin-slots/CourseOutlineTabNotificationsSlot';
99
import { AlertList } from '../../generic/user-messages';
1010

1111
import CourseDates from './widgets/CourseDates';
@@ -181,13 +181,7 @@ const OutlineTab = () => {
181181
/>
182182
)}
183183
<CourseTools />
184-
<PluginSlot
185-
id="outline_tab_notifications_slot"
186-
pluginProps={{
187-
courseId,
188-
model: 'outline',
189-
}}
190-
/>
184+
<CourseOutlineTabNotificationsSlot courseId={courseId} />
191185
<CourseDates />
192186
<CourseHandouts />
193187
</div>

src/course-home/outline-tab/OutlineTab.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ describe('Outline Tab', () => {
139139
});
140140
await fetchAndRender();
141141

142-
expect(screen.getByTestId('outline_tab_notifications_slot')).toBeInTheDocument();
142+
expect(screen.getByTestId('org.openedx.frontend.learning.course_outline_tab_notifications.v1')).toBeInTheDocument();
143143
});
144144

145145
it('handles expand/collapse all button click', async () => {

src/courseware/course/new-sidebar/sidebars/discussions-notifications/notifications/NotificationsWidget.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe('NotificationsWidget', () => {
9090
<NotificationsWidget />
9191
</SidebarContext.Provider>,
9292
);
93-
expect(screen.getByTestId('notification_widget_slot')).toBeInTheDocument();
93+
expect(screen.getByTestId('org.openedx.frontend.learning.notification_widget.v1')).toBeInTheDocument();
9494
});
9595

9696
it('renders no notifications bar if no verified mode', async () => {

src/courseware/course/new-sidebar/sidebars/discussions-notifications/notifications/NotificationsWidget.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React, { useContext, useEffect, useMemo } from 'react';
22

33
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
4-
import { PluginSlot } from '@openedx/frontend-plugin-framework';
54
import { useModel } from '../../../../../../generic/model-store';
65
import { WIDGETS } from '../../../../../../constants';
76
import SidebarContext from '../../../SidebarContext';
7+
import { NotificationWidgetSlot } from '../../../../../../plugin-slots/NotificationWidgetSlot';
88

99
const NotificationsWidget = () => {
1010
const {
@@ -67,15 +67,11 @@ const NotificationsWidget = () => {
6767

6868
return (
6969
<div className="border border-light-400 rounded-sm" data-testid="notification-widget">
70-
<PluginSlot
71-
id="notification_widget_slot"
72-
pluginProps={{
73-
courseId,
74-
model: 'coursewareMeta',
75-
notificationCurrentState: upgradeNotificationCurrentState,
76-
setNotificationCurrentState: setUpgradeNotificationCurrentState,
77-
toggleSidebar: onToggleSidebar,
78-
}}
70+
<NotificationWidgetSlot
71+
courseId={courseId}
72+
notificationCurrentState={upgradeNotificationCurrentState}
73+
setNotificationCurrentState={setUpgradeNotificationCurrentState}
74+
toggleSidebar={onToggleSidebar}
7975
/>
8076
</div>
8177
);

src/courseware/course/sequence/Unit/ContentIFrame.jsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import React from 'react';
44
import { ErrorPage } from '@edx/frontend-platform/react';
55
import { StrictDict } from '@edx/react-unit-test-utils';
66
import { ModalDialog, Modal } from '@openedx/paragon';
7-
import { PluginSlot } from '@openedx/frontend-plugin-framework';
7+
import { ContentIFrameLoaderSlot } from '../../../../plugin-slots/ContentIFrameLoaderSlot';
88

9-
import PageLoading from '@src/generic/PageLoading';
109
import * as hooks from './hooks';
1110

1211
/**
@@ -84,17 +83,7 @@ const ContentIFrame = ({
8483
return (
8584
<>
8685
{(shouldShowContent && !hasLoaded) && (
87-
showError ? <ErrorPage /> : (
88-
<PluginSlot
89-
id="content_iframe_loader_slot"
90-
pluginProps={{
91-
defaultLoaderComponent: <PageLoading srMessage={loadingMessage} />,
92-
courseId,
93-
}}
94-
>
95-
<PageLoading srMessage={loadingMessage} />
96-
</PluginSlot>
97-
)
86+
showError ? <ErrorPage /> : <ContentIFrameLoaderSlot courseId={courseId} loadingMessage={loadingMessage} />
9887
)}
9988
{shouldShowContent && (
10089
<div className="unit-iframe-wrapper">

src/courseware/course/sequence/Unit/ContentIFrame.test.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { shallow } from '@edx/react-unit-test-utils';
66

77
import PageLoading from '@src/generic/PageLoading';
88

9+
import { ContentIFrameLoaderSlot } from '@src/plugin-slots/ContentIFrameLoaderSlot';
910
import * as hooks from './hooks';
1011
import ContentIFrame, { IFRAME_FEATURE_POLICY, testIDs } from './ContentIFrame';
1112

@@ -99,8 +100,8 @@ describe('ContentIFrame Component', () => {
99100
});
100101
it('displays PageLoading component if not showError', () => {
101102
el = shallow(<ContentIFrame {...props} />);
102-
[component] = el.instance.findByType(PageLoading);
103-
expect(component.props.srMessage).toEqual(props.loadingMessage);
103+
[component] = el.instance.findByType(ContentIFrameLoaderSlot);
104+
expect(component.props.loadingMessage).toEqual(props.loadingMessage);
104105
});
105106
});
106107
describe('hasLoaded', () => {

src/courseware/course/sequence/Unit/UnitSuspense.jsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import React, { Suspense } from 'react';
22
import PropTypes from 'prop-types';
33

44
import { useIntl } from '@edx/frontend-platform/i18n';
5-
import { PluginSlot } from '@openedx/frontend-plugin-framework';
65

76
import { useModel } from '@src/generic/model-store';
87
import PageLoading from '@src/generic/PageLoading';
8+
import { GatedUnitContentMessageSlot } from '../../../../plugin-slots/GatedUnitContentMessageSlot';
99

1010
import messages from '../messages';
1111
import HonorCode from '../honor-code';
12-
import LockPaywall from '../lock-paywall';
1312
import * as hooks from './hooks';
1413
import { modelKeys } from './constants';
1514

@@ -29,14 +28,7 @@ const UnitSuspense = ({
2928
<>
3029
{shouldDisplayContentGating && (
3130
<Suspense fallback={<PageLoading srMessage={formatMessage(messages.loadingLockedContent)} />}>
32-
<PluginSlot
33-
id="gated_unit_content_message_slot"
34-
pluginProps={{
35-
courseId,
36-
}}
37-
>
38-
<LockPaywall courseId={courseId} />
39-
</PluginSlot>
31+
<GatedUnitContentMessageSlot courseId={courseId} />
4032
</Suspense>
4133
)}
4234
{shouldDisplayHonorCode && (

src/courseware/course/sequence/Unit/UnitSuspense.test.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { formatMessage, shallow } from '@edx/react-unit-test-utils';
55
import { useModel } from '@src/generic/model-store';
66
import PageLoading from '@src/generic/PageLoading';
77

8+
import { GatedUnitContentMessageSlot } from '@src/plugin-slots/GatedUnitContentMessageSlot';
89
import messages from '../messages';
910
import HonorCode from '../honor-code';
1011
import LockPaywall from '../lock-paywall';
@@ -78,10 +79,9 @@ describe('UnitSuspense component', () => {
7879
beforeEach(() => { mockModels(true, true); });
7980
it('displays LockPaywall in Suspense wrapper with PageLoading fallback', () => {
8081
el = shallow(<UnitSuspense {...props} />);
81-
const [component] = el.instance.findByType(LockPaywall);
82-
expect(component.parent.type).toEqual('PluginSlot');
83-
expect(component.parent.parent.type).toEqual('Suspense');
84-
expect(component.parent.parent.props.fallback)
82+
const [component] = el.instance.findByType(GatedUnitContentMessageSlot);
83+
expect(component.parent.type).toEqual('Suspense');
84+
expect(component.parent.props.fallback)
8585
.toEqual(<PageLoading srMessage={formatMessage(messages.loadingLockedContent)} />);
8686
expect(component.props.courseId).toEqual(props.courseId);
8787
});

0 commit comments

Comments
 (0)