Skip to content

Commit c8a95eb

Browse files
feat!: organize plugin slots as components, add footer slot (openedx#1408)
BREAKING CHANGE: slot ids have been changed for consistency * `sequence_container_plugin` -> `sequence_container_slot` * `unit_title_plugin` -> `unit_title_slot` Co-authored-by: Brian Smith <[email protected]>
1 parent 7bb75dd commit c8a95eb

File tree

18 files changed

+8503
-6309
lines changed

18 files changed

+8503
-6309
lines changed

README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ The Learning MFE is similar to all the other Open edX MFEs. Read the Open
100100
edX Developer Guide's section on
101101
`MFE applications <https://edx.readthedocs.io/projects/edx-developer-docs/en/latest/developers_guide/micro_frontends_in_open_edx.html>`_.
102102

103+
Plugins
104+
=======
105+
This MFE can be customized using `Frontend Plugin Framework <https://github.com/openedx/frontend-plugin-framework>`_.
106+
107+
The parts of this MFE that can be customized in that manner are documented `here </src/plugin-slots>`_.
108+
103109
Environment Variables
104110
======================
105111

package-lock.json

Lines changed: 8296 additions & 6278 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
},
3232
"dependencies": {
3333
"@edx/brand": "npm:@openedx/brand-openedx@^1.2.2",
34-
"@edx/frontend-component-footer": "^13.0.4",
3534
"@edx/frontend-component-header": "^5.0.2",
3635
"@edx/frontend-lib-learning-assistant": "^2.0.0",
3736
"@edx/frontend-lib-special-exams": "^3.0.1",
@@ -43,7 +42,8 @@
4342
"@fortawesome/free-regular-svg-icons": "5.15.4",
4443
"@fortawesome/free-solid-svg-icons": "5.15.4",
4544
"@fortawesome/react-fontawesome": "^0.1.4",
46-
"@openedx/frontend-plugin-framework": "^1.0.2",
45+
"@openedx/frontend-plugin-framework": "^1.1.2",
46+
"@openedx/frontend-slot-footer": "^1.0.2",
4747
"@openedx/paragon": "^22.3.0",
4848
"@popperjs/core": "2.11.8",
4949
"@reduxjs/toolkit": "1.8.1",

src/courseware/course/sequence/Sequence.jsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import {
99
import { useIntl } from '@edx/frontend-platform/i18n';
1010
import { useSelector } from 'react-redux';
1111
import SequenceExamWrapper from '@edx/frontend-lib-special-exams';
12-
import { PluginSlot } from '@openedx/frontend-plugin-framework';
1312

1413
import PageLoading from '@src/generic/PageLoading';
1514
import { useModel } from '@src/generic/model-store';
1615
import { useSequenceBannerTextAlert, useSequenceEntranceExamAlert } from '@src/alerts/sequence-alerts/hooks';
16+
import SequenceContainerSlot from '../../../plugin-slots/SequenceContainerSlot';
1717

1818
import { getCoursewareOutlineSidebarSettings } from '../../data/selectors';
1919
import CourseLicense from '../course-license';
@@ -202,13 +202,7 @@ const Sequence = ({
202202
</div>
203203
{isNewDiscussionSidebarViewEnabled ? <NewSidebar /> : <Sidebar />}
204204
</div>
205-
<PluginSlot
206-
id="sequence_container_plugin"
207-
pluginProps={{
208-
courseId,
209-
unitId,
210-
}}
211-
/>
205+
<SequenceContainerSlot courseId={courseId} unitId={unitId} />
212206
</>
213207
);
214208

src/courseware/course/sequence/Unit/__snapshots__/index.test.jsx.snap

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,9 @@ exports[`Unit component output snapshot: not bookmarked, do not show content 1`]
2828
>
2929
unit-title
3030
</h3>
31-
<PluginSlot
32-
id="unit_title_plugin"
33-
pluginProps={
34-
Object {
35-
"courseId": "test-course-id",
36-
"unitId": "test-props-id",
37-
}
38-
}
31+
<UnitTitleSlot
32+
courseId="test-course-id"
33+
unitId="test-props-id"
3934
/>
4035
</div>
4136
<h2

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import { useIntl } from '@edx/frontend-platform/i18n';
77
import { useModel } from '@src/generic/model-store';
88
import { usePluginsCallback } from '@src/generic/plugin-store';
99

10-
import { PluginSlot } from '@openedx/frontend-plugin-framework';
1110
import BookmarkButton from '../../bookmark/BookmarkButton';
1211
import messages from '../messages';
1312
import ContentIFrame from './ContentIFrame';
1413
import UnitSuspense from './UnitSuspense';
1514
import { modelKeys, views } from './constants';
1615
import { useExamAccess, useShouldDisplayHonorCode } from './hooks';
1716
import { getIFrameUrl } from './urls';
17+
import UnitTitleSlot from '../../../../plugin-slots/UnitTitleSlot';
1818

1919
const Unit = ({
2020
courseId,
@@ -43,13 +43,7 @@ const Unit = ({
4343
<div className="unit">
4444
<div className="mb-0">
4545
<h3 className="h3">{unit.title}</h3>
46-
<PluginSlot
47-
id="unit_title_plugin"
48-
pluginProps={{
49-
courseId,
50-
unitId: id,
51-
}}
52-
/>
46+
<UnitTitleSlot courseId={courseId} unitId={id} />
5347
</div>
5448
<h2 className="sr-only">{formatMessage(messages.headerPlaceholder)}</h2>
5549
<BookmarkButton

src/generic/CourseAccessErrorPage.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, { useEffect } from 'react';
22
import { LearningHeader as Header } from '@edx/frontend-component-header';
3-
import Footer from '@edx/frontend-component-footer';
43
import { useParams, Navigate } from 'react-router-dom';
54
import { useDispatch, useSelector } from 'react-redux';
65
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
6+
import FooterSlot from '@openedx/frontend-slot-footer';
77
import useActiveEnterpriseAlert from '../alerts/active-enteprise-alert';
88
import { AlertList } from './user-messages';
99
import { fetchDiscussionTab } from '../course-home/data/thunks';
@@ -32,7 +32,7 @@ const CourseAccessErrorPage = ({ intl }) => {
3232
<PageLoading
3333
srMessage={intl.formatMessage(messages.loading)}
3434
/>
35-
<Footer />
35+
<FooterSlot />
3636
</>
3737
);
3838
}
@@ -51,7 +51,7 @@ const CourseAccessErrorPage = ({ intl }) => {
5151
}}
5252
/>
5353
</main>
54-
<Footer />
54+
<FooterSlot />
5555
</>
5656
);
5757
};

src/plugin-slots/FooterSlot/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Footer Slot
2+
3+
### Slot ID: `footer_slot`
4+
5+
## Description
6+
7+
This slot is used to replace/modify/hide the footer.
8+
9+
The implementation of the `FooterSlot` component lives in [the `frontend-slot-footer` repository](https://github.com/openedx/frontend-slot-footer/).
10+
11+
## Example
12+
13+
The following `env.config.jsx` will replace the default footer.
14+
15+
![Screenshot of Default Footer](./images/default_footer.png)
16+
17+
with a simple custom footer
18+
19+
![Screenshot of Custom Footer](./images/custom_footer.png)
20+
21+
```jsx
22+
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
23+
24+
const config = {
25+
pluginSlots: {
26+
footer_slot: {
27+
plugins: [
28+
{
29+
// Hide the default footer
30+
op: PLUGIN_OPERATIONS.Hide,
31+
widgetId: 'default_contents',
32+
},
33+
{
34+
// Insert a custom footer
35+
op: PLUGIN_OPERATIONS.Insert,
36+
widget: {
37+
id: 'custom_footer',
38+
type: DIRECT_PLUGIN,
39+
RenderWidget: () => (
40+
<h1 style={{textAlign: 'center'}}>🦶</h1>
41+
),
42+
},
43+
},
44+
]
45+
}
46+
},
47+
}
48+
49+
export default config;
50+
```
5.67 KB
Loading
6.14 KB
Loading

0 commit comments

Comments
 (0)