Skip to content

Commit

Permalink
perf: update redwood branch with upstream (#9)
Browse files Browse the repository at this point in the history
* feat: use frontend-plugin-framework to provide a FooterSlot (openedx#332)

Co-authored-by: Brian Smith <[email protected]>

* perf: add css-variables support to redwood (#7)

* fix: re create package-lock

* fix: tests failed because axios lib errors

---------

Co-authored-by: Adolfo R. Brandes <[email protected]>
Co-authored-by: Brian Smith <[email protected]>
  • Loading branch information
3 people authored Jul 29, 2024
1 parent f48dcae commit e0b15d0
Show file tree
Hide file tree
Showing 13 changed files with 3,887 additions and 1,875 deletions.
1 change: 0 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ LOGOUT_URL='http://localhost:18000/logout'
LOGO_URL=https://edx-cdn.org/v3/default/logo.svg
LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg
LOGO_WHITE_URL=https://edx-cdn.org/v3/default/logo-white.svg
LOGO_POWERED_BY_OPEN_EDX_URL_SVG=https://edx-cdn.org/v3/stage/open-edx-tag.svg
FAVICON_URL=https://edx-cdn.org/v3/default/favicon.ico
CSRF_TOKEN_API_PATH='/csrf/api/v1/token'
REFRESH_ACCESS_TOKEN_ENDPOINT='http://localhost:18000/login_refresh'
Expand Down
1 change: 0 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ LOGOUT_URL='http://localhost:18000/logout'
LOGO_URL=https://edx-cdn.org/v3/default/logo.svg
LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg
LOGO_WHITE_URL=https://edx-cdn.org/v3/default/logo-white.svg
LOGO_POWERED_BY_OPEN_EDX_URL_SVG=https://edx-cdn.org/v3/stage/open-edx-tag.svg
FAVICON_URL=https://edx-cdn.org/v3/default/favicon.ico
CSRF_TOKEN_API_PATH='/csrf/api/v1/token'
REFRESH_ACCESS_TOKEN_ENDPOINT='http://localhost:18000/login_refresh'
Expand Down
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ to the `relevant tutor-mfe documentation`_ to get started using it.

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

Plugins
=======
This MFE can be customized using `Frontend Plugin Framework <https://github.com/openedx/frontend-plugin-framework>`_.

The parts of this MFE that can be customized in that manner are documented `here </src/plugin-slots>`_.

Developing
==========

Expand Down
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ module.exports = createConfig('jest', {
'src/data/services/lms/fakeData', // don't unit test mock data
'src/test', // don't unit test integration test utils
],
// see https://github.com/axios/axios/issues/5026
moduleNameMapper: {
'^axios$': 'axios/dist/axios.js',
},
testTimeout: 120000,
testEnvironment: 'jsdom',
});
5,674 changes: 3,818 additions & 1,856 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
},
"dependencies": {
"@edx/brand": "npm:@openedx/brand-openedx@^1.2.2",
"@edx/frontend-component-footer": "npm:@edunext/[email protected]",
"@edx/frontend-component-header": "npm:@edunext/[email protected]",
"@edx/frontend-platform": "npm:@edunext/[email protected]",
"@edx/openedx-atlas": "^0.6.0",
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-brands-svg-icons": "^5.15.4",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-fontawesome": "^0.2.0",
"@openedx/frontend-slot-footer": "^1.0.2",
"@openedx/paragon": "23.0.0-alpha.1",
"@redux-beacon/segment": "^1.1.0",
"@reduxjs/toolkit": "^1.6.1",
Expand Down
4 changes: 2 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { BrowserRouter as Router } from 'react-router-dom';

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

import { selectors } from 'data/redux';
Expand Down Expand Up @@ -32,7 +32,7 @@ export const App = ({ courseMetadata, isEnabled }) => (
<main data-testid="main">
<ListView />
</main>
<Footer logo={process.env.LOGO_POWERED_BY_OPEN_EDX_URL_SVG} data-testid="footer" />
<FooterSlot />
</div>
</Router>
);
Expand Down
7 changes: 1 addition & 6 deletions src/App.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ jest.mock('data/redux', () => ({
jest.mock('@edx/frontend-component-header', () => ({
LearningHeader: 'Header',
}));
jest.mock('@edx/frontend-component-footer', () => 'Footer');
jest.mock('@edx/frontend-component-footer', () => ({ FooterSlot: 'Footer' }));

jest.mock('containers/DemoWarning', () => 'DemoWarning');
jest.mock('containers/CTA', () => 'CTA');
jest.mock('containers/ListView', () => 'ListView');
jest.mock('components/Head', () => 'Head');

const logo = 'fakeLogo.png';
let el;

describe('App router component', () => {
Expand All @@ -42,7 +41,6 @@ describe('App router component', () => {
});
describe('component', () => {
beforeEach(() => {
process.env.LOGO_POWERED_BY_OPEN_EDX_URL_SVG = logo;
el = shallow(<App {...props} />);
});
describe('Router', () => {
Expand All @@ -51,9 +49,6 @@ describe('App router component', () => {
expect(el.instance.findByTestId('main')[0].children[0].type).toBe('ListView');
});
});
test('Footer logo drawn from env variable', () => {
expect(el.instance.findByTestId('footer')[0].props.logo).toEqual(logo);
});

test('Header to use courseMetadata props', () => {
const {
Expand Down
10 changes: 2 additions & 8 deletions src/__snapshots__/App.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ exports[`App router component snapshot: disabled (show demo warning) 1`] = `
>
<ListView />
</main>
<Footer
data-testid="footer"
logo="https://edx-cdn.org/v3/stage/open-edx-tag.svg"
/>
<FooterSlot />
</div>
</BrowserRouter>
`;
Expand All @@ -43,10 +40,7 @@ exports[`App router component snapshot: enabled 1`] = `
>
<ListView />
</main>
<Footer
data-testid="footer"
logo="https://edx-cdn.org/v3/stage/open-edx-tag.svg"
/>
<FooterSlot />
</div>
</BrowserRouter>
`;
50 changes: 50 additions & 0 deletions src/plugin-slots/FooterSlot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Footer Slot

### Slot ID: `footer_slot`

## Description

This slot is used to replace/modify/hide the footer.

The implementation of the `FooterSlot` component lives in [the `frontend-slot-footer` repository](https://github.com/openedx/frontend-slot-footer/).

## Example

The following `env.config.jsx` will replace the default footer.

![Screenshot of Default Footer](./images/default_footer.png)

with a simple custom footer

![Screenshot of Custom Footer](./images/custom_footer.png)

```jsx
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';

const config = {
pluginSlots: {
footer_slot: {
plugins: [
{
// Hide the default footer
op: PLUGIN_OPERATIONS.Hide,
widgetId: 'default_contents',
},
{
// Insert a custom footer
op: PLUGIN_OPERATIONS.Insert,
widget: {
id: 'custom_footer',
type: DIRECT_PLUGIN,
RenderWidget: () => (
<h1 style={{textAlign: 'center'}}>🦶</h1>
),
},
},
]
}
},
}

export default config;
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/plugin-slots/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `frontend-app-ora-grading` Plugin Slots

* [`footer_slot`](./FooterSlot/)

0 comments on commit e0b15d0

Please sign in to comment.