Skip to content

Commit 36d676b

Browse files
feat: use frontend-plugin-framework to provide a FooterSlot (#332)
Co-authored-by: Brian Smith <[email protected]>
1 parent 1d924b4 commit 36d676b

13 files changed

+811
-285
lines changed

.env.development

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ LOGOUT_URL='http://localhost:18000/logout'
77
LOGO_URL=https://edx-cdn.org/v3/default/logo.svg
88
LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg
99
LOGO_WHITE_URL=https://edx-cdn.org/v3/default/logo-white.svg
10-
LOGO_POWERED_BY_OPEN_EDX_URL_SVG=https://edx-cdn.org/v3/stage/open-edx-tag.svg
1110
FAVICON_URL=https://edx-cdn.org/v3/default/favicon.ico
1211
CSRF_TOKEN_API_PATH='/csrf/api/v1/token'
1312
REFRESH_ACCESS_TOKEN_ENDPOINT='http://localhost:18000/login_refresh'

.env.test

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ LOGOUT_URL='http://localhost:18000/logout'
77
LOGO_URL=https://edx-cdn.org/v3/default/logo.svg
88
LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg
99
LOGO_WHITE_URL=https://edx-cdn.org/v3/default/logo-white.svg
10-
LOGO_POWERED_BY_OPEN_EDX_URL_SVG=https://edx-cdn.org/v3/stage/open-edx-tag.svg
1110
FAVICON_URL=https://edx-cdn.org/v3/default/favicon.ico
1211
CSRF_TOKEN_API_PATH='/csrf/api/v1/token'
1312
REFRESH_ACCESS_TOKEN_ENDPOINT='http://localhost:18000/login_refresh'

README.rst

+6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ to the `relevant tutor-mfe documentation`_ to get started using it.
3939

4040
.. _relevant tutor-mfe documentation: https://github.com/overhangio/tutor-mfe#mfe-development
4141

42+
Plugins
43+
=======
44+
This MFE can be customized using `Frontend Plugin Framework <https://github.com/openedx/frontend-plugin-framework>`_.
45+
46+
The parts of this MFE that can be customized in that manner are documented `here </src/plugin-slots>`_.
47+
4248
Developing
4349
==========
4450

package-lock.json

+746-266
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
},
2626
"dependencies": {
2727
"@edx/brand": "npm:@openedx/brand-openedx@^1.2.2",
28-
"@edx/frontend-component-footer": "13.0.2",
2928
"@edx/frontend-component-header": "5.0.2",
3029
"@edx/frontend-platform": "7.1.0",
3130
"@edx/openedx-atlas": "^0.6.0",
3231
"@fortawesome/fontawesome-svg-core": "^1.2.36",
3332
"@fortawesome/free-brands-svg-icons": "^5.15.4",
3433
"@fortawesome/free-solid-svg-icons": "^5.15.4",
3534
"@fortawesome/react-fontawesome": "^0.2.0",
35+
"@openedx/frontend-slot-footer": "^1.0.2",
3636
"@openedx/paragon": "21.11.3",
3737
"@redux-beacon/segment": "^1.1.0",
3838
"@reduxjs/toolkit": "^1.6.1",

src/App.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
33
import { connect } from 'react-redux';
44
import { BrowserRouter as Router } from 'react-router-dom';
55

6-
import Footer from '@edx/frontend-component-footer';
6+
import FooterSlot from '@openedx/frontend-slot-footer';
77
import { LearningHeader as Header } from '@edx/frontend-component-header';
88

99
import { selectors } from 'data/redux';
@@ -32,7 +32,7 @@ export const App = ({ courseMetadata, isEnabled }) => (
3232
<main data-testid="main">
3333
<ListView />
3434
</main>
35-
<Footer logo={process.env.LOGO_POWERED_BY_OPEN_EDX_URL_SVG} data-testid="footer" />
35+
<FooterSlot />
3636
</div>
3737
</Router>
3838
);

src/App.test.jsx

+1-6
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ jest.mock('data/redux', () => ({
1515
jest.mock('@edx/frontend-component-header', () => ({
1616
LearningHeader: 'Header',
1717
}));
18-
jest.mock('@edx/frontend-component-footer', () => 'Footer');
18+
jest.mock('@edx/frontend-component-footer', () => ({ FooterSlot: 'Footer' }));
1919

2020
jest.mock('containers/DemoWarning', () => 'DemoWarning');
2121
jest.mock('containers/CTA', () => 'CTA');
2222
jest.mock('containers/ListView', () => 'ListView');
2323
jest.mock('components/Head', () => 'Head');
2424

25-
const logo = 'fakeLogo.png';
2625
let el;
2726

2827
describe('App router component', () => {
@@ -42,7 +41,6 @@ describe('App router component', () => {
4241
});
4342
describe('component', () => {
4443
beforeEach(() => {
45-
process.env.LOGO_POWERED_BY_OPEN_EDX_URL_SVG = logo;
4644
el = shallow(<App {...props} />);
4745
});
4846
describe('Router', () => {
@@ -51,9 +49,6 @@ describe('App router component', () => {
5149
expect(el.instance.findByTestId('main')[0].children[0].type).toBe('ListView');
5250
});
5351
});
54-
test('Footer logo drawn from env variable', () => {
55-
expect(el.instance.findByTestId('footer')[0].props.logo).toEqual(logo);
56-
});
5752

5853
test('Header to use courseMetadata props', () => {
5954
const {

src/__snapshots__/App.test.jsx.snap

+2-8
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ exports[`App router component snapshot: disabled (show demo warning) 1`] = `
1818
>
1919
<ListView />
2020
</main>
21-
<Footer
22-
data-testid="footer"
23-
logo="https://edx-cdn.org/v3/stage/open-edx-tag.svg"
24-
/>
21+
<FooterSlot />
2522
</div>
2623
</BrowserRouter>
2724
`;
@@ -43,10 +40,7 @@ exports[`App router component snapshot: enabled 1`] = `
4340
>
4441
<ListView />
4542
</main>
46-
<Footer
47-
data-testid="footer"
48-
logo="https://edx-cdn.org/v3/stage/open-edx-tag.svg"
49-
/>
43+
<FooterSlot />
5044
</div>
5145
</BrowserRouter>
5246
`;

src/plugin-slots/FooterSlot/README.md

+50
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+
```
Loading
Loading

src/plugin-slots/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `frontend-app-ora-grading` Plugin Slots
2+
3+
* [`footer_slot`](./FooterSlot/)

webpack.dev-tutor.config.js

Whitespace-only changes.

0 commit comments

Comments
 (0)