Compare commits
116 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1abf704144 | ||
|
|
9905fff1a0 | ||
|
|
c63030a52d | ||
|
|
08445d891d | ||
|
|
1dc8f3e654 | ||
|
|
0f56f46109 | ||
|
|
8b9246efe7 | ||
|
|
b1335b9373 | ||
|
|
bbe3b58620 | ||
|
|
c99804bff4 | ||
|
|
2d03191631 | ||
|
|
c23d3fe74d | ||
|
|
1d12c6506e | ||
|
|
39a88243e5 | ||
|
|
9466f6aced | ||
|
|
7cb75a333f | ||
|
|
4dcbae37f2 | ||
|
|
636e71e141 | ||
|
|
320cfa17a2 | ||
|
|
b61302c3f5 | ||
|
|
e6444392a6 | ||
|
|
cd10265c60 | ||
|
|
c7a84e62f1 | ||
|
|
2d3c5ecc4c | ||
|
|
b6c1f77331 | ||
|
|
a3ef54e2bf | ||
|
|
bb69baecb0 | ||
|
|
95e191cf86 | ||
|
|
61702da769 | ||
|
|
47d467747f | ||
|
|
75bd146e72 | ||
|
|
db201af910 | ||
|
|
281b817084 | ||
|
|
08b69b8096 | ||
|
|
7c8876490d | ||
|
|
ba2e46bfa9 | ||
|
|
09cc332306 | ||
|
|
1f91a60b6d | ||
|
|
490da867df | ||
|
|
fd723e6063 | ||
|
|
664ca3e78f | ||
|
|
18a8a76105 | ||
|
|
0ad89f88a1 | ||
|
|
b0391866a3 | ||
|
|
3a9e3f8fba | ||
|
|
b2c55a09e5 | ||
|
|
6795147255 | ||
|
|
a87c111b3c | ||
|
|
655d6c058b | ||
|
|
923009191f | ||
|
|
80da098ec8 | ||
|
|
0197c85de5 | ||
|
|
0ef407458c | ||
|
|
c5d83f658a | ||
|
|
eb941181ea | ||
|
|
ed379258a8 | ||
|
|
8109ba39bb | ||
|
|
ebb87070da | ||
|
|
cbcaf4c9fe | ||
|
|
d3dda9e56d | ||
|
|
db3c54201c | ||
|
|
8f8b4645b4 | ||
|
|
194f93e85e | ||
|
|
10fc7a2d72 | ||
|
|
1d7a871cfd | ||
|
|
cf09847e95 | ||
|
|
84e30f0fb7 | ||
|
|
288b6c7d0f | ||
|
|
9a23003f7f | ||
|
|
922a31b90b | ||
|
|
73236b296b | ||
|
|
eb92d8f1f1 | ||
|
|
bc79936022 | ||
|
|
2aac71a988 | ||
|
|
032105da7f | ||
|
|
6e2ccf2f2c | ||
|
|
907145be24 | ||
|
|
58791757d7 | ||
|
|
583aaf676e | ||
|
|
2e46ec1f9b | ||
|
|
bb80d92512 | ||
|
|
e138dedd29 | ||
|
|
073a6c2a18 | ||
|
|
41cf64b9d7 | ||
|
|
908b5b0b11 | ||
|
|
59dd82c919 | ||
|
|
afed581a18 | ||
|
|
f6b02cbfe7 | ||
|
|
ede01dbd20 | ||
|
|
4a0f244a1a | ||
|
|
906d9a78c1 | ||
|
|
ac0d5f42f7 | ||
|
|
e9d1b435dd | ||
|
|
cc647e7bc8 | ||
|
|
2d5f5fe787 | ||
|
|
ef7bd9284a | ||
|
|
10f9d7c1cd | ||
|
|
6b3a49ccec | ||
|
|
f473c98bb8 | ||
|
|
bd52be3177 | ||
|
|
ef12ac20fe | ||
|
|
7fa6bd8740 | ||
|
|
8d9178f532 | ||
|
|
98bcacfced | ||
|
|
ac78454133 | ||
|
|
09b7c8be9a | ||
|
|
c992a9129a | ||
|
|
7f6ad73a25 | ||
|
|
cefbd28d9b | ||
|
|
c26bdc54e1 | ||
|
|
02f6b44368 | ||
|
|
4cbde7e38f | ||
|
|
bdb6ecb79f | ||
|
|
46c1ffd731 | ||
|
|
b6bd211c6e | ||
|
|
ef8445a1b2 |
4
.github/workflows/ci.yml
vendored
@@ -14,12 +14,10 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Setup Nodejs Env
|
||||
run: echo "NODE_VER=`cat .nvmrc`" >> $GITHUB_ENV
|
||||
- name: Setup Nodejs
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ env.NODE_VER }}
|
||||
node-version-file: '.nvmrc'
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Validate package-lock.json changes
|
||||
|
||||
2
.github/workflows/lockfileversion-check.yml
vendored
@@ -10,4 +10,4 @@ on:
|
||||
|
||||
jobs:
|
||||
version-check:
|
||||
uses: openedx/.github/.github/workflows/lockfile-check.yml@master
|
||||
uses: openedx/.github/.github/workflows/lockfileversion-check-v3.yml@master
|
||||
|
||||
14
.github/workflows/release.yml
vendored
@@ -4,6 +4,11 @@ on:
|
||||
branches:
|
||||
- master
|
||||
- alpha
|
||||
|
||||
permissions:
|
||||
id-token: write # Required for OIDC
|
||||
contents: write # For Semantic Release tagging
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
@@ -13,12 +18,10 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Setup Nodejs Env
|
||||
run: echo "NODE_VER=`cat .nvmrc`" >> $GITHUB_ENV
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ env.NODE_VER }}
|
||||
node-version-file: '.nvmrc'
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Validate package-lock.json changes
|
||||
@@ -37,7 +40,6 @@ jobs:
|
||||
- name: Build
|
||||
run: npm run build
|
||||
- name: Release
|
||||
run: npx semantic-release@25
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}
|
||||
run: npx semantic-release
|
||||
GITHUB_TOKEN: ${{ secrets.OPENEDX_SEMANTIC_RELEASE_GITHUB_TOKEN }}
|
||||
|
||||
2
.gitignore
vendored
@@ -10,4 +10,4 @@ src/i18n/transifex_input.json
|
||||
temp/babel-plugin-react-intl
|
||||
/.vscode
|
||||
module.config.js
|
||||
src/i18n/messages
|
||||
src/i18n/messages
|
||||
|
||||
@@ -62,9 +62,9 @@ Cloning and Startup
|
||||
|
||||
``git clone https://github.com/openedx/frontend-component-footer.git``
|
||||
|
||||
2. Use node v18.x.
|
||||
2. Use node v24.x.
|
||||
|
||||
The current version of the micro-frontend build scripts support node 18.
|
||||
The current version of the micro-frontend build scripts support node 24.
|
||||
Using other major versions of node *may* work, but this is unsupported. For
|
||||
convenience, this repository includes an .nvmrc file to help in setting the
|
||||
correct node version via `nvm <https://github.com/nvm-sh/nvm>`_.
|
||||
@@ -95,9 +95,9 @@ This library has the following exports:
|
||||
|
||||
Plugin
|
||||
======
|
||||
The footer can be replaced using using `Frontend Plugin Framework <https://github.com/openedx/frontend-plugin-framework>`_.
|
||||
The footer can be replaced or modified using `Frontend Plugin Framework <https://github.com/openedx/frontend-plugin-framework>`_.
|
||||
|
||||
Information on how to utilize the ``FooterSlot`` component to do so is available in the `frontend-slot-footer repository <https://github.com/openedx/frontend-slot-footer/>`_.
|
||||
Information on how to replace or modify the footer is available `here </src/plugin-slots>`_.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
14
catalog-info.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
# This file records information about this repo. Its use is described in OEP-55:
|
||||
# https://open-edx-proposals.readthedocs.io/en/latest/processes/oep-0055-proc-project-maintainers.html
|
||||
|
||||
apiVersion: backstage.io/v1alpha1
|
||||
kind: Component
|
||||
metadata:
|
||||
name: "frontend-component-footer"
|
||||
description: "A generic footer for the Open edX micro-frontend applications."
|
||||
annotations:
|
||||
openedx.org/arch-interest-groups: ""
|
||||
spec:
|
||||
owner: group:committers-frontend
|
||||
type: "library"
|
||||
lifecycle: "production"
|
||||
@@ -1,6 +1,4 @@
|
||||
@import "@edx/brand/paragon/fonts";
|
||||
@import "@edx/brand/paragon/variables";
|
||||
@import "@openedx/paragon/scss/core/core";
|
||||
@import "@edx/brand/paragon/overrides";
|
||||
@use "@openedx/paragon/dist/core.min.css" as paragonCore;
|
||||
@use "@openedx/paragon/dist/light.min.css" as paragonLight;
|
||||
|
||||
@import "@edx/frontend-component-footer/footer";
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
# openedx.yaml
|
||||
|
||||
---
|
||||
owner: edx/fedx-team
|
||||
tags:
|
||||
- library
|
||||
- component
|
||||
- react
|
||||
26291
package-lock.json
generated
52
package.json
@@ -10,19 +10,16 @@
|
||||
"build": "make build",
|
||||
"i18n_extract": "fedx-scripts formatjs extract",
|
||||
"lint": "fedx-scripts eslint --ext .js --ext .jsx .",
|
||||
"lint:fix": "fedx-scripts eslint --fix --ext .js --ext .jsx .",
|
||||
"snapshot": "fedx-scripts jest --updateSnapshot",
|
||||
"start": "fedx-scripts webpack-dev-server --progress",
|
||||
"start:with-theme": "paragon install-theme && npm start && npm install",
|
||||
"test": "fedx-scripts jest --coverage"
|
||||
"test": "fedx-scripts jest --coverage",
|
||||
"test:watch": "npm run test -- --watch"
|
||||
},
|
||||
"files": [
|
||||
"/dist"
|
||||
],
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "npm run lint"
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/openedx/frontend-component-footer.git"
|
||||
@@ -36,38 +33,39 @@
|
||||
"devDependencies": {
|
||||
"@edx/brand": "npm:@openedx/brand-openedx@^1.2.2",
|
||||
"@edx/browserslist-config": "^1.1.1",
|
||||
"@edx/frontend-platform": "8.1.0",
|
||||
"@edx/reactifex": "^2.1.1",
|
||||
"@openedx/frontend-build": "14.0.10",
|
||||
"@openedx/frontend-plugin-framework": "^1.1.2",
|
||||
"@openedx/paragon": "22.6.1",
|
||||
"@edx/frontend-platform": "^8.2.1",
|
||||
"@openedx/frontend-build": "^14.3.1",
|
||||
"@openedx/paragon": "^23.3.0",
|
||||
"@testing-library/jest-dom": "^5.16.4",
|
||||
"@testing-library/react": "^12.1.1",
|
||||
"husky": "8.0.3",
|
||||
"@testing-library/react": "^16.2.0",
|
||||
"@testing-library/dom": "^10.4.0",
|
||||
"@testing-library/user-event": "^14.6.1",
|
||||
"prop-types": "15.8.1",
|
||||
"react": "17.0.2",
|
||||
"react-dom": "17.0.2",
|
||||
"react-redux": "7.2.9",
|
||||
"react-router-dom": "6.24.1",
|
||||
"react-test-renderer": "17.0.2",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-redux": "8.1.3",
|
||||
"react-router-dom": "6.30.2",
|
||||
"react-test-renderer": "18.3.1",
|
||||
"redux": "4.2.1",
|
||||
"semantic-release": "21.1.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-svg-core": "6.5.2",
|
||||
"@fortawesome/free-brands-svg-icons": "6.5.2",
|
||||
"@fortawesome/free-regular-svg-icons": "6.5.2",
|
||||
"@fortawesome/free-solid-svg-icons": "6.5.2",
|
||||
"@fortawesome/react-fontawesome": "0.2.2",
|
||||
"jest-environment-jsdom": "^29.7.0",
|
||||
"@fortawesome/fontawesome-svg-core": "6.7.2",
|
||||
"@fortawesome/free-brands-svg-icons": "6.7.2",
|
||||
"@fortawesome/free-regular-svg-icons": "6.7.2",
|
||||
"@fortawesome/free-solid-svg-icons": "6.7.2",
|
||||
"@fortawesome/react-fontawesome": "0.2.6",
|
||||
"@openedx/frontend-plugin-framework": "^1.7.0",
|
||||
"classnames": "^2.5.1",
|
||||
"jest-environment-jsdom": "^30.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"ts-jest": "^29.1.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@edx/frontend-platform": "^7.0.0 || ^8.0.0",
|
||||
"@openedx/paragon": ">= 21.11.3 < 23.0.0",
|
||||
"@openedx/paragon": ">= 21.11.3 < 24.0.0",
|
||||
"prop-types": "^15.5.10",
|
||||
"react": "^16.9.0 || ^17.0.0",
|
||||
"react-dom": "^16.9.0 || ^17.0.0"
|
||||
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
||||
"react-dom": "^16.9.0 || ^17.0.0 || ^18.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
$gray-footer: #fcfcfc !default;
|
||||
|
||||
.footer {
|
||||
background-color: $gray-footer;
|
||||
background-color: var(--pgn-color-light-100, $gray-footer);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import React, { useContext } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
|
||||
import { useIntl } from '@edx/frontend-platform/i18n';
|
||||
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
|
||||
import { ensureConfig } from '@edx/frontend-platform';
|
||||
import { AppContext } from '@edx/frontend-platform/react';
|
||||
@@ -17,13 +17,17 @@ const EVENT_NAMES = {
|
||||
FOOTER_LINK: 'edx.bi.footer.link',
|
||||
};
|
||||
|
||||
class SiteFooter extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.externalLinkClickHandler = this.externalLinkClickHandler.bind(this);
|
||||
}
|
||||
const SiteFooter = ({
|
||||
supportedLanguages,
|
||||
onLanguageSelected,
|
||||
logo,
|
||||
}) => {
|
||||
const intl = useIntl();
|
||||
const { config } = useContext(AppContext);
|
||||
|
||||
externalLinkClickHandler(event) {
|
||||
const showLanguageSelector = supportedLanguages.length > 0 && onLanguageSelected;
|
||||
|
||||
const externalLinkClickHandler = (event) => {
|
||||
const label = event.currentTarget.getAttribute('href');
|
||||
const eventName = EVENT_NAMES.FOOTER_LINK;
|
||||
const properties = {
|
||||
@@ -31,52 +35,39 @@ class SiteFooter extends React.Component {
|
||||
label,
|
||||
};
|
||||
sendTrackEvent(eventName, properties);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
supportedLanguages,
|
||||
onLanguageSelected,
|
||||
logo,
|
||||
intl,
|
||||
} = this.props;
|
||||
const showLanguageSelector = supportedLanguages.length > 0 && onLanguageSelected;
|
||||
const { config } = this.context;
|
||||
|
||||
return (
|
||||
<footer
|
||||
role="contentinfo"
|
||||
className="footer d-flex border-top py-3 px-4"
|
||||
>
|
||||
<div className="container-fluid d-flex">
|
||||
<a
|
||||
className="d-block"
|
||||
href={config.LMS_BASE_URL}
|
||||
aria-label={intl.formatMessage(messages['footer.logo.ariaLabel'])}
|
||||
>
|
||||
<img
|
||||
style={{ maxHeight: 45 }}
|
||||
src={logo || config.LOGO_TRADEMARK_URL}
|
||||
alt={intl.formatMessage(messages['footer.logo.altText'])}
|
||||
/>
|
||||
</a>
|
||||
<div className="flex-grow-1" />
|
||||
{showLanguageSelector && (
|
||||
<LanguageSelector
|
||||
options={supportedLanguages}
|
||||
onSubmit={onLanguageSelected}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
SiteFooter.contextType = AppContext;
|
||||
return (
|
||||
<footer
|
||||
role="contentinfo"
|
||||
className="footer d-flex border-top py-3 px-4"
|
||||
>
|
||||
<div className="container-fluid d-flex">
|
||||
<a
|
||||
className="d-block"
|
||||
href={config.LMS_BASE_URL}
|
||||
aria-label={intl.formatMessage(messages['footer.logo.ariaLabel'])}
|
||||
onClick={externalLinkClickHandler}
|
||||
>
|
||||
<img
|
||||
style={{ maxHeight: 45 }}
|
||||
src={logo || config.LOGO_TRADEMARK_URL}
|
||||
alt={intl.formatMessage(messages['footer.logo.altText'])}
|
||||
/>
|
||||
</a>
|
||||
<div className="flex-grow-1" />
|
||||
{showLanguageSelector && (
|
||||
<LanguageSelector
|
||||
options={supportedLanguages}
|
||||
onSubmit={onLanguageSelected}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
};
|
||||
|
||||
SiteFooter.propTypes = {
|
||||
intl: intlShape.isRequired,
|
||||
logo: PropTypes.string,
|
||||
onLanguageSelected: PropTypes.func,
|
||||
supportedLanguages: PropTypes.arrayOf(PropTypes.shape({
|
||||
@@ -91,5 +82,5 @@ SiteFooter.defaultProps = {
|
||||
supportedLanguages: [],
|
||||
};
|
||||
|
||||
export default injectIntl(SiteFooter);
|
||||
export default SiteFooter;
|
||||
export { EVENT_NAMES };
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
/* eslint-disable react/prop-types */
|
||||
import React, { useMemo } from 'react';
|
||||
import renderer from 'react-test-renderer';
|
||||
import { render, fireEvent, screen } from '@testing-library/react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { IntlProvider } from '@edx/frontend-platform/i18n';
|
||||
import { AppContext } from '@edx/frontend-platform/react';
|
||||
|
||||
import Footer from './Footer';
|
||||
import FooterSlot from '../plugin-slots/FooterSlot';
|
||||
import StudioFooterHelpSectionSlot from '../plugin-slots/StudioFooterHelpSectionSlot';
|
||||
|
||||
const FooterWithContext = ({ locale = 'es' }) => {
|
||||
const contextValue = useMemo(() => ({
|
||||
@@ -21,7 +24,7 @@ const FooterWithContext = ({ locale = 'es' }) => {
|
||||
<AppContext.Provider
|
||||
value={contextValue}
|
||||
>
|
||||
<Footer />
|
||||
<FooterSlot />
|
||||
</AppContext.Provider>
|
||||
</IntlProvider>
|
||||
);
|
||||
@@ -76,21 +79,44 @@ describe('<Footer />', () => {
|
||||
});
|
||||
|
||||
describe('handles language switching', () => {
|
||||
it('calls onLanguageSelected prop when a language is changed', () => {
|
||||
it('calls onLanguageSelected prop when a language is changed', async () => {
|
||||
const user = userEvent.setup();
|
||||
const mockHandleLanguageSelected = jest.fn();
|
||||
render(<FooterWithLanguageSelector languageSelected={mockHandleLanguageSelected} />);
|
||||
|
||||
fireEvent.submit(screen.getByTestId('site-footer-submit-btn'), {
|
||||
target: {
|
||||
elements: {
|
||||
'site-footer-language-select': {
|
||||
value: 'es',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
await user.selectOptions(screen.getByRole('combobox'), 'es');
|
||||
await user.click(screen.getByTestId('site-footer-submit-btn'));
|
||||
|
||||
expect(mockHandleLanguageSelected).toHaveBeenCalledWith('es');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('<StudioFooterHelpSectionSlot />', () => {
|
||||
const SectionWithContext = ({ locale = 'es' }) => {
|
||||
const contextValue = useMemo(() => ({
|
||||
authenticatedUser: null,
|
||||
config: {
|
||||
LOGO_TRADEMARK_URL: process.env.LOGO_TRADEMARK_URL,
|
||||
LMS_BASE_URL: process.env.LMS_BASE_URL,
|
||||
},
|
||||
}), []);
|
||||
|
||||
return (
|
||||
<IntlProvider locale={locale}>
|
||||
<AppContext.Provider
|
||||
value={contextValue}
|
||||
>
|
||||
<StudioFooterHelpSectionSlot />
|
||||
</AppContext.Provider>
|
||||
</IntlProvider>
|
||||
);
|
||||
};
|
||||
|
||||
it('renders correctly', () => {
|
||||
const tree = renderer
|
||||
.create(<SectionWithContext />)
|
||||
.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { injectIntl, intlShape, FormattedMessage } from '@edx/frontend-platform/i18n';
|
||||
import { useIntl, FormattedMessage } from '@edx/frontend-platform/i18n';
|
||||
|
||||
const LanguageSelector = ({
|
||||
intl, options, onSubmit, ...props
|
||||
options, onSubmit, ...props
|
||||
}) => {
|
||||
const intl = useIntl();
|
||||
const handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
const languageCode = e.target.elements['site-footer-language-select'].value;
|
||||
@@ -47,7 +48,6 @@ const LanguageSelector = ({
|
||||
};
|
||||
|
||||
LanguageSelector.propTypes = {
|
||||
intl: intlShape.isRequired,
|
||||
onSubmit: PropTypes.func.isRequired,
|
||||
options: PropTypes.arrayOf(PropTypes.shape({
|
||||
value: PropTypes.string,
|
||||
@@ -55,4 +55,4 @@ LanguageSelector.propTypes = {
|
||||
})).isRequired,
|
||||
};
|
||||
|
||||
export default injectIntl(LanguageSelector);
|
||||
export default LanguageSelector;
|
||||
|
||||
@@ -12,6 +12,7 @@ exports[`<Footer /> renders correctly renders with a language selector 1`] = `
|
||||
aria-label="edX Home"
|
||||
className="d-block"
|
||||
href="http://localhost:18000"
|
||||
onClick={[Function]}
|
||||
>
|
||||
<img
|
||||
alt="Powered by Open edX"
|
||||
@@ -81,6 +82,7 @@ exports[`<Footer /> renders correctly renders without a language selector 1`] =
|
||||
aria-label="edX Home"
|
||||
className="d-block"
|
||||
href="http://localhost:18000"
|
||||
onClick={[Function]}
|
||||
>
|
||||
<img
|
||||
alt="Powered by Open edX"
|
||||
@@ -111,6 +113,7 @@ exports[`<Footer /> renders correctly renders without a language selector in es
|
||||
aria-label="edX Home"
|
||||
className="d-block"
|
||||
href="http://localhost:18000"
|
||||
onClick={[Function]}
|
||||
>
|
||||
<img
|
||||
alt="Powered by Open edX"
|
||||
@@ -128,3 +131,68 @@ exports[`<Footer /> renders correctly renders without a language selector in es
|
||||
</div>
|
||||
</footer>
|
||||
`;
|
||||
|
||||
exports[`<StudioFooterHelpSectionSlot /> renders correctly 1`] = `
|
||||
[
|
||||
<div
|
||||
className="m-0 mt-6 row align-items-center justify-content-center"
|
||||
>
|
||||
<div
|
||||
className="col border-top mr-2"
|
||||
/>
|
||||
<button
|
||||
className="btn btn-outline-primary btn-sm"
|
||||
data-testid="helpToggleButton"
|
||||
disabled={false}
|
||||
onClick={[Function]}
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
className="pgn__icon pgn__icon__sm btn-icon-before"
|
||||
>
|
||||
<svg
|
||||
aria-hidden={true}
|
||||
fill="none"
|
||||
focusable={false}
|
||||
height={24}
|
||||
role="img"
|
||||
viewBox="0 0 24 24"
|
||||
width={24}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm1 17h-2v-2h2v2Zm2.07-7.75-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
Looking for help with Studio?
|
||||
<span
|
||||
className="pgn__icon pgn__icon__sm btn-icon-after"
|
||||
>
|
||||
<svg
|
||||
aria-hidden={true}
|
||||
fill="none"
|
||||
focusable={false}
|
||||
height={24}
|
||||
role="img"
|
||||
viewBox="0 0 24 24"
|
||||
width={24}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6-1.41-1.41Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
<div
|
||||
className="col border-top ml-2"
|
||||
/>
|
||||
</div>,
|
||||
<div
|
||||
className="px-4 container-mw-xl container-fluid"
|
||||
/>,
|
||||
]
|
||||
`;
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import React, { useContext, useState } from 'react';
|
||||
import _ from 'lodash';
|
||||
import { intlShape, injectIntl, FormattedMessage } from '@edx/frontend-platform/i18n';
|
||||
import React, { useContext } from 'react';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import { useIntl, FormattedMessage } from '@edx/frontend-platform/i18n';
|
||||
import { ensureConfig } from '@edx/frontend-platform';
|
||||
import { AppContext } from '@edx/frontend-platform/react';
|
||||
import {
|
||||
ActionRow,
|
||||
Button,
|
||||
Container,
|
||||
Hyperlink,
|
||||
Image,
|
||||
TransitionReplace,
|
||||
} from '@openedx/paragon';
|
||||
import { ExpandLess, ExpandMore, Help } from '@openedx/paragon/icons';
|
||||
import classNames from 'classnames';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import messages from './messages';
|
||||
import StudioFooterLogoSlot from '../../plugin-slots/StudioFooterLogoSlot';
|
||||
import StudioFooterHelpSectionSlot from '../../plugin-slots/StudioFooterHelpSectionSlot';
|
||||
|
||||
ensureConfig([
|
||||
'LMS_BASE_URL',
|
||||
@@ -26,81 +27,29 @@ ensureConfig([
|
||||
], 'Studio Footer component');
|
||||
|
||||
const StudioFooter = ({
|
||||
// injected
|
||||
intl,
|
||||
containerProps,
|
||||
}) => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const intl = useIntl();
|
||||
const { config } = useContext(AppContext);
|
||||
|
||||
const { containerClassName, ...restContainerProps } = containerProps || {};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="m-0 mt-6 row align-items-center justify-content-center">
|
||||
<div className="col border-top mr-2" />
|
||||
<Button
|
||||
data-testid="helpToggleButton"
|
||||
variant="outline-primary"
|
||||
onClick={() => setIsOpen(!isOpen)}
|
||||
iconBefore={Help}
|
||||
iconAfter={isOpen ? ExpandLess : ExpandMore}
|
||||
size="sm"
|
||||
>
|
||||
{isOpen ? intl.formatMessage(messages.closeHelpButtonLabel)
|
||||
: intl.formatMessage(messages.openHelpButtonLabel)}
|
||||
</Button>
|
||||
<div className="col border-top ml-2" />
|
||||
</div>
|
||||
<Container size="xl" className="px-4">
|
||||
<TransitionReplace>
|
||||
{isOpen ? (
|
||||
<ActionRow key="help-link-button-row" className="py-4" data-testid="helpButtonRow">
|
||||
<ActionRow.Spacer />
|
||||
<Button as="a" href="https://docs.edx.org/" size="sm">
|
||||
<FormattedMessage {...messages.edxDocumentationButtonLabel} />
|
||||
</Button>
|
||||
<Button
|
||||
as="a"
|
||||
href="https://open.edx.org/"
|
||||
size="sm"
|
||||
data-testid="openEdXPortalButton"
|
||||
>
|
||||
<FormattedMessage {...messages.openEdxPortalButtonLabel} />
|
||||
</Button>
|
||||
<Button
|
||||
as="a"
|
||||
href="https://www.edx.org/course/edx101-overview-of-creating-an-edx-course#.VO4eaLPF-n1"
|
||||
size="sm"
|
||||
>
|
||||
<FormattedMessage {...messages.edx101ButtonLabel} />
|
||||
</Button>
|
||||
<Button
|
||||
as="a"
|
||||
href="https://www.edx.org/course/studiox-creating-a-course-with-edx-studio"
|
||||
size="sm"
|
||||
>
|
||||
<FormattedMessage {...messages.studioXButtonLabel} />
|
||||
</Button>
|
||||
{!_.isEmpty(config.SUPPORT_EMAIL) && (
|
||||
<Button
|
||||
as="a"
|
||||
href={`mailto:${config.SUPPORT_EMAIL}`}
|
||||
size="sm"
|
||||
data-testid="contactUsButton"
|
||||
>
|
||||
<FormattedMessage {...messages.contactUsButtonLabel} />
|
||||
</Button>
|
||||
)}
|
||||
<ActionRow.Spacer />
|
||||
</ActionRow>
|
||||
) : null}
|
||||
</TransitionReplace>
|
||||
<StudioFooterHelpSectionSlot containerProps={containerProps} />
|
||||
<Container
|
||||
size="xl"
|
||||
className={classNames('px-4', containerClassName)}
|
||||
{...restContainerProps}
|
||||
>
|
||||
<ActionRow className="pt-3 m-0 x-small">
|
||||
© {new Date().getFullYear()} <Hyperlink destination={config.MARKETING_SITE_BASE_URL} target="_blank" className="ml-2">{config.SITE_NAME}</Hyperlink>
|
||||
<ActionRow.Spacer />
|
||||
{!_.isEmpty(config.TERMS_OF_SERVICE_URL) && (
|
||||
{!isEmpty(config.TERMS_OF_SERVICE_URL) && (
|
||||
<Hyperlink destination={config.TERMS_OF_SERVICE_URL} data-testid="termsOfService">
|
||||
{intl.formatMessage(messages.termsOfServiceLinkLabel)}
|
||||
</Hyperlink>
|
||||
)}{!_.isEmpty(config.PRIVACY_POLICY_URL) && (
|
||||
)}{!isEmpty(config.PRIVACY_POLICY_URL) && (
|
||||
<Hyperlink destination={config.PRIVACY_POLICY_URL} data-testid="privacyPolicy">
|
||||
{intl.formatMessage(messages.privacyPolicyLinkLabel)}
|
||||
</Hyperlink>
|
||||
@@ -125,13 +74,7 @@ const StudioFooter = ({
|
||||
<FormattedMessage {...messages.trademarkMessage} />
|
||||
<Hyperlink className="ml-1" destination="https://www.edx.org">edX Inc</Hyperlink>.
|
||||
<ActionRow.Spacer />
|
||||
<Hyperlink destination="https://open.edx.org" className="float-right">
|
||||
<Image
|
||||
width="120px"
|
||||
alt="Powered by Open edX"
|
||||
src="https://logos.openedx.org/open-edx-logo-tag.png"
|
||||
/>
|
||||
</Hyperlink>
|
||||
<StudioFooterLogoSlot />
|
||||
</ActionRow>
|
||||
</Container>
|
||||
</>
|
||||
@@ -139,8 +82,11 @@ const StudioFooter = ({
|
||||
};
|
||||
|
||||
StudioFooter.propTypes = {
|
||||
// injected
|
||||
intl: intlShape.isRequired,
|
||||
containerProps: PropTypes.shape(Container.propTypes),
|
||||
};
|
||||
|
||||
export default injectIntl(StudioFooter);
|
||||
StudioFooter.defaultProps = {
|
||||
containerProps: {},
|
||||
};
|
||||
|
||||
export default StudioFooter;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
/* eslint-disable react/prop-types */
|
||||
import React, { useMemo } from 'react';
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import '@testing-library/jest-dom/extend-expect';
|
||||
import '@testing-library/jest-dom';
|
||||
import { IntlProvider } from '@edx/frontend-platform/i18n';
|
||||
import { AppContext } from '@edx/frontend-platform/react';
|
||||
import StudioFooter from './StudioFooter';
|
||||
import StudioFooterSlot from '../../plugin-slots/StudioFooterSlot';
|
||||
import messages from './messages';
|
||||
|
||||
const config = {
|
||||
@@ -35,7 +37,7 @@ const Component = ({ updateVariable }) => {
|
||||
return (
|
||||
<IntlProvider locale="en">
|
||||
<AppContext.Provider value={contextValue}>
|
||||
<StudioFooter />
|
||||
<StudioFooterSlot />
|
||||
</AppContext.Provider>
|
||||
</IntlProvider>
|
||||
);
|
||||
@@ -56,35 +58,40 @@ describe('Footer', () => {
|
||||
});
|
||||
});
|
||||
describe('help section expanded view', () => {
|
||||
it('help button should read Hide Studio help', () => {
|
||||
it('help button should read Hide Studio help', async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<Component />);
|
||||
const helpToggleButton = screen.getByText(messages.openHelpButtonLabel.defaultMessage);
|
||||
fireEvent.click(helpToggleButton);
|
||||
await user.click(helpToggleButton);
|
||||
expect(screen.getByText(messages.closeHelpButtonLabel.defaultMessage))
|
||||
.toBeVisible();
|
||||
});
|
||||
it('help button link row should be visible', () => {
|
||||
it('help button link row should be visible', async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<Component />);
|
||||
const helpToggleButton = screen.getByText(messages.openHelpButtonLabel.defaultMessage);
|
||||
fireEvent.click(helpToggleButton);
|
||||
await user.click(helpToggleButton);
|
||||
expect(screen.getByTestId('helpButtonRow')).toBeVisible();
|
||||
});
|
||||
it('Open edX portal button should be visible', () => {
|
||||
it('Open edX portal button should be visible', async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<Component />);
|
||||
const helpToggleButton = screen.getByText(messages.openHelpButtonLabel.defaultMessage);
|
||||
fireEvent.click(helpToggleButton);
|
||||
expect(screen.getByTestId('openEdXPortalButton')).toBeVisible();
|
||||
await user.click(helpToggleButton);
|
||||
expect(screen.getByTestId('openEdXDemoCourseButton')).toBeVisible();
|
||||
});
|
||||
it('should not show contact us button', () => {
|
||||
it('should not show contact us button', async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<Component />);
|
||||
const helpToggleButton = screen.getByText(messages.openHelpButtonLabel.defaultMessage);
|
||||
fireEvent.click(helpToggleButton);
|
||||
await user.click(helpToggleButton);
|
||||
expect(screen.queryByTestId('contactUsButton')).toBeNull();
|
||||
});
|
||||
it('should show contact us button', () => {
|
||||
it('should show contact us button', async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<Component updateVariable={['SUPPORT_EMAIL', 'support@email.com']} />);
|
||||
const helpToggleButton = screen.getByText(messages.openHelpButtonLabel.defaultMessage);
|
||||
fireEvent.click(helpToggleButton);
|
||||
await user.click(helpToggleButton);
|
||||
expect(screen.getByTestId('contactUsButton')).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
32
src/components/studio-footer/help-components/HelpButton.jsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import React from 'react';
|
||||
import { useIntl } from '@edx/frontend-platform/i18n';
|
||||
import {
|
||||
Button,
|
||||
} from '@openedx/paragon';
|
||||
import { ExpandLess, ExpandMore, Help } from '@openedx/paragon/icons';
|
||||
import PropTypes from 'prop-types';
|
||||
import messages from '../messages';
|
||||
|
||||
const HelpButton = ({ isOpen, setIsOpen }) => {
|
||||
const intl = useIntl();
|
||||
return (
|
||||
<Button
|
||||
data-testid="helpToggleButton"
|
||||
variant="outline-primary"
|
||||
onClick={() => setIsOpen(!isOpen)}
|
||||
iconBefore={Help}
|
||||
iconAfter={isOpen ? ExpandLess : ExpandMore}
|
||||
size="sm"
|
||||
>
|
||||
{isOpen ? intl.formatMessage(messages.closeHelpButtonLabel)
|
||||
: intl.formatMessage(messages.openHelpButtonLabel)}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
HelpButton.propTypes = {
|
||||
setIsOpen: PropTypes.func.isRequired,
|
||||
isOpen: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
export default HelpButton;
|
||||
@@ -0,0 +1,55 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { IntlProvider } from '@edx/frontend-platform/i18n';
|
||||
import { AppContext } from '@edx/frontend-platform/react';
|
||||
import HelpButton from './HelpButton';
|
||||
import '@testing-library/jest-dom';
|
||||
|
||||
// eslint-disable-next-line react/prop-types
|
||||
const ButtonWithContext = ({ locale = 'en', isOpen, setIsOpen }) => {
|
||||
const contextValue = useMemo(() => ({
|
||||
authenticatedUser: null,
|
||||
config: { },
|
||||
}), []);
|
||||
|
||||
return (
|
||||
<IntlProvider locale={locale}>
|
||||
<AppContext.Provider
|
||||
value={contextValue}
|
||||
>
|
||||
<HelpButton isOpen={isOpen} setIsOpen={setIsOpen} />
|
||||
</AppContext.Provider>
|
||||
</IntlProvider>
|
||||
);
|
||||
};
|
||||
|
||||
describe('HelpButton', () => {
|
||||
const mockSetIsOpen = jest.fn();
|
||||
|
||||
beforeEach(() => {
|
||||
mockSetIsOpen.mockClear();
|
||||
});
|
||||
|
||||
it('renders with "open" label when isOpen is false', () => {
|
||||
render(<ButtonWithContext isOpen={false} setIsOpen={mockSetIsOpen} />);
|
||||
expect(screen.getByTestId('helpToggleButton')).toBeInTheDocument();
|
||||
expect(screen.getByRole('button')).toHaveTextContent(/help|open/i);
|
||||
});
|
||||
|
||||
it('renders with "close" label when isOpen is true', () => {
|
||||
render(<ButtonWithContext isOpen setIsOpen={mockSetIsOpen} />);
|
||||
expect(screen.getByTestId('helpToggleButton')).toBeInTheDocument();
|
||||
expect(screen.getByRole('button')).toHaveTextContent(/close|help/i);
|
||||
});
|
||||
|
||||
it('calls setIsOpen with the toggled value when clicked', async () => {
|
||||
const user = userEvent.setup();
|
||||
const { rerender } = render(<ButtonWithContext isOpen={false} setIsOpen={mockSetIsOpen} />);
|
||||
await user.click(screen.getByTestId('helpToggleButton'));
|
||||
expect(mockSetIsOpen).toHaveBeenCalledWith(true);
|
||||
rerender(<ButtonWithContext isOpen setIsOpen={mockSetIsOpen} />);
|
||||
await user.click(screen.getByTestId('helpToggleButton'));
|
||||
expect(mockSetIsOpen).toHaveBeenCalledWith(false);
|
||||
});
|
||||
});
|
||||
62
src/components/studio-footer/help-components/HelpContent.jsx
Normal file
@@ -0,0 +1,62 @@
|
||||
import React, { useContext } from 'react';
|
||||
import { AppContext } from '@edx/frontend-platform/react';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import { ensureConfig } from '@edx/frontend-platform';
|
||||
import { FormattedMessage } from '@edx/frontend-platform/i18n';
|
||||
import {
|
||||
ActionRow,
|
||||
Button,
|
||||
} from '@openedx/paragon';
|
||||
import messages from '../messages';
|
||||
|
||||
ensureConfig([
|
||||
'SUPPORT_EMAIL',
|
||||
], 'Studio Footer Help Content component');
|
||||
|
||||
const BUTTONS = [
|
||||
{
|
||||
as: 'a',
|
||||
href: 'https://docs.openedx.org/en/latest/educators/quickstarts/build_a_course.html',
|
||||
size: 'sm',
|
||||
message: messages.educatorsDocsButtonLabel,
|
||||
dataTestid: null,
|
||||
},
|
||||
{
|
||||
as: 'a',
|
||||
href: 'https://training.openedx.io/courses/course-v1:OpenedX+DemoX+Demo_Course/about',
|
||||
size: 'sm',
|
||||
message: messages.openEdxDemoCourseButtonLabel,
|
||||
dataTestid: 'openEdXDemoCourseButton',
|
||||
},
|
||||
];
|
||||
|
||||
const HelpContent = () => {
|
||||
const { config } = useContext(AppContext);
|
||||
return (
|
||||
<ActionRow key="help-link-button-row" className="py-4" data-testid="helpButtonRow">
|
||||
<ActionRow.Spacer />
|
||||
|
||||
{BUTTONS.map(({
|
||||
as, href, size, message, dataTestid,
|
||||
}) => (
|
||||
<Button as={as} href={href} size={size} key={message.id} data-testid={dataTestid}>
|
||||
<FormattedMessage {...message} />
|
||||
</Button>
|
||||
))}
|
||||
|
||||
{!isEmpty(config.SUPPORT_EMAIL) && (
|
||||
<Button
|
||||
as="a"
|
||||
href={`mailto:${config.SUPPORT_EMAIL}`}
|
||||
size="sm"
|
||||
data-testid="contactUsButton"
|
||||
>
|
||||
<FormattedMessage {...messages.contactUsButtonLabel} />
|
||||
</Button>
|
||||
)}
|
||||
<ActionRow.Spacer />
|
||||
</ActionRow>
|
||||
);
|
||||
};
|
||||
|
||||
export default HelpContent;
|
||||
@@ -0,0 +1,44 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { IntlProvider } from '@edx/frontend-platform/i18n';
|
||||
import { AppContext } from '@edx/frontend-platform/react';
|
||||
import HelpContent from './HelpContent';
|
||||
import '@testing-library/jest-dom';
|
||||
import messages from '../messages';
|
||||
|
||||
// eslint-disable-next-line react/prop-types
|
||||
const ContentWithContext = ({ locale = 'en', config = {} }) => {
|
||||
const contextValue = useMemo(() => ({
|
||||
authenticatedUser: null,
|
||||
config,
|
||||
}), [config]);
|
||||
|
||||
return (
|
||||
<IntlProvider locale={locale}>
|
||||
<AppContext.Provider
|
||||
value={contextValue}
|
||||
>
|
||||
<HelpContent />
|
||||
</AppContext.Provider>
|
||||
</IntlProvider>
|
||||
);
|
||||
};
|
||||
|
||||
describe('HelpContent', () => {
|
||||
it('renders all help buttons', () => {
|
||||
const config = { SUPPORT_EMAIL: 'support@example.com' };
|
||||
render(<ContentWithContext config={config} />);
|
||||
expect(screen.getByText(messages.educatorsDocsButtonLabel.defaultMessage)).toBeInTheDocument();
|
||||
expect(screen.getByText(messages.openEdxDemoCourseButtonLabel.defaultMessage)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not render contact button if SUPPORT_EMAIL is empty', () => {
|
||||
render(<ContentWithContext config={{ SUPPORT_EMAIL: null }} />);
|
||||
expect(screen.queryByTestId('contactUsButton')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders ActionRow with correct test id', () => {
|
||||
render(<ContentWithContext />);
|
||||
expect(screen.getByTestId('helpButtonRow')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
43
src/components/studio-footer/help-components/HelpSection.jsx
Normal file
@@ -0,0 +1,43 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
Container,
|
||||
TransitionReplace,
|
||||
} from '@openedx/paragon';
|
||||
import classNames from 'classnames';
|
||||
import PropTypes from 'prop-types';
|
||||
import StudioFooterHelpButtonSlot from '../../../plugin-slots/StudioFooterHelpButtonSlot';
|
||||
import StudioFooterHelpContentlot from '../../../plugin-slots/StudioFooterHelpContentSlot';
|
||||
|
||||
const HelpSection = ({ containerProps }) => {
|
||||
const [isOpen, setIsOpen] = React.useState(false);
|
||||
const { containerClassName, ...restContainerProps } = containerProps || {};
|
||||
return (
|
||||
<>
|
||||
<div className="m-0 mt-6 row align-items-center justify-content-center">
|
||||
<div className="col border-top mr-2" />
|
||||
<StudioFooterHelpButtonSlot
|
||||
setIsOpen={setIsOpen}
|
||||
isOpen={isOpen}
|
||||
/>
|
||||
<div className="col border-top ml-2" />
|
||||
</div>
|
||||
<Container
|
||||
size="xl"
|
||||
className={classNames('px-4', containerClassName)}
|
||||
{...restContainerProps}
|
||||
>
|
||||
{isOpen && <TransitionReplace><StudioFooterHelpContentlot /></TransitionReplace> }
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
HelpSection.propTypes = {
|
||||
containerProps: PropTypes.shape(Container.propTypes),
|
||||
};
|
||||
|
||||
HelpSection.defaultProps = {
|
||||
containerProps: {},
|
||||
};
|
||||
|
||||
export default HelpSection;
|
||||
@@ -0,0 +1,52 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import { IntlProvider } from '@edx/frontend-platform/i18n';
|
||||
import { AppContext } from '@edx/frontend-platform/react';
|
||||
import HelpSection from './HelpSection';
|
||||
import '@testing-library/jest-dom';
|
||||
|
||||
// eslint-disable-next-line react/prop-types
|
||||
const HelpSectionWithContext = ({ locale = 'en', config = {}, containerProps = null }) => {
|
||||
const contextValue = useMemo(() => ({
|
||||
authenticatedUser: null,
|
||||
config,
|
||||
}), [config]);
|
||||
|
||||
return (
|
||||
<IntlProvider locale={locale}>
|
||||
<AppContext.Provider
|
||||
value={contextValue}
|
||||
>
|
||||
<HelpSection containerProps={containerProps} />
|
||||
</AppContext.Provider>
|
||||
</IntlProvider>
|
||||
);
|
||||
};
|
||||
|
||||
describe('HelpSection', () => {
|
||||
it('renders the HelpButton', () => {
|
||||
render(<HelpSectionWithContext />);
|
||||
expect(screen.getByTestId('helpToggleButton')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not show HelpContent by default', () => {
|
||||
render(<HelpSectionWithContext />);
|
||||
expect(screen.queryByTestId('helpButtonRow')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows HelpContent when HelpButton is clicked', () => {
|
||||
render(<HelpSectionWithContext />);
|
||||
const button = screen.getByTestId('helpToggleButton');
|
||||
fireEvent.click(button);
|
||||
expect(screen.getByTestId('helpButtonRow')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('hides HelpContent when HelpButton is clicked twice', () => {
|
||||
render(<HelpSectionWithContext containerProps={{ containerClassName: 'container', size: 'xl' }} />);
|
||||
const button = screen.getByTestId('helpToggleButton');
|
||||
fireEvent.click(button);
|
||||
expect(screen.queryByTestId('helpButtonRow')).toBeInTheDocument();
|
||||
fireEvent.click(button);
|
||||
expect(screen.queryByTestId('helpButtonRow')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -11,25 +11,15 @@ const messages = defineMessages({
|
||||
defaultMessage: 'Hide Studio help',
|
||||
description: 'Label for button that closes the collapsed section with help buttons',
|
||||
},
|
||||
edxDocumentationButtonLabel: {
|
||||
id: 'authoring.footer.help.edxDocumentation.button.label',
|
||||
defaultMessage: 'edX documentation',
|
||||
description: 'Label for button that links to the edX documentation site',
|
||||
educatorsDocsButtonLabel: {
|
||||
id: 'authoring.footer.help.educatorsDocs.button.label',
|
||||
defaultMessage: 'Open edX Educators Docs',
|
||||
description: 'Label for button that links to the build a course quickstart site',
|
||||
},
|
||||
openEdxPortalButtonLabel: {
|
||||
id: 'authoring.footer.help.openEdxPortal.button.label',
|
||||
defaultMessage: 'Open edX portal',
|
||||
description: 'Label for button that links to the Open edX portal',
|
||||
},
|
||||
edx101ButtonLabel: {
|
||||
id: 'authoring.footer.help.edx101.button.label',
|
||||
defaultMessage: 'Enroll in edX 101',
|
||||
description: 'Label for button that links to the edX 101 course',
|
||||
},
|
||||
studioXButtonLabel: {
|
||||
id: 'authoring.footer.help.studioX.button.label',
|
||||
defaultMessage: 'Enroll in StudioX',
|
||||
description: 'Label for button that links to the edX StudioX course',
|
||||
openEdxDemoCourseButtonLabel: {
|
||||
id: 'authoring.footer.help.openEdxDemoCourse.button.label',
|
||||
defaultMessage: 'Open edX Demo Course',
|
||||
description: 'Label for button that links to the open edX demo course portal',
|
||||
},
|
||||
contactUsButtonLabel: {
|
||||
id: 'authoring.footer.help.contactUs.button.label',
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import Footer, { EVENT_NAMES } from './components/Footer';
|
||||
import messages from './i18n/index';
|
||||
import StudioFooter from './components/studio-footer';
|
||||
import FooterSlot from './plugin-slots/FooterSlot';
|
||||
import StudioFooterSlot from './plugin-slots/StudioFooterSlot';
|
||||
|
||||
export default Footer;
|
||||
export {
|
||||
messages, EVENT_NAMES, StudioFooter,
|
||||
messages, EVENT_NAMES, StudioFooter, FooterSlot, StudioFooterSlot,
|
||||
};
|
||||
|
||||
51
src/plugin-slots/FooterSlot/README.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# FooterSlot
|
||||
|
||||
### Slot ID: `org.openedx.frontend.layout.footer.v1`
|
||||
|
||||
### Slot ID Aliases
|
||||
* `footer_slot`
|
||||
|
||||
## Description
|
||||
|
||||
This slot is used to repace/modify/hide the entire footer.
|
||||
|
||||
## Example
|
||||
|
||||
The following `env.config.jsx` will replace the default footer.
|
||||
|
||||

|
||||
|
||||
with a simple custom footer
|
||||
|
||||

|
||||
|
||||
```jsx
|
||||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
|
||||
|
||||
const config = {
|
||||
pluginSlots: {
|
||||
'org.openedx.frontend.layout.footer.v1': {
|
||||
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;
|
||||
```
|
||||
BIN
src/plugin-slots/FooterSlot/images/custom_footer.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
src/plugin-slots/FooterSlot/images/default_footer.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
14
src/plugin-slots/FooterSlot/index.jsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import React from 'react';
|
||||
import { PluginSlot } from '@openedx/frontend-plugin-framework';
|
||||
import Footer from '../../components/Footer';
|
||||
|
||||
const FooterSlot = () => (
|
||||
<PluginSlot
|
||||
id="org.openedx.frontend.layout.footer.v1"
|
||||
idAliases={['footer_slot', 'footer_plugin_slot']}
|
||||
>
|
||||
<Footer />
|
||||
</PluginSlot>
|
||||
);
|
||||
|
||||
export default FooterSlot;
|
||||
5
src/plugin-slots/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# `frontend-component-footer` Plugin Slots
|
||||
|
||||
* [`org.openedx.frontend.layout.footer.v1`](./FooterSlot/)
|
||||
* [`org.openedx.frontend.layout.studio_footer.v1`](./StudioFooterSlot/)
|
||||
* [`org.openedx.frontend.layout.studio_footer_logo.v1`](./StudioFooterLogoSlot/)
|
||||
47
src/plugin-slots/StudioFooterHelpButtonSlot/README.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# StudioFooterLogoSlot
|
||||
|
||||
### Slot ID: `org.openedx.frontend.layout.studio_footer_help_button.v1`
|
||||
|
||||
## Description
|
||||
|
||||
This slot is used to repace/modify/hide the help button to the studio footer.
|
||||
|
||||
## Examples
|
||||
|
||||
### Add your custom button.
|
||||
|
||||
The following `env.config.jsx` will add a custom help button to the studio footer.
|
||||
|
||||

|
||||
|
||||
```jsx
|
||||
import { PLUGIN_OPERATIONS, DIRECT_PLUGIN } from '@openedx/frontend-plugin-framework';
|
||||
import {
|
||||
Button,
|
||||
} from '@openedx/paragon';
|
||||
|
||||
const config = {
|
||||
pluginSlots: {
|
||||
'org.openedx.frontend.layout.studio_footer_help_button.v1': {
|
||||
keepDefault: false,
|
||||
plugins: [
|
||||
{
|
||||
op: PLUGIN_OPERATIONS.Insert,
|
||||
widget: {
|
||||
id: 'studio_footer_helpbutton_addition',
|
||||
type: DIRECT_PLUGIN,
|
||||
priority: 40,
|
||||
RenderWidget: ({isOpen, setIsOpen}) => {
|
||||
return (
|
||||
<Button className="button button1" onClick={() => setIsOpen(!isOpen)}>Custom Help Button</Button>
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
```
|
||||
|
After Width: | Height: | Size: 148 KiB |
17
src/plugin-slots/StudioFooterHelpButtonSlot/index.jsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import React from 'react';
|
||||
import { PluginSlot } from '@openedx/frontend-plugin-framework';
|
||||
import PropTypes from 'prop-types';
|
||||
import HelpButton from '../../components/studio-footer/help-components/HelpButton';
|
||||
|
||||
const StudioFooterHelpButtonSlot = ({ isOpen, setIsOpen }) => (
|
||||
<PluginSlot id="org.openedx.frontend.layout.studio_footer_help_button.v1" pluginProps={{ isOpen, setIsOpen }}>
|
||||
<HelpButton isOpen={isOpen} setIsOpen={setIsOpen} />
|
||||
</PluginSlot>
|
||||
);
|
||||
|
||||
StudioFooterHelpButtonSlot.propTypes = {
|
||||
setIsOpen: PropTypes.func.isRequired,
|
||||
isOpen: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
export default StudioFooterHelpButtonSlot;
|
||||
50
src/plugin-slots/StudioFooterHelpContentSlot/README.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# StudioFooterLogoSlot
|
||||
|
||||
### Slot ID: `org.openedx.frontend.layout.studio_footer_help-content.v1`
|
||||
|
||||
## Description
|
||||
|
||||
This slot is used to repace/modify/hide the help content to the studio footer.
|
||||
|
||||
## Examples
|
||||
|
||||
### Add a custom help content.
|
||||
|
||||
The following `env.config.jsx` will add a custom help content to the studio footer.
|
||||
|
||||

|
||||
|
||||
```jsx
|
||||
import { PLUGIN_OPERATIONS, DIRECT_PLUGIN } from '@openedx/frontend-plugin-framework';
|
||||
import {
|
||||
Hyperlink,
|
||||
} from '@openedx/paragon';
|
||||
|
||||
const config = {
|
||||
pluginSlots: {
|
||||
'org.openedx.frontend.layout.studio_footer_help-content.v1': {
|
||||
keepDefault: false,
|
||||
plugins: [
|
||||
{
|
||||
op: PLUGIN_OPERATIONS.Insert,
|
||||
widget: {
|
||||
id: 'studio_footer_helpcontent_addition',
|
||||
type: DIRECT_PLUGIN,
|
||||
priority: 40,
|
||||
RenderWidget: () => {
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center', padding: '20px 5px' }}>
|
||||
<p>Custom Help content</p>
|
||||
<Hyperlink destination="https://example.com/">more help</Hyperlink>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
```
|
||||
|
After Width: | Height: | Size: 129 KiB |
13
src/plugin-slots/StudioFooterHelpContentSlot/index.jsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import React from 'react';
|
||||
import { PluginSlot } from '@openedx/frontend-plugin-framework';
|
||||
import HelpContent from '../../components/studio-footer/help-components/HelpContent';
|
||||
|
||||
const StudioFooterHelpContentSlot = () => (
|
||||
<PluginSlot
|
||||
id="org.openedx.frontend.layout.studio_footer_help-content.v1"
|
||||
>
|
||||
<HelpContent />
|
||||
</PluginSlot>
|
||||
);
|
||||
|
||||
export default StudioFooterHelpContentSlot;
|
||||
53
src/plugin-slots/StudioFooterHelpSectionSlot/README.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# StudioFooterLogoSlot
|
||||
|
||||
### Slot ID: `org.openedx.frontend.layout.studio_footer_help_section.v1`
|
||||
|
||||
## Description
|
||||
|
||||
This slot is used to repace/modify/hide the help section to the studio footer.
|
||||
|
||||

|
||||
|
||||
## Examples
|
||||
|
||||
### Customize help section.
|
||||
|
||||
The following `env.config.jsx` will add a custom help section to the studio footer.
|
||||
|
||||
```jsx
|
||||
import { PLUGIN_OPERATIONS, DIRECT_PLUGIN } from '@openedx/frontend-plugin-framework';
|
||||
import {
|
||||
Hyperlink,
|
||||
Button,
|
||||
} from '@openedx/paragon';
|
||||
|
||||
const config = {
|
||||
pluginSlots: {
|
||||
'org.openedx.frontend.layout.studio_footer_help_section.v1': {
|
||||
keepDefault: false,
|
||||
plugins: [
|
||||
{
|
||||
op: PLUGIN_OPERATIONS.Insert,
|
||||
widget: {
|
||||
id: 'studio_footer_helpsection_addition',
|
||||
type: DIRECT_PLUGIN,
|
||||
priority: 40,
|
||||
RenderWidget: () => {
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center', padding: '20px 5px' }}>
|
||||
<p>Custom Help Section custizable as needed </p>
|
||||
<Button className="button button1">Go to home</Button>
|
||||
<Hyperlink destination="https://example.com/">About</Hyperlink>
|
||||
<Hyperlink destination="https://example.com/">Info</Hyperlink>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
```
|
||||
|
After Width: | Height: | Size: 142 KiB |
19
src/plugin-slots/StudioFooterHelpSectionSlot/index.jsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import React from 'react';
|
||||
import { PluginSlot } from '@openedx/frontend-plugin-framework';
|
||||
import PropTypes from 'prop-types';
|
||||
import {
|
||||
Container,
|
||||
} from '@openedx/paragon';
|
||||
import HelpSection from '../../components/studio-footer/help-components/HelpSection';
|
||||
|
||||
const StudioFooterHelpSectionSlot = ({ containerProps }) => (
|
||||
<PluginSlot id="org.openedx.frontend.layout.studio_footer_help_section.v1">
|
||||
<HelpSection containerProps={containerProps} />
|
||||
</PluginSlot>
|
||||
);
|
||||
|
||||
StudioFooterHelpSectionSlot.propTypes = {
|
||||
containerProps: PropTypes.shape(Container.propTypes),
|
||||
};
|
||||
|
||||
export default StudioFooterHelpSectionSlot;
|
||||
57
src/plugin-slots/StudioFooterLogoSlot/README.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# StudioFooterLogoSlot
|
||||
|
||||
### Slot ID: `org.openedx.frontend.layout.studio_footer_logo.v1`
|
||||
|
||||
### Slot ID Aliases
|
||||
* `studio_footer_logo_slot`
|
||||
|
||||
## Description
|
||||
|
||||
This slot is used to add your site logo to the studio footer.
|
||||
|
||||
## Examples
|
||||
|
||||
### Add your site logo.
|
||||
|
||||
The following `env.config.jsx` will add your site logo to the studio footer.
|
||||
|
||||

|
||||
|
||||
```jsx
|
||||
import { PLUGIN_OPERATIONS, DIRECT_PLUGIN } from '@openedx/frontend-plugin-framework';
|
||||
import {
|
||||
Hyperlink,
|
||||
Image,
|
||||
} from '@openedx/paragon';
|
||||
|
||||
const config = {
|
||||
pluginSlots: {
|
||||
'org.openedx.frontend.layout.studio_footer_logo.v1': {
|
||||
keepDefault: true,
|
||||
plugins: [
|
||||
{
|
||||
op: PLUGIN_OPERATIONS.Insert,
|
||||
widget: {
|
||||
id: 'studio_footer_logo_addition',
|
||||
type: DIRECT_PLUGIN,
|
||||
priority: 40,
|
||||
RenderWidget: () => {
|
||||
return (
|
||||
<Hyperlink destination="https://example.com/" className="float-right">
|
||||
<Image
|
||||
height="48px"
|
||||
alt="Hosted by MySite"
|
||||
src="https://logos.openedx.org/generic-logo.svg"
|
||||
/>
|
||||
</Hyperlink>
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
```
|
||||
|
After Width: | Height: | Size: 285 KiB |
17
src/plugin-slots/StudioFooterLogoSlot/index.jsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import React from 'react';
|
||||
import { PluginSlot } from '@openedx/frontend-plugin-framework';
|
||||
import { Hyperlink, Image } from '@openedx/paragon';
|
||||
|
||||
const StudioFooterLogoSlot = () => (
|
||||
<PluginSlot id="org.openedx.frontend.layout.studio_footer_logo.v1" idAliases={['studio_footer_logo_slot']}>
|
||||
<Hyperlink destination="https://openedx.org" className="float-right">
|
||||
<Image
|
||||
width="120px"
|
||||
alt="Powered by Open edX"
|
||||
src="https://logos.openedx.org/open-edx-logo-tag.png"
|
||||
/>
|
||||
</Hyperlink>
|
||||
</PluginSlot>
|
||||
);
|
||||
|
||||
export default StudioFooterLogoSlot;
|
||||
51
src/plugin-slots/StudioFooterSlot/README.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# StudioFooterSlot
|
||||
|
||||
### Slot ID: `org.openedx.frontend.layout.studio_footer.v1`
|
||||
|
||||
### Slot ID Aliases
|
||||
* `studio_footer_slot`
|
||||
|
||||
## Description
|
||||
|
||||
This slot is used to repace/modify/hide the entire studio footer.
|
||||
|
||||
## Example
|
||||
|
||||
The following `env.config.jsx` will replace the default studio footer.
|
||||
|
||||

|
||||
|
||||
with a simple custom footer
|
||||
|
||||

|
||||
|
||||
```jsx
|
||||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
|
||||
|
||||
const config = {
|
||||
pluginSlots: {
|
||||
'org.openedx.frontend.layout.studio_footer.v1': {
|
||||
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;
|
||||
```
|
||||
BIN
src/plugin-slots/StudioFooterSlot/images/custom_footer.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
|
After Width: | Height: | Size: 79 KiB |
11
src/plugin-slots/StudioFooterSlot/index.jsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
import { PluginSlot } from '@openedx/frontend-plugin-framework';
|
||||
import StudioFooter from '../../components/studio-footer';
|
||||
|
||||
const StudioFooterSlot = () => (
|
||||
<PluginSlot id="org.openedx.frontend.layout.studio_footer.v1" idAliases={['studio_footer_slot']}>
|
||||
<StudioFooter />
|
||||
</PluginSlot>
|
||||
);
|
||||
|
||||
export default StudioFooterSlot;
|
||||
@@ -2,7 +2,9 @@ const path = require('path');
|
||||
const { createConfig } = require('@openedx/frontend-build');
|
||||
|
||||
module.exports = createConfig('webpack-dev', {
|
||||
entry: path.resolve(__dirname, 'example'),
|
||||
entry: {
|
||||
app: path.resolve(__dirname, 'example'),
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'example/dist'),
|
||||
publicPath: '/',
|
||||
|
||||