Compare commits
322 Commits
v11.2.0
...
renovate/c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56f6d318f2 | ||
|
|
8a5ba98e96 | ||
|
|
29e96e3b5a | ||
|
|
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 | ||
|
|
5b34595520 | ||
|
|
32ae2d8e7c | ||
|
|
abac1cd6d4 | ||
|
|
e0115e3d88 | ||
|
|
ff18f3add9 | ||
|
|
4926c3105b | ||
|
|
838a81a020 | ||
|
|
0ac6840cea | ||
|
|
26a17bf2e4 | ||
|
|
17b9710810 | ||
|
|
df0129485e | ||
|
|
1c2f290faa | ||
|
|
9af9024bcc | ||
|
|
0008bd485a | ||
|
|
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 | ||
|
|
879f384809 | ||
|
|
b65a80616b | ||
|
|
d5f0bca2b7 | ||
|
|
3e6eaa1ded | ||
|
|
48b56df115 | ||
|
|
1d2bfd8e40 | ||
|
|
197f24a684 | ||
|
|
0d6c99acbc | ||
|
|
8213c3a66a | ||
|
|
a6ae384f7e | ||
|
|
dd612879e2 | ||
|
|
248bab9370 | ||
|
|
92c879bf8f | ||
|
|
16275a2ecc | ||
|
|
970ca113e9 | ||
|
|
65c459c53e | ||
|
|
961faafd3a | ||
|
|
16b468bdcc | ||
|
|
91d6ea6572 | ||
|
|
e13c7a6349 | ||
|
|
ec288a6430 | ||
|
|
10335c8075 | ||
|
|
e09f1af861 | ||
|
|
c1e5885ecb | ||
|
|
7849899658 | ||
|
|
c508632126 | ||
|
|
ef148e8d35 | ||
|
|
b8a162f9c9 | ||
|
|
5643296f04 | ||
|
|
5cf89420b3 | ||
|
|
176eb22711 | ||
|
|
4380dd2a14 | ||
|
|
a0080cd4ef | ||
|
|
1f80f98acc | ||
|
|
d7ed4bfaf2 | ||
|
|
898e23d4bd | ||
|
|
7c07480f31 | ||
|
|
f956c0ac93 | ||
|
|
d625329324 | ||
|
|
01ccaa6988 | ||
|
|
c0dd43ce4a | ||
|
|
56469df0b5 | ||
|
|
0de4ad621e | ||
|
|
5d50e59672 | ||
|
|
c715f0c4d4 | ||
|
|
a62124ddf2 | ||
|
|
8c222ddb0a | ||
|
|
b4031ce345 | ||
|
|
b787f5ecfe | ||
|
|
f87d47f42d | ||
|
|
818ed5d179 | ||
|
|
07eb5892da | ||
|
|
3b8b18051f | ||
|
|
1c719d63cb | ||
|
|
dc7d2fadff | ||
|
|
b710800b2a | ||
|
|
74ff35ae9a | ||
|
|
e6835f9c56 | ||
|
|
a0c19faa92 | ||
|
|
fa37ebb828 | ||
|
|
a24972b64f | ||
|
|
abb22a82ba | ||
|
|
1df0b94a8c | ||
|
|
d563e2f444 | ||
|
|
92a210f81d | ||
|
|
1b92a3c505 | ||
|
|
f88d47275b | ||
|
|
26f3900602 | ||
|
|
a9db712240 | ||
|
|
739cce6c50 | ||
|
|
3a19e219bb | ||
|
|
12511689e8 | ||
|
|
f084393cc9 | ||
|
|
4035ff122c | ||
|
|
159b5a842e | ||
|
|
b06c8b5d01 | ||
|
|
c79da49208 | ||
|
|
82b3310a8f | ||
|
|
fcd641259b | ||
|
|
509276df12 | ||
|
|
4527baef5a | ||
|
|
8183143ae5 | ||
|
|
91311f25da | ||
|
|
ccef5de855 | ||
|
|
01fa97055f | ||
|
|
3cff0970a3 | ||
|
|
f2c879999d | ||
|
|
3f18cf7c9d | ||
|
|
30796204b8 | ||
|
|
d206ecf3ad | ||
|
|
f3094e1725 | ||
|
|
5bbd266834 | ||
|
|
37eed0578f | ||
|
|
acbe489a7c | ||
|
|
2cfbb40265 | ||
|
|
e0a634900d | ||
|
|
fb06f7d9f9 |
@@ -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,3 +1,4 @@
|
||||
const { createConfig } = require('@edx/frontend-build');
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
const { createConfig } = require('@openedx/frontend-build');
|
||||
|
||||
module.exports = createConfig('eslint');
|
||||
|
||||
@@ -16,4 +16,4 @@ jobs:
|
||||
secrets:
|
||||
GITHUB_APP_ID: ${{ secrets.GRAPHQL_AUTH_APP_ID }}
|
||||
GITHUB_APP_PRIVATE_KEY: ${{ secrets.GRAPHQL_AUTH_APP_PEM }}
|
||||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_ISSUE_BOT_TOKEN }}
|
||||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_ISSUE_BOT_TOKEN }}
|
||||
|
||||
20
.github/workflows/add-remove-label-on-comment.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
# This workflow runs when a comment is made on the ticket
|
||||
# If the comment starts with "label: " it tries to apply
|
||||
# the label indicated in rest of comment.
|
||||
# If the comment starts with "remove label: ", it tries
|
||||
# to remove the indicated label.
|
||||
# Note: Labels are allowed to have spaces and this script does
|
||||
# not parse spaces (as often a space is legitimate), so the command
|
||||
# "label: really long lots of words label" will apply the
|
||||
# label "really long lots of words label"
|
||||
|
||||
name: Allows for the adding and removing of labels via comment
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
add_remove_labels:
|
||||
uses: openedx/.github/.github/workflows/add-remove-label-on-comment.yml@master
|
||||
|
||||
14
.github/workflows/ci.yml
vendored
@@ -9,18 +9,15 @@ on:
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node: [16]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Setup Nodejs
|
||||
uses: actions/setup-node@v2
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
node-version-file: '.nvmrc'
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Validate package-lock.json changes
|
||||
@@ -34,4 +31,7 @@ jobs:
|
||||
- name: i18n_extract
|
||||
run: npm run i18n_extract
|
||||
- name: Coverage
|
||||
uses: codecov/codecov-action@v3
|
||||
uses: codecov/codecov-action@v5
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
fail_ci_if_error: true
|
||||
|
||||
2
.github/workflows/commitlint.yml
vendored
@@ -7,4 +7,4 @@ on:
|
||||
|
||||
jobs:
|
||||
commitlint:
|
||||
uses: edx/.github/.github/workflows/commitlint.yml@master
|
||||
uses: openedx/.github/.github/workflows/commitlint.yml@master
|
||||
|
||||
2
.github/workflows/lockfileversion-check.yml
vendored
@@ -10,4 +10,4 @@ on:
|
||||
|
||||
jobs:
|
||||
version-check:
|
||||
uses: openedx/.github/.github/workflows/lockfileversion-check.yml@master
|
||||
uses: openedx/.github/.github/workflows/lockfileversion-check-v3.yml@master
|
||||
|
||||
22
.github/workflows/release.yml
vendored
@@ -3,19 +3,25 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- alpha
|
||||
|
||||
permissions:
|
||||
id-token: write # Required for OIDC
|
||||
contents: write # For Semantic Release tagging
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 16
|
||||
node-version-file: '.nvmrc'
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Validate package-lock.json changes
|
||||
@@ -27,11 +33,13 @@ jobs:
|
||||
- name: i18n_extract
|
||||
run: npm run i18n_extract
|
||||
- name: Coverage
|
||||
uses: codecov/codecov-action@v3
|
||||
uses: codecov/codecov-action@v5
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
fail_ci_if_error: false
|
||||
- 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 }}
|
||||
|
||||
12
.github/workflows/self-assign-issue.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# This workflow runs when a comment is made on the ticket
|
||||
# If the comment starts with "assign me" it assigns the author to the
|
||||
# ticket (case insensitive)
|
||||
|
||||
name: Assign comment author to ticket if they say "assign me"
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
self_assign_by_comment:
|
||||
uses: openedx/.github/.github/workflows/self-assign-issue.yml@master
|
||||
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
|
||||
|
||||
23
Makefile
Executable file → Normal file
@@ -1,14 +1,9 @@
|
||||
transifex_resource = frontend-component-footer
|
||||
transifex_langs = "ar,fr,es_419,zh_CN"
|
||||
|
||||
transifex_utils = ./node_modules/.bin/transifex-utils.js
|
||||
i18n = ./src/i18n
|
||||
transifex_input = $(i18n)/transifex_input.json
|
||||
tx_url1 = https://www.transifex.com/api/2/project/edx-platform/resource/$(transifex_resource)/translation/en/strings/
|
||||
tx_url2 = https://www.transifex.com/api/2/project/edx-platform/resource/$(transifex_resource)/source/
|
||||
|
||||
# This directory must match .babelrc .
|
||||
transifex_temp = ./temp/babel-plugin-react-intl
|
||||
transifex_temp = ./temp/babel-plugin-formatjs
|
||||
|
||||
build:
|
||||
rm -rf ./dist
|
||||
@@ -19,7 +14,7 @@ build:
|
||||
@rm -rf dist/__mocks__
|
||||
|
||||
requirements:
|
||||
npm install
|
||||
npm ci
|
||||
|
||||
i18n.extract:
|
||||
# Pulling display strings from .jsx files into .json files...
|
||||
@@ -37,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/reactifex/bash_scripts/get_hashed_strings.sh $(tx_url1)
|
||||
# Writing out comments to file...
|
||||
$(transifex_utils) $(transifex_temp) --comments
|
||||
# Pushing comments to Transifex...
|
||||
./node_modules/reactifex/bash_scripts/put_comments.sh $(tx_url2)
|
||||
|
||||
# Pulls translations from Transifex.
|
||||
pull_translations:
|
||||
tx pull -f --mode reviewed --languages=$(transifex_langs)
|
||||
|
||||
# This target is used by Travis.
|
||||
validate-no-uncommitted-package-lock-changes:
|
||||
|
||||
132
README.rst
@@ -5,16 +5,35 @@ 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.
|
||||
|
||||
************
|
||||
Requirements
|
||||
************
|
||||
***************
|
||||
Getting Started
|
||||
***************
|
||||
|
||||
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/edx/frontend-template-application/blob/3355bb3a96232390e9056f35b06ffa8f105ed7ca/src/index.jsx>`_
|
||||
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>`_
|
||||
|
||||
Environment Variables
|
||||
=====================
|
||||
@@ -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 v24.x.
|
||||
|
||||
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>`_.
|
||||
|
||||
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 or modified using `Frontend Plugin Framework <https://github.com/openedx/frontend-plugin-framework>`_.
|
||||
|
||||
Information on how to replace or modify the footer is available `here </src/plugin-slots>`_.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
@@ -68,12 +116,13 @@ Component Usage Example::
|
||||
]}
|
||||
/>
|
||||
|
||||
* `An example of minimal component and messages usage. <https://github.com/edx/frontend-template-application/blob/3355bb3a96232390e9056f35b06ffa8f105ed7ca/src/index.jsx#L23>`_
|
||||
* `An example of SCSS file usage. <https://github.com/edx/frontend-template-application/blob/3cd5485bf387b8c479baf6b02bf59e3061dc3465/src/index.scss#L9>`_
|
||||
* `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');
|
||||
|
||||
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 "@edx/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,4 +1,4 @@
|
||||
const { createConfig } = require('@edx/frontend-build');
|
||||
const { createConfig } = require('@openedx/frontend-build');
|
||||
|
||||
module.exports = createConfig('jest', {
|
||||
setupFiles: [
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
# openedx.yaml
|
||||
|
||||
---
|
||||
owner: edx/fedx-team
|
||||
tags:
|
||||
- library
|
||||
- component
|
||||
- react
|
||||
61545
package-lock.json
generated
70
package.json
@@ -8,59 +8,63 @@
|
||||
},
|
||||
"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 .",
|
||||
"lint:fix": "fedx-scripts eslint --fix --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 --coverage",
|
||||
"test:watch": "npm run test -- --watch"
|
||||
},
|
||||
"files": [
|
||||
"/dist"
|
||||
],
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "npm run lint"
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/edx/frontend-component-footer.git"
|
||||
"url": "git+https://github.com/openedx/frontend-component-footer.git"
|
||||
},
|
||||
"author": "edX",
|
||||
"license": "AGPL-3.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/edx/frontend-component-footer/issues"
|
||||
"url": "https://github.com/openedx/frontend-component-footer/issues"
|
||||
},
|
||||
"homepage": "https://github.com/edx/frontend-component-footer#readme",
|
||||
"homepage": "https://github.com/openedx/frontend-component-footer#readme",
|
||||
"devDependencies": {
|
||||
"@edx/brand": "npm:@edx/brand-openedx@1.1.0",
|
||||
"@edx/frontend-build": "9.2.2",
|
||||
"@edx/frontend-platform": "2.5.0",
|
||||
"@edx/paragon": "19.25.3",
|
||||
"enzyme": "3.11.0",
|
||||
"enzyme-adapter-react-16": "1.15.6",
|
||||
"husky": "7.0.4",
|
||||
"@edx/brand": "npm:@openedx/brand-openedx@^1.2.2",
|
||||
"@edx/browserslist-config": "^1.1.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": "^16.2.0",
|
||||
"@testing-library/dom": "^10.4.0",
|
||||
"@testing-library/user-event": "^14.6.1",
|
||||
"prop-types": "15.8.1",
|
||||
"react": "16.14.0",
|
||||
"react-dom": "16.14.0",
|
||||
"react-redux": "7.2.8",
|
||||
"react-router-dom": "5.3.3",
|
||||
"react-test-renderer": "16.14.0",
|
||||
"reactifex": "1.1.1",
|
||||
"redux": "4.2.0",
|
||||
"semantic-release": "17.4.7"
|
||||
"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",
|
||||
"ts-jest": "^29.1.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-svg-core": "1.2.36",
|
||||
"@fortawesome/free-brands-svg-icons": "5.15.4",
|
||||
"@fortawesome/free-regular-svg-icons": "5.15.4",
|
||||
"@fortawesome/free-solid-svg-icons": "5.15.4",
|
||||
"@fortawesome/react-fontawesome": "0.2.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",
|
||||
"lodash": "^4.17.21"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@edx/frontend-platform": "^2.3.0",
|
||||
"@edx/frontend-platform": "^7.0.0 || ^8.0.0",
|
||||
"@openedx/paragon": ">= 21.11.3 < 24.0.0",
|
||||
"prop-types": "^15.5.10",
|
||||
"react": "^16.9.0",
|
||||
"react-dom": "^16.9.0"
|
||||
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
||||
"react-dom": "^16.9.0 || ^17.0.0 || ^18.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
"pin"
|
||||
],
|
||||
"automerge": true
|
||||
},
|
||||
{
|
||||
"matchPackagePatterns": ["@edx", "@openedx"],
|
||||
"matchUpdateTypes": ["minor", "patch"],
|
||||
"automerge": true
|
||||
}
|
||||
],
|
||||
"timezone": "America/New_York"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
$gray-footer: #fcfcfc !default;
|
||||
|
||||
.footer {
|
||||
background-color: $gray-footer;
|
||||
background-color: var(--pgn-color-light-100, $gray-footer);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
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/config';
|
||||
import { ensureConfig } from '@edx/frontend-platform';
|
||||
import { AppContext } from '@edx/frontend-platform/react';
|
||||
|
||||
import messages from './Footer.messages';
|
||||
@@ -17,21 +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);
|
||||
|
||||
getLocalePrefix(locale) {
|
||||
const twoLetterPrefix = locale.substring(0, 2).toLowerCase();
|
||||
if (twoLetterPrefix === 'en') {
|
||||
return '';
|
||||
}
|
||||
return `/${twoLetterPrefix}`;
|
||||
}
|
||||
const showLanguageSelector = supportedLanguages.length > 0 && onLanguageSelected;
|
||||
|
||||
externalLinkClickHandler(event) {
|
||||
const externalLinkClickHandler = (event) => {
|
||||
const label = event.currentTarget.getAttribute('href');
|
||||
const eventName = EVENT_NAMES.FOOTER_LINK;
|
||||
const properties = {
|
||||
@@ -39,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({
|
||||
@@ -99,5 +82,5 @@ SiteFooter.defaultProps = {
|
||||
supportedLanguages: [],
|
||||
};
|
||||
|
||||
export default injectIntl(SiteFooter);
|
||||
export default SiteFooter;
|
||||
export { EVENT_NAMES };
|
||||
|
||||
@@ -1,117 +1,122 @@
|
||||
import React from 'react';
|
||||
/* eslint-disable react/prop-types */
|
||||
import React, { useMemo } from 'react';
|
||||
import renderer from 'react-test-renderer';
|
||||
import { mount } from 'enzyme';
|
||||
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(() => ({
|
||||
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}
|
||||
>
|
||||
<FooterSlot />
|
||||
</AppContext.Provider>
|
||||
</IntlProvider>
|
||||
);
|
||||
};
|
||||
|
||||
const FooterWithLanguageSelector = ({ languageSelected = () => {} }) => {
|
||||
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="en">
|
||||
<AppContext.Provider
|
||||
value={contextValue}
|
||||
>
|
||||
<Footer
|
||||
onLanguageSelected={languageSelected}
|
||||
supportedLanguages={[
|
||||
{ label: 'English', value: 'en' },
|
||||
{ label: 'Español', value: 'es' },
|
||||
]}
|
||||
/>
|
||||
</AppContext.Provider>
|
||||
</IntlProvider>
|
||||
);
|
||||
};
|
||||
|
||||
describe('<Footer />', () => {
|
||||
describe('renders correctly', () => {
|
||||
it('renders without a language selector', () => {
|
||||
const tree = renderer
|
||||
.create((
|
||||
<IntlProvider locale="en">
|
||||
<AppContext.Provider
|
||||
value={{
|
||||
authenticatedUser: null,
|
||||
config: {
|
||||
LOGO_TRADEMARK_URL: process.env.LOGO_TRADEMARK_URL,
|
||||
LMS_BASE_URL: process.env.LMS_BASE_URL,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Footer />
|
||||
</AppContext.Provider>
|
||||
</IntlProvider>
|
||||
))
|
||||
.create(<FooterWithContext locale="en" />)
|
||||
.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
it('renders without a language selector in es', () => {
|
||||
const tree = renderer
|
||||
.create((
|
||||
<IntlProvider locale="es">
|
||||
<AppContext.Provider
|
||||
value={{
|
||||
authenticatedUser: null,
|
||||
config: {
|
||||
LOGO_TRADEMARK_URL: process.env.LOGO_TRADEMARK_URL,
|
||||
LMS_BASE_URL: process.env.LMS_BASE_URL,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Footer />
|
||||
</AppContext.Provider>
|
||||
</IntlProvider>
|
||||
))
|
||||
.create(<FooterWithContext locale="es" />)
|
||||
.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
it('renders with a language selector', () => {
|
||||
const tree = renderer
|
||||
.create((
|
||||
<IntlProvider locale="en">
|
||||
<AppContext.Provider
|
||||
value={{
|
||||
authenticatedUser: null,
|
||||
config: {
|
||||
LOGO_TRADEMARK_URL: process.env.LOGO_TRADEMARK_URL,
|
||||
LMS_BASE_URL: process.env.LMS_BASE_URL,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Footer
|
||||
onLanguageSelected={() => {}}
|
||||
supportedLanguages={[
|
||||
{ label: 'English', value: 'en' },
|
||||
{ label: 'Español', value: 'es' },
|
||||
]}
|
||||
/>
|
||||
</AppContext.Provider>
|
||||
</IntlProvider>
|
||||
))
|
||||
.create(<FooterWithLanguageSelector />)
|
||||
.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
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();
|
||||
const wrapper = mount((
|
||||
<IntlProvider locale="en">
|
||||
<AppContext.Provider
|
||||
value={{
|
||||
authenticatedUser: null,
|
||||
config: {
|
||||
LOGO_TRADEMARK_URL: process.env.LOGO_TRADEMARK_URL,
|
||||
LMS_BASE_URL: process.env.LMS_BASE_URL,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Footer
|
||||
onLanguageSelected={mockHandleLanguageSelected}
|
||||
supportedLanguages={[
|
||||
{ label: 'English', value: 'en' },
|
||||
{ label: 'Español', value: 'es' },
|
||||
]}
|
||||
/>
|
||||
</AppContext.Provider>
|
||||
</IntlProvider>
|
||||
));
|
||||
render(<FooterWithLanguageSelector languageSelected={mockHandleLanguageSelected} />);
|
||||
|
||||
wrapper.find('form').simulate('submit', {
|
||||
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;
|
||||
@@ -34,7 +35,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"
|
||||
@@ -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,12 +12,13 @@ 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"
|
||||
src="https://edx-cdn.org/v3/default/logo-trademark.svg"
|
||||
style={
|
||||
Object {
|
||||
{
|
||||
"maxHeight": 45,
|
||||
}
|
||||
}
|
||||
@@ -58,6 +59,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
|
||||
@@ -80,12 +82,13 @@ 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"
|
||||
src="https://edx-cdn.org/v3/default/logo-trademark.svg"
|
||||
style={
|
||||
Object {
|
||||
{
|
||||
"maxHeight": 45,
|
||||
}
|
||||
}
|
||||
@@ -110,12 +113,13 @@ 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"
|
||||
src="https://edx-cdn.org/v3/default/logo-trademark.svg"
|
||||
style={
|
||||
Object {
|
||||
{
|
||||
"maxHeight": 45,
|
||||
}
|
||||
}
|
||||
@@ -127,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"
|
||||
/>,
|
||||
]
|
||||
`;
|
||||
|
||||
92
src/components/studio-footer/StudioFooter.jsx
Normal file
@@ -0,0 +1,92 @@
|
||||
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,
|
||||
Container,
|
||||
Hyperlink,
|
||||
} from '@openedx/paragon';
|
||||
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',
|
||||
'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 = ({
|
||||
containerProps,
|
||||
}) => {
|
||||
const intl = useIntl();
|
||||
const { config } = useContext(AppContext);
|
||||
|
||||
const { containerClassName, ...restContainerProps } = containerProps || {};
|
||||
|
||||
return (
|
||||
<>
|
||||
<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) && (
|
||||
<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 />
|
||||
<StudioFooterLogoSlot />
|
||||
</ActionRow>
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
StudioFooter.propTypes = {
|
||||
containerProps: PropTypes.shape(Container.propTypes),
|
||||
};
|
||||
|
||||
StudioFooter.defaultProps = {
|
||||
containerProps: {},
|
||||
};
|
||||
|
||||
export default StudioFooter;
|
||||
128
src/components/studio-footer/StudioFooter.test.jsx
Normal file
@@ -0,0 +1,128 @@
|
||||
/* eslint-disable react/prop-types */
|
||||
import React, { useMemo } from '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 StudioFooterSlot from '../../plugin-slots/StudioFooterSlot';
|
||||
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}>
|
||||
<StudioFooterSlot />
|
||||
</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', async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<Component />);
|
||||
const helpToggleButton = screen.getByText(messages.openHelpButtonLabel.defaultMessage);
|
||||
await user.click(helpToggleButton);
|
||||
expect(screen.getByText(messages.closeHelpButtonLabel.defaultMessage))
|
||||
.toBeVisible();
|
||||
});
|
||||
it('help button link row should be visible', async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<Component />);
|
||||
const helpToggleButton = screen.getByText(messages.openHelpButtonLabel.defaultMessage);
|
||||
await user.click(helpToggleButton);
|
||||
expect(screen.getByTestId('helpButtonRow')).toBeVisible();
|
||||
});
|
||||
it('Open edX portal button should be visible', async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<Component />);
|
||||
const helpToggleButton = screen.getByText(messages.openHelpButtonLabel.defaultMessage);
|
||||
await user.click(helpToggleButton);
|
||||
expect(screen.getByTestId('openEdXDemoCourseButton')).toBeVisible();
|
||||
});
|
||||
it('should not show contact us button', async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<Component />);
|
||||
const helpToggleButton = screen.getByText(messages.openHelpButtonLabel.defaultMessage);
|
||||
await user.click(helpToggleButton);
|
||||
expect(screen.queryByTestId('contactUsButton')).toBeNull();
|
||||
});
|
||||
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);
|
||||
await user.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();
|
||||
});
|
||||
});
|
||||
});
|
||||
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();
|
||||
});
|
||||
});
|
||||
3
src/components/studio-footer/index.jsx
Normal file
@@ -0,0 +1,3 @@
|
||||
import StudioFooter from './StudioFooter';
|
||||
|
||||
export default StudioFooter;
|
||||
51
src/components/studio-footer/messages.js
Normal file
@@ -0,0 +1,51 @@
|
||||
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',
|
||||
},
|
||||
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',
|
||||
},
|
||||
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',
|
||||
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,32 +1 @@
|
||||
import arMessages from './messages/ar.json';
|
||||
import caMessages from './messages/ca.json';
|
||||
// no need to import en messages-- they are in the defaultMessage field
|
||||
import es419Messages from './messages/es_419.json';
|
||||
import frMessages from './messages/fr.json';
|
||||
import zhcnMessages from './messages/zh_CN.json';
|
||||
import heMessages from './messages/he.json';
|
||||
import idMessages from './messages/id.json';
|
||||
import kokrMessages from './messages/ko_kr.json';
|
||||
import plMessages from './messages/pl.json';
|
||||
import ptbrMessages from './messages/pt_br.json';
|
||||
import ruMessages from './messages/ru.json';
|
||||
import thMessages from './messages/th.json';
|
||||
import ukMessages from './messages/uk.json';
|
||||
|
||||
const messages = {
|
||||
ar: arMessages,
|
||||
'es-419': es419Messages,
|
||||
fr: frMessages,
|
||||
'zh-cn': zhcnMessages,
|
||||
ca: caMessages,
|
||||
he: heMessages,
|
||||
id: idMessages,
|
||||
'ko-kr': kokrMessages,
|
||||
pl: plMessages,
|
||||
'pt-br': ptbrMessages,
|
||||
ru: ruMessages,
|
||||
th: thMessages,
|
||||
uk: ukMessages,
|
||||
};
|
||||
|
||||
export default messages;
|
||||
export default {};
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"footer.socialLinks.srText.facebook": "Like edX on Facebook",
|
||||
"footer.socialLinks.srText.twitter": "Follow edX on Twitter",
|
||||
"footer.socialLinks.srText.youtube": "Subscribe to the edX YouTube channel",
|
||||
"footer.socialLinks.srText.linkedin": "Follow edX on LinkedIn",
|
||||
"footer.socialLinks.srText.reddit": "Subscribe to the edX subreddit",
|
||||
"footer.languageForm.select.label": "Choose Language",
|
||||
"footer.languageForm.submit.label": "Apply",
|
||||
"footer.edxLinks.about": "About",
|
||||
"footer.edxLinks.business": "edX for Business",
|
||||
"footer.edxLinks.affiliates": "Affiliates",
|
||||
"footer.edxLinks.openEdx": "Open edX",
|
||||
"footer.edxLinks.careers": "Careers",
|
||||
"footer.edxLinks.news": "News",
|
||||
"footer.legalLinks.heading": "Legal",
|
||||
"footer.legalLinks.termsOfService": "Terms of Service & Honor Code",
|
||||
"footer.legalLinks.privacyPolicy": "Privacy Policy",
|
||||
"footer.legalLinks.a11yPolicy": "Accessibility Policy",
|
||||
"footer.legalLinks.trademarkPolicy": "Trademark Policy",
|
||||
"footer.legalLinks.sitemap": "Sitemap",
|
||||
"footer.connectLinks.heading": "Connect",
|
||||
"footer.connectLinks.blog": "Blog",
|
||||
"footer.connectLinks.contact": "Contact Us",
|
||||
"footer.connectLinks.help": "Help Center",
|
||||
"footer.connectLinks.mediaKit": "Media Kit",
|
||||
"footer.connectLinks.donate": "Donate",
|
||||
"footer.mobileApp.apple": "Download the edX mobile app from the Apple App Store",
|
||||
"footer.mobileApp.google": "Download the edX mobile app from Google Play",
|
||||
"footer.logo.altText": "Powered by Open edX",
|
||||
"footer.logo.ariaLabel": "edX Home",
|
||||
"footer.ariaLabel": "Page Footer"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"footer.socialLinks.srText.facebook": "Like edX on Facebook",
|
||||
"footer.socialLinks.srText.twitter": "Follow edX on Twitter",
|
||||
"footer.socialLinks.srText.youtube": "Subscribe to the edX YouTube channel",
|
||||
"footer.socialLinks.srText.linkedin": "Follow edX on LinkedIn",
|
||||
"footer.socialLinks.srText.reddit": "Subscribe to the edX subreddit",
|
||||
"footer.languageForm.select.label": "Choose Language",
|
||||
"footer.languageForm.submit.label": "Apply",
|
||||
"footer.edxLinks.about": "About",
|
||||
"footer.edxLinks.business": "edX for Business",
|
||||
"footer.edxLinks.affiliates": "Affiliates",
|
||||
"footer.edxLinks.openEdx": "Open edX",
|
||||
"footer.edxLinks.careers": "Careers",
|
||||
"footer.edxLinks.news": "News",
|
||||
"footer.legalLinks.heading": "Legal",
|
||||
"footer.legalLinks.termsOfService": "Terms of Service & Honor Code",
|
||||
"footer.legalLinks.privacyPolicy": "Privacy Policy",
|
||||
"footer.legalLinks.a11yPolicy": "Accessibility Policy",
|
||||
"footer.legalLinks.trademarkPolicy": "Trademark Policy",
|
||||
"footer.legalLinks.sitemap": "Sitemap",
|
||||
"footer.connectLinks.heading": "Connect",
|
||||
"footer.connectLinks.blog": "Blog",
|
||||
"footer.connectLinks.contact": "Contact Us",
|
||||
"footer.connectLinks.help": "Help Center",
|
||||
"footer.connectLinks.mediaKit": "Media Kit",
|
||||
"footer.connectLinks.donate": "Donate",
|
||||
"footer.mobileApp.apple": "Download the edX mobile app from the Apple App Store",
|
||||
"footer.mobileApp.google": "Download the edX mobile app from Google Play",
|
||||
"footer.logo.altText": "Powered by Open edX",
|
||||
"footer.logo.ariaLabel": "edX Home",
|
||||
"footer.ariaLabel": "Page Footer"
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"footer.socialLinks.srText.facebook": "Like edX on Facebook",
|
||||
"footer.socialLinks.srText.twitter": "Follow edX on Twitter",
|
||||
"footer.socialLinks.srText.youtube": "Subscribe to the edX YouTube channel",
|
||||
"footer.socialLinks.srText.linkedin": "Follow edX on LinkedIn",
|
||||
"footer.socialLinks.srText.reddit": "Subscribe to the edX subreddit",
|
||||
"footer.languageForm.select.label": "Choose Language",
|
||||
"footer.languageForm.submit.label": "Apply",
|
||||
"footer.edxLinks.about": "About",
|
||||
"footer.edxLinks.business": "edX for Business",
|
||||
"footer.edxLinks.affiliates": "Affiliates",
|
||||
"footer.edxLinks.openEdx": "Open edX",
|
||||
"footer.edxLinks.careers": "Careers",
|
||||
"footer.edxLinks.news": "News",
|
||||
"footer.legalLinks.heading": "Legal",
|
||||
"footer.legalLinks.termsOfService": "Terms of Service & Honor Code",
|
||||
"footer.legalLinks.privacyPolicy": "Privacy Policy",
|
||||
"footer.legalLinks.a11yPolicy": "Accessibility Policy",
|
||||
"footer.legalLinks.trademarkPolicy": "Trademark Policy",
|
||||
"footer.legalLinks.sitemap": "Sitemap",
|
||||
"footer.connectLinks.heading": "Connect",
|
||||
"footer.connectLinks.blog": "Blog",
|
||||
"footer.connectLinks.contact": "Contact Us",
|
||||
"footer.connectLinks.help": "Help Center",
|
||||
"footer.connectLinks.mediaKit": "Media Kit",
|
||||
"footer.connectLinks.donate": "Donate",
|
||||
"footer.mobileApp.apple": "Download the edX mobile app from the Apple App Store",
|
||||
"footer.mobileApp.google": "Download the edX mobile app from Google Play",
|
||||
"footer.logo.altText": "Powered by Open edX",
|
||||
"footer.logo.ariaLabel": "edX Home",
|
||||
"footer.ariaLabel": "Page Footer"
|
||||
}
|
||||
@@ -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,32 +0,0 @@
|
||||
{
|
||||
"footer.socialLinks.srText.facebook": "Like edX on Facebook",
|
||||
"footer.socialLinks.srText.twitter": "Follow edX on Twitter",
|
||||
"footer.socialLinks.srText.youtube": "Subscribe to the edX YouTube channel",
|
||||
"footer.socialLinks.srText.linkedin": "Follow edX on LinkedIn",
|
||||
"footer.socialLinks.srText.reddit": "Subscribe to the edX subreddit",
|
||||
"footer.languageForm.select.label": "Choose Language",
|
||||
"footer.languageForm.submit.label": "Apply",
|
||||
"footer.edxLinks.about": "About",
|
||||
"footer.edxLinks.business": "edX for Business",
|
||||
"footer.edxLinks.affiliates": "Affiliates",
|
||||
"footer.edxLinks.openEdx": "Open edX",
|
||||
"footer.edxLinks.careers": "Careers",
|
||||
"footer.edxLinks.news": "News",
|
||||
"footer.legalLinks.heading": "Legal",
|
||||
"footer.legalLinks.termsOfService": "Terms of Service & Honor Code",
|
||||
"footer.legalLinks.privacyPolicy": "Privacy Policy",
|
||||
"footer.legalLinks.a11yPolicy": "Accessibility Policy",
|
||||
"footer.legalLinks.trademarkPolicy": "Trademark Policy",
|
||||
"footer.legalLinks.sitemap": "Sitemap",
|
||||
"footer.connectLinks.heading": "Connect",
|
||||
"footer.connectLinks.blog": "Blog",
|
||||
"footer.connectLinks.contact": "Contact Us",
|
||||
"footer.connectLinks.help": "Help Center",
|
||||
"footer.connectLinks.mediaKit": "Media Kit",
|
||||
"footer.connectLinks.donate": "Donate",
|
||||
"footer.mobileApp.apple": "Download the edX mobile app from the Apple App Store",
|
||||
"footer.mobileApp.google": "Download the edX mobile app from Google Play",
|
||||
"footer.logo.altText": "Powered by Open edX",
|
||||
"footer.logo.ariaLabel": "edX Home",
|
||||
"footer.ariaLabel": "Page Footer"
|
||||
}
|
||||
@@ -1,5 +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 };
|
||||
export {
|
||||
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;
|
||||
@@ -1,8 +1,3 @@
|
||||
import Enzyme from 'enzyme';
|
||||
import Adapter from 'enzyme-adapter-react-16';
|
||||
|
||||
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,8 +1,10 @@
|
||||
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'),
|
||||
entry: {
|
||||
app: path.resolve(__dirname, 'example'),
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'example/dist'),
|
||||
publicPath: '/',
|
||||
|
||||