Compare commits
92 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
181b9916a0 | ||
|
|
22dbec317c | ||
|
|
6f15e4dafa | ||
|
|
9f5aed3c76 | ||
|
|
54bc04b182 | ||
|
|
ea2578fa15 | ||
|
|
5f7fab236d | ||
|
|
adf5f6c9a8 | ||
|
|
132b080195 | ||
|
|
0d4ea96874 | ||
|
|
8b9f5fa348 | ||
|
|
c014e30ca8 | ||
|
|
0e6ab3c358 | ||
|
|
7d0a126580 | ||
|
|
c422ce40be | ||
|
|
7299d5367f | ||
|
|
38203b91ba | ||
|
|
83c340fe08 | ||
|
|
9eaebf4b11 | ||
|
|
2a883857cf | ||
|
|
5f26c1ae93 | ||
|
|
89ad7234ac | ||
|
|
936915f81f | ||
|
|
b993992987 | ||
|
|
64fc8adeed | ||
|
|
a49b06349e | ||
|
|
aa13b4946c | ||
|
|
cff78e021c | ||
|
|
62bf038a06 | ||
|
|
eed127969d | ||
|
|
dcce076942 | ||
|
|
6cf8bf3965 | ||
|
|
fad5b0925e | ||
|
|
1f5e5fa4dd | ||
|
|
a94f57dae2 | ||
|
|
531ae4a603 | ||
|
|
2a2f9ed43f | ||
|
|
5c0ac3de54 | ||
|
|
4aec12eae0 | ||
|
|
5059e0dac1 | ||
|
|
ed5aeb8179 | ||
|
|
19fe6680a9 | ||
|
|
59c78ac479 | ||
|
|
238854bdfb | ||
|
|
07ad578613 | ||
|
|
fc3c9581f3 | ||
|
|
0015b72eb7 | ||
|
|
f694e322ee | ||
|
|
5e7ac40348 | ||
|
|
c2e5f0f403 | ||
|
|
d0b9a40f5d | ||
|
|
3f815b386f | ||
|
|
e9bb918925 | ||
|
|
9b1a3e994a | ||
|
|
7253f9de2b | ||
|
|
3e6ccb2ea1 | ||
|
|
7c3c925838 | ||
|
|
cde76129af | ||
|
|
29050d109f | ||
|
|
5caf0ea549 | ||
|
|
3571e5c3ed | ||
|
|
1011854f51 | ||
|
|
a5859702b5 | ||
|
|
2b3a13a5a0 | ||
|
|
ca4b4905b7 | ||
|
|
c7e42fda3d | ||
|
|
2266486398 | ||
|
|
91cd859ffc | ||
|
|
c5e8a12f89 | ||
|
|
edd4cc4589 | ||
|
|
6202398292 | ||
|
|
f8c26fc369 | ||
|
|
63656116c5 | ||
|
|
e2ccd1b56a | ||
|
|
c0f4b90505 | ||
|
|
c3f5a07256 | ||
|
|
7450b8f061 | ||
|
|
677d72813e | ||
|
|
abe24fb46a | ||
|
|
ce5396c9ab | ||
|
|
dc0982dfd2 | ||
|
|
a9f6ca8b77 | ||
|
|
d2e790ce99 | ||
|
|
f1bd7d2ec2 | ||
|
|
425616defe | ||
|
|
fca4a6bd29 | ||
|
|
bdaaa8541f | ||
|
|
0fce9cd9f7 | ||
|
|
e4adba4f66 | ||
|
|
be8529246c | ||
|
|
98f818e295 | ||
|
|
fb869bc008 |
@@ -8,6 +8,11 @@ LMS_BASE_URL=http://localhost:18000
|
||||
LOGIN_URL=http://localhost:18000/login
|
||||
LOGOUT_URL=http://localhost:18000/login
|
||||
MARKETING_SITE_BASE_URL=http://localhost:18000
|
||||
TERMS_OF_SERVICE_URL=null
|
||||
PRIVACY_POLICY_URL=null
|
||||
SUPPORT_EMAIL=null
|
||||
STUDIO_BASE_URL=http://localhost:18010
|
||||
ENABLE_ACCESSIBILITY_PAGE=false
|
||||
ORDER_HISTORY_URL=localhost:1996/orders
|
||||
REFRESH_ACCESS_TOKEN_ENDPOINT=http://localhost:18000/login_refresh
|
||||
SEGMENT_KEY=null
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
const { createConfig } = require('@edx/frontend-build');
|
||||
const { createConfig } = require('@openedx/frontend-build');
|
||||
|
||||
module.exports = createConfig('eslint');
|
||||
|
||||
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -11,13 +11,13 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
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@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ env.NODE_VER }}
|
||||
- name: Install dependencies
|
||||
|
||||
2
.github/workflows/lockfileversion-check.yml
vendored
2
.github/workflows/lockfileversion-check.yml
vendored
@@ -10,4 +10,4 @@ on:
|
||||
|
||||
jobs:
|
||||
version-check:
|
||||
uses: openedx/.github/.github/workflows/lockfileversion-check-v3.yml@master
|
||||
uses: openedx/.github/.github/workflows/lockfile-check.yml@master
|
||||
|
||||
5
.github/workflows/release.yml
vendored
5
.github/workflows/release.yml
vendored
@@ -3,19 +3,20 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- alpha
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
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@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ env.NODE_VER }}
|
||||
- name: Install dependencies
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,3 +10,4 @@ src/i18n/transifex_input.json
|
||||
temp/babel-plugin-react-intl
|
||||
/.vscode
|
||||
module.config.js
|
||||
src/i18n/messages
|
||||
@@ -1,5 +1,8 @@
|
||||
{
|
||||
"branch": "master",
|
||||
"branches": [
|
||||
"master",
|
||||
{name: "alpha", prerelease: true}
|
||||
],
|
||||
"tagFormat": "v${version}",
|
||||
"verifyConditions": [
|
||||
"@semantic-release/npm",
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
[main]
|
||||
host = https://www.transifex.com
|
||||
|
||||
[o:open-edx:p:edx-platform:r:frontend-component-footer]
|
||||
file_filter = src/i18n/messages/<lang>.json
|
||||
source_file = src/i18n/transifex_input.json
|
||||
source_lang = en
|
||||
type = KEYVALUEJSON
|
||||
|
||||
21
Makefile
21
Makefile
@@ -1,12 +1,9 @@
|
||||
export TRANSIFEX_RESOURCE = frontend-component-footer
|
||||
transifex_langs = "ar,fr,es_419,zh_CN,pt,it,de,uk,ru,hi,fr_CA,it_IT,pt_PT,de_DE"
|
||||
|
||||
transifex_utils = ./node_modules/.bin/transifex-utils.js
|
||||
i18n = ./src/i18n
|
||||
transifex_input = $(i18n)/transifex_input.json
|
||||
|
||||
# This directory must match .babelrc .
|
||||
transifex_temp = ./temp/babel-plugin-react-intl
|
||||
transifex_temp = ./temp/babel-plugin-formatjs
|
||||
|
||||
build:
|
||||
rm -rf ./dist
|
||||
@@ -17,7 +14,7 @@ build:
|
||||
@rm -rf dist/__mocks__
|
||||
|
||||
requirements:
|
||||
npm install
|
||||
npm ci
|
||||
|
||||
i18n.extract:
|
||||
# Pulling display strings from .jsx files into .json files...
|
||||
@@ -35,20 +32,6 @@ detect_changed_source_translations:
|
||||
# Checking for changed translations...
|
||||
git diff --exit-code $(i18n)
|
||||
|
||||
# Pushes translations to Transifex. You must run make extract_translations first.
|
||||
push_translations:
|
||||
# Pushing strings to Transifex...
|
||||
tx push -s
|
||||
# Fetching hashes from Transifex...
|
||||
./node_modules/@edx/reactifex/bash_scripts/get_hashed_strings_v3.sh
|
||||
# Writing out comments to file...
|
||||
$(transifex_utils) $(transifex_temp) --comments --v3-scripts-path
|
||||
# Pushing comments to Transifex...
|
||||
./node_modules/@edx/reactifex/bash_scripts/put_comments_v3.sh
|
||||
|
||||
# Pulls translations from Transifex.
|
||||
pull_translations:
|
||||
tx pull -t -f --mode reviewed --languages=$(transifex_langs)
|
||||
|
||||
# This target is used by Travis.
|
||||
validate-no-uncommitted-package-lock-changes:
|
||||
|
||||
124
README.rst
124
README.rst
@@ -5,14 +5,33 @@ frontend-component-footer
|
||||
|Build Status| |Codecov| |npm_version| |npm_downloads| |license| |semantic-release|
|
||||
|
||||
********
|
||||
Overview
|
||||
Purpose
|
||||
********
|
||||
|
||||
A generic footer for Open edX micro-frontend applications. It includes a logo and an optional language selector dropdown.
|
||||
|
||||
************
|
||||
***************
|
||||
Getting Started
|
||||
***************
|
||||
|
||||
Prerequisites
|
||||
=============
|
||||
|
||||
The `devstack`_ is currently recommended as a development environment for your
|
||||
new MFE. If you start it with ``make dev.up.lms`` that should give you
|
||||
everything you need as a companion to this frontend.
|
||||
|
||||
Note that it is also possible to use `Tutor`_ to develop an MFE. You can refer
|
||||
to the `relevant tutor-mfe documentation`_ to get started using it.
|
||||
|
||||
.. _Devstack: https://github.com/openedx/devstack
|
||||
|
||||
.. _Tutor: https://github.com/overhangio/tutor
|
||||
|
||||
.. _relevant tutor-mfe documentation: https://github.com/overhangio/tutor-mfe#mfe-development
|
||||
|
||||
Requirements
|
||||
************
|
||||
============
|
||||
|
||||
This component uses ``@edx/frontend-platform`` services such as i18n, analytics, configuration, and the ``AppContext`` React component, and expects that it has been loaded into a micro-frontend that has been properly initialized via ``@edx/frontend-platform``'s ``initialize`` function. `Please visit the frontend template application to see an example. <https://github.com/openedx/frontend-template-application/blob/3355bb3a96232390e9056f35b06ffa8f105ed7ca/src/index.jsx>`_
|
||||
|
||||
@@ -24,9 +43,8 @@ This component requires that the following environment variable be set by the co
|
||||
* ``LMS_BASE_URL`` - The URL of the LMS of your Open edX instance.
|
||||
* ``LOGO_TRADEMARK_URL`` - This is a URL to a logo for use in the footer. This is a different environment variable than ``LOGO_URL`` (used in frontend-component-header) to accommodate sites that would like to have additional trademark information on a logo in the footer, such as a (tm) or (r) symbol.
|
||||
|
||||
************
|
||||
Installation
|
||||
************
|
||||
============
|
||||
|
||||
To install this footer into your Open edX micro-frontend, run the following command in your MFE:
|
||||
|
||||
@@ -34,9 +52,33 @@ To install this footer into your Open edX micro-frontend, run the following comm
|
||||
|
||||
This will make the component available to be imported into your application.
|
||||
|
||||
*****
|
||||
Cloning and Startup
|
||||
===================
|
||||
|
||||
.. code-block::
|
||||
|
||||
|
||||
1. Clone your new repo:
|
||||
|
||||
``git clone https://github.com/openedx/frontend-component-footer.git``
|
||||
|
||||
2. Use node v18.x.
|
||||
|
||||
The current version of the micro-frontend build scripts support node 18.
|
||||
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>`_.
|
||||
|
||||
3. Install npm dependencies:
|
||||
|
||||
``cd frontend-component-footer && npm ci``
|
||||
|
||||
4. Start the dev server:
|
||||
|
||||
``npm start``
|
||||
|
||||
Usage
|
||||
*****
|
||||
=====
|
||||
|
||||
This library has the following exports:
|
||||
|
||||
@@ -51,6 +93,12 @@ This library has the following exports:
|
||||
language from its dropdown.
|
||||
* supportedLanguages: An array of objects representing available languages. See example below for object shape.
|
||||
|
||||
Plugin
|
||||
======
|
||||
The footer can be replaced using 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/>`_.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
@@ -71,9 +119,10 @@ Component Usage Example::
|
||||
* `An example of minimal component and messages usage. <https://github.com/openedx/frontend-template-application/blob/3355bb3a96232390e9056f35b06ffa8f105ed7ca/src/index.jsx#L23>`_
|
||||
* `An example of SCSS file usage. <https://github.com/openedx/frontend-template-application/blob/3cd5485bf387b8c479baf6b02bf59e3061dc3465/src/index.scss#L9>`_
|
||||
|
||||
***********
|
||||
|
||||
|
||||
Development
|
||||
***********
|
||||
===========
|
||||
|
||||
Install dependencies::
|
||||
|
||||
@@ -87,6 +136,63 @@ Build a production distribution::
|
||||
|
||||
npm run build
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
The code in this repository is licensed under the AGPLv3 unless otherwise
|
||||
noted.
|
||||
|
||||
Please see `LICENSE <LICENSE>`_ for details.
|
||||
|
||||
Contributing
|
||||
============
|
||||
|
||||
Contributions are very welcome. Please read `How To Contribute`_ for details.
|
||||
|
||||
.. _How To Contribute: https://openedx.org/r/how-to-contribute
|
||||
|
||||
This project is currently accepting all types of contributions, bug fixes,
|
||||
security fixes, maintenance work, or new features. However, please make sure
|
||||
to have a discussion about your new feature idea with the maintainers prior to
|
||||
beginning development to maximize the chances of your change being accepted.
|
||||
You can start a conversation by creating a new issue on this repo summarizing
|
||||
your idea.
|
||||
|
||||
Getting Help
|
||||
===========
|
||||
|
||||
If you're having trouble, we have discussion forums at
|
||||
https://discuss.openedx.org where you can connect with others in the community.
|
||||
|
||||
Our real-time conversations are on Slack. You can request a `Slack
|
||||
invitation`_, then join our `community Slack workspace`_. Because this is a
|
||||
frontend repository, the best place to discuss it would be in the `#wg-frontend
|
||||
channel`_.
|
||||
|
||||
For anything non-trivial, the best path is to open an issue in this repository
|
||||
with as many details about the issue you are facing as you can provide.
|
||||
|
||||
https://github.com/openedx/frontend-component-footer/issues
|
||||
|
||||
For more information about these options, see the `Getting Help`_ page.
|
||||
|
||||
.. _Slack invitation: https://openedx.org/slack
|
||||
.. _community Slack workspace: https://openedx.slack.com/
|
||||
.. _#wg-frontend channel: https://openedx.slack.com/archives/C04BM6YC7A6
|
||||
.. _Getting Help: https://openedx.org/community/connect
|
||||
|
||||
The Open edX Code of Conduct
|
||||
============================
|
||||
|
||||
All community members are expected to follow the `Open edX Code of Conduct`_.
|
||||
|
||||
.. _Open edX Code of Conduct: https://openedx.org/code-of-conduct/
|
||||
|
||||
Reporting Security Issues
|
||||
=========================
|
||||
|
||||
Please do not report security issues in public. Please email security@openedx.org.
|
||||
|
||||
.. |Build Status| image:: https://api.travis-ci.com/edx/frontend-component-footer.svg?branch=master
|
||||
:target: https://travis-ci.com/edx/frontend-component-footer
|
||||
.. |Codecov| image:: https://img.shields.io/codecov/c/github/edx/frontend-component-footer
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
const { createConfig } = require('@edx/frontend-build');
|
||||
const { createConfig } = require('@openedx/frontend-build');
|
||||
|
||||
module.exports = createConfig('babel-preserve-modules');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@import "@edx/brand/paragon/fonts";
|
||||
@import "@edx/brand/paragon/variables";
|
||||
@import "@edx/paragon/scss/core/core";
|
||||
@import "@openedx/paragon/scss/core/core";
|
||||
@import "@edx/brand/paragon/overrides";
|
||||
|
||||
@import "@edx/frontend-component-footer/footer";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { createConfig } = require('@edx/frontend-build');
|
||||
const { createConfig } = require('@openedx/frontend-build');
|
||||
|
||||
module.exports = createConfig('jest', {
|
||||
setupFiles: [
|
||||
|
||||
17799
package-lock.json
generated
17799
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
38
package.json
38
package.json
@@ -8,11 +8,12 @@
|
||||
},
|
||||
"scripts": {
|
||||
"build": "make build",
|
||||
"i18n_extract": "BABEL_ENV=i18n fedx-scripts babel src --quiet > /dev/null",
|
||||
"i18n_extract": "fedx-scripts formatjs extract",
|
||||
"lint": "fedx-scripts eslint --ext .js --ext .jsx .",
|
||||
"snapshot": "fedx-scripts jest --updateSnapshot",
|
||||
"start": "fedx-scripts webpack-dev-server --progress",
|
||||
"test": "fedx-scripts jest --coverage"
|
||||
"start:with-theme": "paragon install-theme && npm start && npm install",
|
||||
"test": "fedx-scripts jest"
|
||||
},
|
||||
"files": [
|
||||
"/dist"
|
||||
@@ -33,33 +34,38 @@
|
||||
},
|
||||
"homepage": "https://github.com/openedx/frontend-component-footer#readme",
|
||||
"devDependencies": {
|
||||
"@edx/brand": "npm:@edx/brand-openedx@1.2.0",
|
||||
"@edx/brand": "npm:@openedx/brand-openedx@^1.2.2",
|
||||
"@edx/browserslist-config": "^1.1.1",
|
||||
"@edx/frontend-build": "12.9.10",
|
||||
"@edx/frontend-platform": "5.0.0",
|
||||
"@edx/paragon": "^20.44.0",
|
||||
"@edx/frontend-platform": "8.0.3",
|
||||
"@edx/reactifex": "^2.1.1",
|
||||
"@wojtekmaj/enzyme-adapter-react-17": "0.8.0",
|
||||
"enzyme": "3.11.0",
|
||||
"@openedx/frontend-build": "14.0.3",
|
||||
"@openedx/frontend-plugin-framework": "^1.1.2",
|
||||
"@openedx/paragon": "22.4.0",
|
||||
"@testing-library/jest-dom": "^5.16.4",
|
||||
"@testing-library/react": "^12.1.1",
|
||||
"husky": "8.0.3",
|
||||
"prop-types": "15.8.1",
|
||||
"react": "17.0.2",
|
||||
"react-dom": "17.0.2",
|
||||
"react-redux": "7.2.9",
|
||||
"react-router-dom": "6.15.0",
|
||||
"react-router-dom": "6.23.1",
|
||||
"react-test-renderer": "17.0.2",
|
||||
"redux": "4.2.1",
|
||||
"semantic-release": "21.0.9"
|
||||
"semantic-release": "21.1.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-svg-core": "6.4.2",
|
||||
"@fortawesome/free-brands-svg-icons": "6.4.2",
|
||||
"@fortawesome/free-regular-svg-icons": "6.4.2",
|
||||
"@fortawesome/free-solid-svg-icons": "6.4.2",
|
||||
"@fortawesome/react-fontawesome": "0.2.0"
|
||||
"@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",
|
||||
"lodash": "^4.17.21",
|
||||
"ts-jest": "^29.1.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@edx/frontend-platform": "^4.0.0 || ^5.0.0",
|
||||
"@edx/frontend-platform": "^7.0.0 || ^8.0.0",
|
||||
"@openedx/paragon": ">= 21.11.3 < 23.0.0",
|
||||
"prop-types": "^15.5.10",
|
||||
"react": "^16.9.0 || ^17.0.0",
|
||||
"react-dom": "^16.9.0 || ^17.0.0"
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
"automerge": true
|
||||
},
|
||||
{
|
||||
"matchPackagePatterns": ["@edx"],
|
||||
"matchPackagePatterns": ["@edx", "@openedx"],
|
||||
"matchUpdateTypes": ["minor", "patch"],
|
||||
"automerge": true
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
|
||||
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
|
||||
import { ensureConfig } from '@edx/frontend-platform/config';
|
||||
import { ensureConfig } from '@edx/frontend-platform';
|
||||
import { AppContext } from '@edx/frontend-platform/react';
|
||||
|
||||
import messages from './Footer.messages';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable react/prop-types */
|
||||
import React, { useMemo } from 'react';
|
||||
import renderer from 'react-test-renderer';
|
||||
import { mount } from 'enzyme';
|
||||
import { render, fireEvent, screen } from '@testing-library/react';
|
||||
import { IntlProvider } from '@edx/frontend-platform/i18n';
|
||||
import { AppContext } from '@edx/frontend-platform/react';
|
||||
|
||||
@@ -78,9 +78,9 @@ describe('<Footer />', () => {
|
||||
describe('handles language switching', () => {
|
||||
it('calls onLanguageSelected prop when a language is changed', () => {
|
||||
const mockHandleLanguageSelected = jest.fn();
|
||||
const wrapper = mount(<FooterWithLanguageSelector languageSelected={mockHandleLanguageSelected} />);
|
||||
render(<FooterWithLanguageSelector languageSelected={mockHandleLanguageSelected} />);
|
||||
|
||||
wrapper.find('form').simulate('submit', {
|
||||
fireEvent.submit(screen.getByTestId('site-footer-submit-btn'), {
|
||||
target: {
|
||||
elements: {
|
||||
'site-footer-language-select': {
|
||||
|
||||
@@ -34,7 +34,7 @@ const LanguageSelector = ({
|
||||
>
|
||||
{options.map(({ value, label }) => <option key={value} value={value}>{label}</option>)}
|
||||
</select>
|
||||
<button className="btn btn-outline-primary btn-sm" type="submit">
|
||||
<button data-testid="site-footer-submit-btn" className="btn btn-outline-primary btn-sm" type="submit">
|
||||
<FormattedMessage
|
||||
id="footer.languageForm.submit.label"
|
||||
defaultMessage="Apply"
|
||||
|
||||
@@ -17,7 +17,7 @@ exports[`<Footer /> renders correctly renders with a language selector 1`] = `
|
||||
alt="Powered by Open edX"
|
||||
src="https://edx-cdn.org/v3/default/logo-trademark.svg"
|
||||
style={
|
||||
Object {
|
||||
{
|
||||
"maxHeight": 45,
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,7 @@ exports[`<Footer /> renders correctly renders with a language selector 1`] = `
|
||||
</select>
|
||||
<button
|
||||
className="btn btn-outline-primary btn-sm"
|
||||
data-testid="site-footer-submit-btn"
|
||||
type="submit"
|
||||
>
|
||||
Apply
|
||||
@@ -85,7 +86,7 @@ exports[`<Footer /> renders correctly renders without a language selector 1`] =
|
||||
alt="Powered by Open edX"
|
||||
src="https://edx-cdn.org/v3/default/logo-trademark.svg"
|
||||
style={
|
||||
Object {
|
||||
{
|
||||
"maxHeight": 45,
|
||||
}
|
||||
}
|
||||
@@ -115,7 +116,7 @@ exports[`<Footer /> renders correctly renders without a language selector in es
|
||||
alt="Powered by Open edX"
|
||||
src="https://edx-cdn.org/v3/default/logo-trademark.svg"
|
||||
style={
|
||||
Object {
|
||||
{
|
||||
"maxHeight": 45,
|
||||
}
|
||||
}
|
||||
|
||||
146
src/components/studio-footer/StudioFooter.jsx
Normal file
146
src/components/studio-footer/StudioFooter.jsx
Normal file
@@ -0,0 +1,146 @@
|
||||
import React, { useContext, useState } from 'react';
|
||||
import _ from 'lodash';
|
||||
import { intlShape, injectIntl, 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 messages from './messages';
|
||||
|
||||
ensureConfig([
|
||||
'LMS_BASE_URL',
|
||||
'MARKETING_SITE_BASE_URL',
|
||||
'TERMS_OF_SERVICE_URL',
|
||||
'PRIVACY_POLICY_URL',
|
||||
'SUPPORT_EMAIL',
|
||||
'SITE_NAME',
|
||||
'STUDIO_BASE_URL',
|
||||
'ENABLE_ACCESSIBILITY_PAGE',
|
||||
], 'Studio Footer component');
|
||||
|
||||
const StudioFooter = ({
|
||||
// injected
|
||||
intl,
|
||||
}) => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const { config } = useContext(AppContext);
|
||||
|
||||
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>
|
||||
<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) && (
|
||||
<Hyperlink destination={config.TERMS_OF_SERVICE_URL} data-testid="termsOfService">
|
||||
{intl.formatMessage(messages.termsOfServiceLinkLabel)}
|
||||
</Hyperlink>
|
||||
)}{!_.isEmpty(config.PRIVACY_POLICY_URL) && (
|
||||
<Hyperlink destination={config.PRIVACY_POLICY_URL} data-testid="privacyPolicy">
|
||||
{intl.formatMessage(messages.privacyPolicyLinkLabel)}
|
||||
</Hyperlink>
|
||||
)}
|
||||
{config.ENABLE_ACCESSIBILITY_PAGE === 'true' && (
|
||||
<Hyperlink
|
||||
destination={`${config.STUDIO_BASE_URL}/accessibility`}
|
||||
data-testid="accessibilityRequest"
|
||||
>
|
||||
{intl.formatMessage(messages.accessibilityRequestLinkLabel)}
|
||||
</Hyperlink>
|
||||
)}
|
||||
<Hyperlink destination={config.LMS_BASE_URL}>LMS</Hyperlink>
|
||||
</ActionRow>
|
||||
<ActionRow className="mt-3 pb-4 x-small">
|
||||
{/*
|
||||
Site operators: Please do not remove this paragraph! this attributes back to edX and
|
||||
makes your acknowledgement of edX's trademarks clear.
|
||||
Translators: 'edX' and 'Open edX' are trademarks of 'edX Inc.'. Please do not translate
|
||||
any of these trademarks and company names.
|
||||
*/}
|
||||
<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>
|
||||
</ActionRow>
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
StudioFooter.propTypes = {
|
||||
// injected
|
||||
intl: intlShape.isRequired,
|
||||
};
|
||||
|
||||
export default injectIntl(StudioFooter);
|
||||
121
src/components/studio-footer/StudioFooter.test.jsx
Normal file
121
src/components/studio-footer/StudioFooter.test.jsx
Normal file
@@ -0,0 +1,121 @@
|
||||
/* eslint-disable react/prop-types */
|
||||
import React, { useMemo } from 'react';
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import '@testing-library/jest-dom/extend-expect';
|
||||
import { IntlProvider } from '@edx/frontend-platform/i18n';
|
||||
import { AppContext } from '@edx/frontend-platform/react';
|
||||
import StudioFooter from './StudioFooter';
|
||||
import messages from './messages';
|
||||
|
||||
const config = {
|
||||
LMS_BASE_URL: process.env.LMS_BASE_URL,
|
||||
MARKETING_SITE_BASE_URL: process.env.MARKETING_SITE_BASE_URL,
|
||||
TERMS_OF_SERVICE_URL: process.env.TERMS_OF_SERVICE_URL,
|
||||
PRIVACY_POLICY_URL: process.env.PRIVACY_POLICY_URL,
|
||||
SUPPORT_EMAIL: process.env.SUPPORT_EMAIL,
|
||||
SITE_NAME: process.env.SITE_NAME,
|
||||
STUDIO_BASE_URL: process.env.STUDIO_BASE_URL,
|
||||
ENABLE_ACCESSIBILITY_PAGE: process.env.ENABLE_ACCESSIBILITY_PAGE,
|
||||
};
|
||||
|
||||
let currentConfig = config;
|
||||
const Component = ({ updateVariable }) => {
|
||||
if (updateVariable) {
|
||||
const [variable, value] = updateVariable;
|
||||
currentConfig = {
|
||||
...config,
|
||||
[variable]: value,
|
||||
};
|
||||
}
|
||||
const contextValue = useMemo(() => ({
|
||||
authenticatedUser: null,
|
||||
config: currentConfig,
|
||||
}), []);
|
||||
|
||||
return (
|
||||
<IntlProvider locale="en">
|
||||
<AppContext.Provider value={contextValue}>
|
||||
<StudioFooter />
|
||||
</AppContext.Provider>
|
||||
</IntlProvider>
|
||||
);
|
||||
};
|
||||
|
||||
jest.unmock('@openedx/paragon');
|
||||
|
||||
describe('Footer', () => {
|
||||
describe('help section default view', () => {
|
||||
it('help button should read Looking for help with Studio?', () => {
|
||||
render(<Component />);
|
||||
expect(screen.getByText(messages.openHelpButtonLabel.defaultMessage))
|
||||
.toBeVisible();
|
||||
});
|
||||
it('help button link row should not be visible', () => {
|
||||
render(<Component />);
|
||||
expect(screen.queryByTestId('helpButtonRow')).toBeNull();
|
||||
});
|
||||
});
|
||||
describe('help section expanded view', () => {
|
||||
it('help button should read Hide Studio help', () => {
|
||||
render(<Component />);
|
||||
const helpToggleButton = screen.getByText(messages.openHelpButtonLabel.defaultMessage);
|
||||
fireEvent.click(helpToggleButton);
|
||||
expect(screen.getByText(messages.closeHelpButtonLabel.defaultMessage))
|
||||
.toBeVisible();
|
||||
});
|
||||
it('help button link row should be visible', () => {
|
||||
render(<Component />);
|
||||
const helpToggleButton = screen.getByText(messages.openHelpButtonLabel.defaultMessage);
|
||||
fireEvent.click(helpToggleButton);
|
||||
expect(screen.getByTestId('helpButtonRow')).toBeVisible();
|
||||
});
|
||||
it('Open edX portal button should be visible', () => {
|
||||
render(<Component />);
|
||||
const helpToggleButton = screen.getByText(messages.openHelpButtonLabel.defaultMessage);
|
||||
fireEvent.click(helpToggleButton);
|
||||
expect(screen.getByTestId('openEdXPortalButton')).toBeVisible();
|
||||
});
|
||||
it('should not show contact us button', () => {
|
||||
render(<Component />);
|
||||
const helpToggleButton = screen.getByText(messages.openHelpButtonLabel.defaultMessage);
|
||||
fireEvent.click(helpToggleButton);
|
||||
expect(screen.queryByTestId('contactUsButton')).toBeNull();
|
||||
});
|
||||
it('should show contact us button', () => {
|
||||
render(<Component updateVariable={['SUPPORT_EMAIL', 'support@email.com']} />);
|
||||
const helpToggleButton = screen.getByText(messages.openHelpButtonLabel.defaultMessage);
|
||||
fireEvent.click(helpToggleButton);
|
||||
expect(screen.getByTestId('contactUsButton')).toBeVisible();
|
||||
});
|
||||
});
|
||||
describe('policy link row', () => {
|
||||
it('should only show LMS link', () => {
|
||||
render(<Component />);
|
||||
expect(screen.getByText('LMS')).toBeVisible();
|
||||
expect(screen.queryByTestId('termsOfService')).toBeNull();
|
||||
expect(screen.queryByTestId('privacyPolicy')).toBeNull();
|
||||
expect(screen.queryByTestId('accessibilityRequest')).toBeNull();
|
||||
});
|
||||
it('should show terms of service link', () => {
|
||||
render(<Component updateVariable={['TERMS_OF_SERVICE_URL', 'termsofserviceurl']} />);
|
||||
expect(screen.getByText('LMS')).toBeVisible();
|
||||
expect(screen.queryByTestId('termsOfService')).toBeVisible();
|
||||
expect(screen.queryByTestId('privacyPolicy')).toBeNull();
|
||||
expect(screen.queryByTestId('accessibilityRequest')).toBeNull();
|
||||
});
|
||||
it('should show privacy policy link', () => {
|
||||
render(<Component updateVariable={['PRIVACY_POLICY_URL', 'privacypolicyurl']} />);
|
||||
expect(screen.getByText('LMS')).toBeVisible();
|
||||
expect(screen.queryByTestId('termsOfService')).toBeNull();
|
||||
expect(screen.queryByTestId('privacyPolicy')).toBeVisible();
|
||||
expect(screen.queryByTestId('accessibilityRequest')).toBeNull();
|
||||
});
|
||||
it('should show accessibilty request link', () => {
|
||||
render(<Component updateVariable={['ENABLE_ACCESSIBILITY_PAGE', 'true']} />);
|
||||
expect(screen.getByText('LMS')).toBeVisible();
|
||||
expect(screen.queryByTestId('termsOfService')).toBeNull();
|
||||
expect(screen.queryByTestId('privacyPolicy')).toBeNull();
|
||||
expect(screen.queryByTestId('accessibilityRequest')).toBeVisible();
|
||||
});
|
||||
});
|
||||
});
|
||||
3
src/components/studio-footer/index.jsx
Normal file
3
src/components/studio-footer/index.jsx
Normal file
@@ -0,0 +1,3 @@
|
||||
import StudioFooter from './StudioFooter';
|
||||
|
||||
export default StudioFooter;
|
||||
61
src/components/studio-footer/messages.js
Normal file
61
src/components/studio-footer/messages.js
Normal file
@@ -0,0 +1,61 @@
|
||||
import { defineMessages } from '@edx/frontend-platform/i18n';
|
||||
|
||||
const messages = defineMessages({
|
||||
openHelpButtonLabel: {
|
||||
id: 'authoring.footer.help.openHelp.button.label',
|
||||
defaultMessage: 'Looking for help with Studio?',
|
||||
description: 'Label for button that opens the collapsed section with help buttons',
|
||||
},
|
||||
closeHelpButtonLabel: {
|
||||
id: 'authoring.footer.help.closeHelp.button.label',
|
||||
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',
|
||||
},
|
||||
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',
|
||||
},
|
||||
contactUsButtonLabel: {
|
||||
id: 'authoring.footer.help.contactUs.button.label',
|
||||
defaultMessage: 'Contact us',
|
||||
description: 'Label for button that links to the email for partner support',
|
||||
},
|
||||
termsOfServiceLinkLabel: {
|
||||
id: 'authoring.footer.termsOfService.link.label',
|
||||
defaultMessage: 'Terms of Service',
|
||||
description: 'Label for button that links to the terms of service page',
|
||||
},
|
||||
privacyPolicyLinkLabel: {
|
||||
id: 'authoring.footer.privacyPolicy.link.label',
|
||||
defaultMessage: 'Privacy Policy',
|
||||
description: 'Label for button that links to the privacy policy page',
|
||||
},
|
||||
accessibilityRequestLinkLabel: {
|
||||
id: 'authoring.footer.accessibilityRequest.link.label',
|
||||
defaultMessage: 'Accessibility Accomodation Request',
|
||||
description: 'Label for button that links to the accessibility accomodation requests page',
|
||||
},
|
||||
trademarkMessage: {
|
||||
id: 'authoring.footer.trademark.message',
|
||||
defaultMessage: 'edX and Open edX, and the edX and Open edX logos are registered trademarks of',
|
||||
description: 'Message about the use of logos and names edX and Open edX',
|
||||
},
|
||||
});
|
||||
|
||||
export default messages;
|
||||
@@ -1,34 +1 @@
|
||||
import arMessages from './messages/ar.json';
|
||||
import frMessages from './messages/fr.json';
|
||||
import es419Messages from './messages/es_419.json';
|
||||
import zhcnMessages from './messages/zh_CN.json';
|
||||
import ptMessages from './messages/pt.json';
|
||||
import itMessages from './messages/it.json';
|
||||
import ukMessages from './messages/uk.json';
|
||||
import deMessages from './messages/de.json';
|
||||
import ruMessages from './messages/ru.json';
|
||||
import hiMessages from './messages/hi.json';
|
||||
import frCAMessages from './messages/fr_CA.json';
|
||||
import dedeCAMessages from './messages/de_DE.json';
|
||||
import ititCAMessages from './messages/it_IT.json';
|
||||
import ptptCAMessages from './messages/pt_PT.json';
|
||||
// no need to import en messages-- they are in the defaultMessage field
|
||||
|
||||
const messages = {
|
||||
ar: arMessages,
|
||||
'es-419': es419Messages,
|
||||
fr: frMessages,
|
||||
'zh-cn': zhcnMessages,
|
||||
pt: ptMessages,
|
||||
it: itMessages,
|
||||
de: deMessages,
|
||||
hi: hiMessages,
|
||||
'fr-ca': frCAMessages,
|
||||
ru: ruMessages,
|
||||
uk: ukMessages,
|
||||
'de-de': dedeCAMessages,
|
||||
'it-it': ititCAMessages,
|
||||
'pt-pt': ptptCAMessages,
|
||||
};
|
||||
|
||||
export default messages;
|
||||
export default {};
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -1,5 +1,8 @@
|
||||
import Footer, { EVENT_NAMES } from './components/Footer';
|
||||
import messages from './i18n/index';
|
||||
import StudioFooter from './components/studio-footer';
|
||||
|
||||
export default Footer;
|
||||
export { messages, EVENT_NAMES };
|
||||
export {
|
||||
messages, EVENT_NAMES, StudioFooter,
|
||||
};
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
import Enzyme from 'enzyme';
|
||||
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
|
||||
|
||||
Enzyme.configure({ adapter: new Adapter() });
|
||||
|
||||
// These configuration values are usually set in webpack's EnvironmentPlugin however
|
||||
// Jest does not use webpack so we need to set these so for testing
|
||||
process.env.ACCESS_TOKEN_COOKIE_NAME = 'edx-jwt-cookie-header-payload';
|
||||
@@ -24,3 +19,4 @@ process.env.LOGO_URL = 'https://edx-cdn.org/v3/default/logo.svg';
|
||||
process.env.LOGO_TRADEMARK_URL = 'https://edx-cdn.org/v3/default/logo-trademark.svg';
|
||||
process.env.LOGO_WHITE_URL = 'https://edx-cdn.org/v3/default/logo-white.svg';
|
||||
process.env.FAVICON_URL = 'https://edx-cdn.org/v3/default/favicon.ico';
|
||||
process.env.ENABLE_ACCESSIBILITY_PAGE = 'false';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const path = require('path');
|
||||
const { createConfig } = require('@edx/frontend-build');
|
||||
const { createConfig } = require('@openedx/frontend-build');
|
||||
|
||||
module.exports = createConfig('webpack-dev', {
|
||||
entry: path.resolve(__dirname, 'example'),
|
||||
|
||||
Reference in New Issue
Block a user