Compare commits

...

136 Commits

Author SHA1 Message Date
Stanislav Lunyachek
7ddc95003e fix: Remove extra margin around body element 2025-09-30 12:16:04 -03:00
Muhammad Anas
fa05fa25ab chore: bump frontend-component-header to v6.6.x 2025-09-30 11:55:12 -03:00
oleksandr.buhaienko
26099ea6d5 test: Remove support for Node 20 2025-09-26 10:35:39 -03:00
Feanil Patel
59dbee3fa9 Merge pull request #256 from openedx/feanil/remove-reactifex-packages
build: remove unused @edx/reactifex package
2025-09-25 13:15:44 -04:00
Feanil Patel
1c9e20e6a7 fix: Correct test parameters.
This test should be suppling a `courseModes` parameter not a
`courseMode` parameter with a missing `s`.
2025-09-25 10:13:24 -04:00
Feanil Patel
4af3a5a65a build: remove unused @edx/reactifex package
Remove @edx/reactifex package from devDependencies as it is no longer
needed. Translation extraction functionality has been verified to work
correctly without this dependency.

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 10:13:18 -04:00
PKulkoRaccoonGang
b106d0694f fix: fixed some problems with tests 2025-09-25 10:55:05 -03:00
oleksandr.buhaienko
ef6c498bb7 build: Upgrade to Node 24 2025-09-25 10:55:05 -03:00
edX requirements bot
70a40bf90b chore: update browserslist DB (#255)
Co-authored-by: arbrandes <759355+arbrandes@users.noreply.github.com>
2025-09-22 00:13:18 +00:00
bydawen
7727574280 test: Add Node 24 to CI matrix (#252) 2025-09-19 13:50:59 -04:00
edX requirements bot
51b8d7bac1 chore: update browserslist DB (#251)
Co-authored-by: arbrandes <759355+arbrandes@users.noreply.github.com>
2025-09-08 00:13:07 +00:00
Samuel Allan
95a3eb4959 fix: update frontend-build to fix install issues (#250)
Earlier versions of @openedx/frontend-build used on older version of
'sharp', which caused intermittent installation issues. The version of
'sharp' was updated in @openedx/frontend-build to fix these issues, so
the frontend-build version can be updated here, to fix the issues in
this project too. See
https://github.com/openedx/frontend-build/issues/664 and
https://github.com/openedx/frontend-build/pull/665 for more information.

The frontend-build dependency was updated by:

```
npm install --package-lock-only @openedx/frontend-build
```

Private-ref: https://tasks.opencraft.com/browse/BB-9953
2025-09-05 12:03:05 -06:00
edX requirements bot
975ab436ae chore: update browserslist DB (#249)
Co-authored-by: arbrandes <759355+arbrandes@users.noreply.github.com>
2025-09-01 00:14:46 +00:00
edX requirements bot
64b259a8a9 chore: update browserslist DB (#248)
Co-authored-by: arbrandes <759355+arbrandes@users.noreply.github.com>
2025-08-25 00:13:19 +00:00
edX requirements bot
795636f7a7 chore: update browserslist DB (#247)
Co-authored-by: arbrandes <759355+arbrandes@users.noreply.github.com>
2025-08-18 00:14:21 +00:00
Jacobo Dominguez
f8e2b3de03 refactor: replacing injectIntl with useIntl part 1 (#245) 2025-08-13 13:03:13 -04:00
Jacobo Dominguez
b5e4505665 refactor: replacing injectIntl with useIntl part 2 (#246) 2025-08-13 10:51:53 -04:00
edX requirements bot
74905663e1 chore: update browserslist DB (#241)
Co-authored-by: arbrandes <759355+arbrandes@users.noreply.github.com>
2025-07-07 00:14:01 +00:00
edX requirements bot
a1083d8142 chore: update browserslist DB (#240)
Co-authored-by: arbrandes <759355+arbrandes@users.noreply.github.com>
2025-06-30 00:13:54 +00:00
Brian Smith
20ef9002ec feat!: add design tokens support (#224)
BREAKING CHANGE: Pre-design-tokens theming is no longer supported.

Co-authored-by: Diana Olarte <dcoa@live.com>
2025-06-18 15:36:53 -04:00
edX requirements bot
d2cb5b5e1d chore: update browserslist DB (#237)
Co-authored-by: arbrandes <759355+arbrandes@users.noreply.github.com>
2025-06-16 00:13:32 +00:00
edX requirements bot
cd73b9992f chore: update browserslist DB (#235)
Co-authored-by: arbrandes <759355+arbrandes@users.noreply.github.com>
2025-06-09 00:14:00 +00:00
edX requirements bot
dd99ad7c57 chore: update browserslist DB (#234)
Co-authored-by: arbrandes <759355+arbrandes@users.noreply.github.com>
2025-06-02 00:13:44 +00:00
Brian Smith
f6dfc7f6cc fix(deps): update dependency @edx/frontend-platform to v8.3.7 (#232) 2025-05-19 11:06:25 -04:00
edX requirements bot
c3d9b62944 chore: update browserslist DB (#231)
Co-authored-by: arbrandes <759355+arbrandes@users.noreply.github.com>
2025-05-19 00:13:27 +00:00
edX requirements bot
c0a6133e78 chore: update browserslist DB (#230)
Co-authored-by: arbrandes <759355+arbrandes@users.noreply.github.com>
2025-05-12 00:13:22 +00:00
edX requirements bot
d62aa1df5a chore: update browserslist DB (#229)
Co-authored-by: arbrandes <759355+arbrandes@users.noreply.github.com>
2025-05-05 00:13:21 +00:00
Brian Smith
0c1eb6cae0 feat: import FooterSlot from component package instead of slot package (#226) 2025-04-24 12:10:52 -04:00
Brian Smith
16738335d0 fix(deps): update frontend-component-header to ^6.4.0 (#228) 2025-04-23 17:05:36 -04:00
edX requirements bot
658b70e455 chore: update browserslist DB (#227)
Co-authored-by: arbrandes <759355+arbrandes@users.noreply.github.com>
2025-04-21 00:13:06 +00:00
edX requirements bot
6cb174b146 chore: update browserslist DB (#225)
Co-authored-by: arbrandes <759355+arbrandes@users.noreply.github.com>
2025-04-14 00:13:07 +00:00
edX requirements bot
143f0dcd4b chore: update browserslist DB (#222)
Co-authored-by: arbrandes <759355+arbrandes@users.noreply.github.com>
2025-04-07 00:12:44 +00:00
Brian Smith
ad19426aee feat: upgrade to react 18 (#219) 2025-04-04 13:46:15 -04:00
Régis Behmo
5ab646b69c chore: remove husky 🪓🐶 (#220) 2025-04-04 05:13:54 -04:00
Brian Smith
1cd02a9dfb chore: update @openedx dependencies to versions that support React 18 (#218) 2025-03-27 16:15:55 -04:00
Feanil Patel
445a2f6cd3 Merge pull request #215 from salman2013/salman/update-catalog-info-file
Update catalog-info file for release data
2025-02-11 14:26:35 -05:00
salman2013
166b6fe7ae fix: remove openedx.yaml file 2025-02-11 13:56:57 +05:00
salman2013
a6711a59dc chore: update catalog-info file for release data 2025-01-31 17:11:48 +05:00
Muhammad Anas
454d3ddcdf test: Remove support for Node 18 (#213) 2024-10-31 14:44:39 -04:00
Brian Smith
e4a7448850 feat(deps): update header to 5.6.0 (#214) 2024-10-22 19:19:01 -04:00
Muhammad Anas
1fd3343355 build: Upgrade to Node 20 (#211)
* build: Upgrade to Node 20

* refactor: updated package-lock

* refactor: updated the lockfile version workflow
2024-09-06 12:23:17 -04:00
Muhammad Anas
ef6ade6de1 test: Add Node 20 to CI matrix (#210) 2024-09-03 14:31:42 -04:00
Braden MacDonald
7dc08c060f chore: remove reference to deprecated frontend-lib-content-components repo (#209) 2024-09-03 10:00:30 -07:00
Bilal Qamar
1e1f269b6b feat: updated frontend-build & frontend-platform major versions (#181)
* chore: bumped jest to v29

* refactor: updated frontend-build & added overrides

* feat: updated build and platform major versions, along with edx packages

* refactor: added caret to frontend-platform version
2024-08-06 15:36:25 +05:00
Emad Rad
a8093439a9 fix: update README.rst (#208)
Ffix typos, add code-blocks and highlighting for better readability
2024-07-24 11:51:29 -07:00
Adolfo R. Brandes
10f906b72f build: Update codecov and use token
Update codecov to the latest version and start using the org-wide token for uploads.

See https://github.com/openedx/wg-frontend/issues/179
2024-06-17 12:02:35 -03:00
Brian Smith
3a14119d01 fix: import FooterSlot from frontend-slot-footer package 2024-05-17 09:37:27 -03:00
Brian Smith
cb3b2b4670 feat: use frontend-plugin-framework to provide a FooterSlot 2024-05-09 16:54:37 -03:00
sundasnoreen12
9279a3e4ce Merge pull request #200 from openedx/sundas/INF-1278
feat: remove Transifex calls for OEP-58 for communication app
2024-03-22 14:15:34 +05:00
sundasnoreen12
2a5cf010f8 feat: remove Transifex calls for OEP-58 for communication app 2024-03-21 23:23:59 +05:00
eemaanamir
6dd835d63f refactor: converted functions to memos for best practice 2024-03-06 09:15:44 -03:00
eemaanamir
87c1cb5bd2 test: updated tests for both components to accommodate changes 2024-03-06 09:15:44 -03:00
eemaanamir
5875631a6c refactor: updated code according to best practices 2024-03-06 09:15:44 -03:00
eemaanamir
176a95c352 fix: converted UTC time to localtime in all the bulk email history tables 2024-03-06 09:15:44 -03:00
Kyle McCormick
b24971572d build: update catalog-info team frontend-all to committers-frontend
per https://openedx.atlassian.net/wiki/spaces/COMM/pages/3555852316/GitHub+Access+Team+Structure
2024-03-01 13:00:31 -03:00
Taras Lytvynenko
20f212501f fix: Added maxLength and default tip for email subject (#154)
* fix: Added maxLength and default tip for email subject

* fix: lint
2024-02-27 15:14:56 -03:00
Eugene Dyudyunov
852d0ef2d9 refactor: apply review suggestions 2024-02-27 15:00:14 -03:00
Taras Lytvynenko
809112d4b2 docs: Unnecessary comment deleted 2024-02-27 15:00:14 -03:00
Taras Lytvynenko
d249b5e4aa fix: Logical operations moved into a separate variable 2024-02-27 15:00:14 -03:00
Taras Lytvynenko
dad6c84d46 fix: Course mode is used to show the correct bulk email options 2024-02-27 15:00:14 -03:00
Brian Smith
5f61578e28 chore(deps): update paragon and frontend-build to openedx scope (#190) 2024-01-22 17:23:16 -05:00
Omar Al-Ithawi
da30730662 chore: bump openedx-atlas==0.6.0 (#189) 2024-01-17 11:50:29 -05:00
Omar Al-Ithawi
6e4ae9d976 feat: add ATLAS_OPTIONS and lib-components and frontend-platform deps (#187) 2024-01-09 11:51:56 -05:00
arbrandes
e863eef77d chore: update browserslist DB 2023-12-15 14:57:36 -03:00
arbrandes
ff900335a1 chore: update browserslist DB 2023-12-04 11:23:40 -03:00
arbrandes
c0dc0cbad6 chore: update browserslist DB 2023-11-28 11:42:45 -03:00
arbrandes
83aec7318e chore: update browserslist DB 2023-11-20 12:31:27 -03:00
Ihor Romaniuk
a037f5b340 fix: date format depends on locale date format (#175) 2023-11-16 07:05:57 -03:00
Omar Al-Ithawi
91402fbf12 feat!: remove broken transifex and use atlas exclusively | FC-0012 (#164)
* feat!: remove broken transifex and use atlas exclusively

* feat: install openedx-atlas
2023-11-15 15:10:50 -05:00
o.bugaenko
7a299eb064 fix: wrong id placement on the h1 tag 2023-11-14 16:13:56 -03:00
arbrandes
90e8eeeb50 chore: update browserslist DB 2023-11-14 13:04:20 -03:00
vladislavkeblysh
f25ce0b95d feat: fixed layout 2023-11-14 12:32:37 -03:00
Stanislav Lunyachek
98db1a4a35 fix: Missed favicon in Safari 2023-11-14 12:23:58 -03:00
Muhammad Abdullah Waheed
cf4b632c55 feat: babel-plugin-react-intl to babel-plugin-formatjs migration (#151)
* feat: babel-plugin-react-intl to babel-plugin-formatjs migration

* fix: upgraded frontend-build to fix security issue
2023-11-14 12:58:07 +05:00
Mashal Malik
0720b2feae refactor: add @openedx in renovate automate configuration (#150) 2023-11-01 12:38:32 -03:00
Jason Wesson
56e1781004 Merge pull request #145 from openedx/update-browserslist-db
Update browserslist DB
2023-10-23 13:07:18 -07:00
arbrandes
83eb21bb9a chore: update browserslist DB 2023-10-23 00:07:35 +00:00
Feanil Patel
18ddb35e1e chore: Update to the new version of brand-openedx in the new scope. (#165)
Part of https://github.com/openedx/axim-engineering/issues/23

This updates the `@edx/brand` alias to point to the `brand-openedx` package at
the `openedx` scope. This does not impact imports because this package is used
via an alias.
2023-10-20 17:26:49 -04:00
Syed Ali Abbas Zaidi
ae93b68d57 chore: bump frontend-platform (#158) 2023-10-12 18:41:58 +05:00
mashal-m
7ce2a61233 refactor: update lock file version 2023-09-22 10:49:43 -03:00
Awais Ansari
2de12997ce Merge pull request #122 from openedx/Ali-Abbas/react-router-upgrade
feat: upgrade react router to v6
2023-09-05 18:10:45 +05:00
Syed Ali Abbas Zaidi
f6c8cfa906 build: update header and footer 2023-08-21 17:22:24 +05:00
Syed Ali Abbas Zaidi
db181a7945 Merge branch 'master' of github.com:openedx/frontend-app-communications into Ali-Abbas/react-router-upgrade 2023-08-08 16:38:54 +05:00
arbrandes
840449f71b chore: update browserslist DB 2023-07-31 16:38:23 +01:00
Adolfo R. Brandes
01f1793414 chore: add catalog-info.yaml 2023-07-31 16:36:18 +01:00
Jhon Vente
ce45c8012d [DOCS] Readme updated according OEP-55 (#141)
* docs: readme updated with frontend-template-app readme ref
* fix: change main branch to master, spelling and getting help url
2023-07-07 08:49:27 -04:00
edX requirements bot
7224785682 chore: update browserslist DB (#142)
Co-authored-by: justinhynes <justinhynes@users.noreply.github.com>
2023-07-06 13:38:59 -04:00
Bilal Qamar
6d27b7082d feat: update react & react-dom to v17 (#131)
* feat: update react & react-dom to v17
* build: update paragon version
* refactor: updated edx packages
---------
Co-authored-by: mashal-m <mashal.malik@arbisoft.com>
2023-07-06 12:28:41 -04:00
edX requirements bot
c90bdb1ac7 chore: update browserslist DB (#132)
Co-authored-by: arbrandes <arbrandes@users.noreply.github.com>
2023-06-21 13:09:55 -04:00
Adolfo R. Brandes
090968e2f2 feat: Runtime config support, take 2
Adds a couple of missing features for proper runtime configuration:

1. Favicon runtime configuration support via react-helmet

2. Placeholder values for APP_ID and MFE_CONFIG_API_URL in the sample
   .env files
2023-06-14 15:33:43 +01:00
Tobias Macey
765857f380 fix: Disable URL rewriting when creating links
The default behavior of the TinyMCE editor is to rewrite links that share the same
domain as the component to be relative to that path. Relative URLs will never work in
email contents, so they _always_ need to be absolute URLs. This adds the configuration
settings for `relative_urls` and `remove_script_host` in TinyMCE to always be false,
enabling it to always use absolute URLs. See
[here](https://www.tiny.cloud/docs/configure/url-handling/) for reference.
2023-06-12 19:18:12 +01:00
edX requirements bot
0eec29a458 chore: update browserslist DB (#128)
Co-authored-by: arbrandes <arbrandes@users.noreply.github.com>
2023-06-05 15:06:12 -04:00
Mashal Malik
c2b4d04b5d Migrate off paragon modal deprecated component (#95)
* refactor: migrate off paragon modal deprecated component

* refactor: migrate off paragon modal deprecated component

* refactor: resource the close button string

* refactor: remove extra file

* refactor: add message in messages  file
2023-06-05 14:47:53 -04:00
Ghassan Maslamani
a198557e67 fix: getting course-id when public path is set (#127) 2023-06-01 14:30:35 -03:00
Muhammad Abdullah Waheed
4493eb71fa feat: automate browserlist DB update (#92) 2023-05-23 10:08:33 -03:00
Adolfo R. Brandes
559a1061b6 Merge pull request #125 from arbrandes/runtime-config 2023-05-23 08:54:59 -03:00
Adolfo R. Brandes
53fa594207 feat: Support runtime configuration
frontend-platform supports runtime configuration since 2.5.0 (see the PR
that introduced it[1], but it requires MFE cooperation.  This implements
just that: by avoiding making configuration values constant, it should
now be possible to change them after initialization.

Only a single change related to the `LMS_BASE_URL` setting was required.

[1] openedx/frontend-platform#335
2023-05-22 10:00:22 -03:00
Mashal Malik
0c34d86610 feat: upgrade to node v18 and related fixes (#123) 2023-05-17 14:19:00 -03:00
Syed Ali Abbas Zaidi
05d16cf231 Merge branch 'master' of github.com:openedx/frontend-app-communications into Ali-Abbas/react-router-upgrade 2023-05-16 16:13:15 +05:00
Omar Al-Ithawi
55a0ddb8d2 feat: use atlas in make pull_translations (#124)
Changes
-------
 - Bump frontend-platform to bring intl-imports.js script
 - Move all i18n imports into `src/i18n/index.js` so intl-imports.js can
   override it with latest translations
 - Add `atlas` into `make pull_translations` when `OPENEDX_ATLAS_PULL`
   environment variable is set.
 - Fixed lint rules for frontend-platform@4.1.0
 - Mock useTrackColorSchemeChoice to avoid test failures

Refs: [FC-0012 project](https://openedx.atlassian.net/l/cp/XGS0iCcQ) implementing Translation Infrastructure OEP-58.
2023-05-09 10:08:36 -04:00
Mashal Malik
344b68e10e Update transifex api from v2 to v3 (#119)
* fix: fix conflicts

* refactor: remove duplicate line

* fix: update lock file
2023-03-24 12:48:12 +05:00
Mashal Malik
631d47b286 fix: remove unused codecov pkg (#120) 2023-03-24 12:45:37 +05:00
Syed Ali Abbas Zaidi
81a5f89f36 feat: upgrade react router to v6 2023-03-21 14:26:08 +05:00
Justin Hynes
fd3a49d7c6 Merge pull request #50 from openedx/renovate/npm-ejs-vulnerability
chore(deps): update dependency ejs to 3.1.7 [security]
2023-03-09 13:39:54 -05:00
renovate[bot]
a2b2d55db0 chore(deps): update dependency ejs to 3.1.7 [security]
* ignore lint errors (for now) to prioritize getting an updated version of the Comms MFE out with a compromised dependency
2023-03-09 13:27:42 -05:00
Sarina Canelake
fca2cce77c Merge pull request #118 from openedx/repo_checks/ensure_workflows
Update standard workflow files.
2023-02-28 09:35:03 -05:00
Jason Wesson
0dc2e65f60 Merge pull request #90 from openedx/renovate/edx-frontend-component-footer-11.x
fix(deps): update dependency @edx/frontend-component-footer to v11.6.0
2023-02-24 14:14:00 -08:00
Jason Wesson
cddc28c34f Merge pull request #108 from openedx/renovate/actions-setup-node-3.x
chore(deps): update actions/setup-node action to v3
2023-02-24 14:06:20 -08:00
Jason Wesson
56ca914fb4 Merge pull request #111 from openedx/renovate/codecov-codecov-action-3.x
chore(deps): update codecov/codecov-action action to v3
2023-02-24 13:45:32 -08:00
Jason Wesson
1ea43e0ad4 Merge pull request #106 from openedx/renovate/actions-checkout-3.x
chore(deps): update actions/checkout action to v3
2023-02-24 13:40:32 -08:00
Feanil Patel
9d25d6e4d0 build: Creating a missing workflow file add-remove-label-on-comment.yml.
The .github/workflows/add-remove-label-on-comment.yml workflow is missing or needs an update to stay in
sync with the current standard for this workflow as defined in the
`.github` repo of the `openedx` GitHub org.
2023-02-23 11:07:08 -05:00
Feanil Patel
2888cb6662 build: Creating a missing workflow file add-depr-ticket-to-depr-board.yml.
The .github/workflows/add-depr-ticket-to-depr-board.yml workflow is missing or needs an update to stay in
sync with the current standard for this workflow as defined in the
`.github` repo of the `openedx` GitHub org.
2023-02-23 11:07:08 -05:00
Feanil Patel
418c78d1f3 build: Creating a missing workflow file self-assign-issue.yml.
The .github/workflows/self-assign-issue.yml workflow is missing or needs an update to stay in
sync with the current standard for this workflow as defined in the
`.github` repo of the `openedx` GitHub org.
2023-02-23 11:07:07 -05:00
Mashal Malik
4231093347 Merge pull request #117 from Mashal-m/mashal-m/major-paragon-version-upgrade
build: major version upgrade of paragon
2022-12-28 11:43:57 +05:00
Muhammad Abdullah Waheed
b5b90272f8 refactor: updated renovate config to auto update minor and patch versions of edx dependencies (#74) 2022-12-20 13:19:32 +05:00
mashal-m
a08d30fbbb build: major version upgrade of paragon 2022-12-20 12:37:21 +05:00
mashal-m
ece65c83ad build: use shared browserslist configuration 2022-12-16 12:38:58 -05:00
renovate[bot]
fd98b4468e chore(deps): update codecov/codecov-action action to v3 2022-12-12 12:27:36 +00:00
renovate[bot]
4a8df3b50e chore(deps): update actions/setup-node action to v3 2022-12-12 12:27:28 +00:00
renovate[bot]
35f755ccf1 chore(deps): update actions/checkout action to v3 2022-12-12 12:27:22 +00:00
renovate[bot]
6b4bd3b534 fix(deps): update dependency @edx/frontend-component-footer to v11.6.0 2022-12-12 12:27:14 +00:00
renovate[bot]
2d9d195936 fix(deps): update dependency tinymce to v5.10.7 2022-12-12 12:22:24 +00:00
renovate[bot]
1082b27647 chore(deps): update dependency prettier to v2.8.1 2022-12-12 09:54:24 +00:00
Tim McCormack
9782cf108f build: Remove community-engineering CODEOWNERS (#112)
Team no longer exists. See <https://github.com/edx/edx-arch-experiments/issues/132>.
2022-12-09 19:41:48 +00:00
renovate[bot]
466fac7e9e fix(deps): update dependency @edx/frontend-component-header to v3.5.0 2022-12-05 11:02:31 +00:00
renovate[bot]
422632c582 chore(deps): update dependency prettier to v2.8.0 2022-11-28 09:19:27 +00:00
renovate[bot]
67b6512288 fix(deps): update dependency regenerator-runtime to v0.13.11 2022-11-21 10:26:48 +00:00
renovate[bot]
13ba06fd2a fix(deps): update dependency @edx/frontend-component-header to v3.4.1 2022-11-15 00:07:05 +00:00
renovate[bot]
61a2a4e8c9 fix(deps): update dependency core-js to v3.26.1 2022-11-14 08:47:19 +00:00
renovate[bot]
e112c3a6d1 fix(deps): update react-router monorepo to v5.3.4 2022-11-07 11:41:03 +00:00
renovate[bot]
97a21b9574 fix(deps): update dependency core-js to v3.26.0 2022-11-07 08:15:48 +00:00
Zubair Shakoor
22675fd17a fix: -t flag added in pull translation command (#100) 2022-10-28 14:54:27 +05:00
renovate[bot]
32327cde93 fix(deps): update dependency @edx/frontend-component-header to v3.3.0 2022-10-24 11:00:17 +00:00
renovate[bot]
dadbfed8e1 fix(deps): update dependency tinymce to v5.10.6 2022-10-24 07:14:55 +00:00
renovate[bot]
262ea5be0d fix(deps): update dependency redux to v4.2.0 2022-10-17 10:57:56 +00:00
renovate[bot]
fcb393d9e7 fix(deps): update dependency regenerator-runtime to v0.13.10 2022-10-17 07:58:39 +00:00
86 changed files with 15046 additions and 41871 deletions

4
.env
View File

@@ -19,3 +19,7 @@ SEGMENT_KEY=''
SITE_NAME=''
USER_INFO_COOKIE_NAME=''
SCHEDULE_EMAIL_SECTION=''
APP_ID=''
MFE_CONFIG_API_URL=''
# Fallback in local style files
PARAGON_THEME_URLS={}

View File

@@ -20,3 +20,7 @@ SEGMENT_KEY=''
SITE_NAME=localhost
USER_INFO_COOKIE_NAME='edx-user-info'
SCHEDULE_EMAIL_SECTION='true'
APP_ID=''
MFE_CONFIG_API_URL=''
# Fallback in local style files
PARAGON_THEME_URLS={}

View File

@@ -18,3 +18,6 @@ SEGMENT_KEY=''
SITE_NAME=localhost
USER_INFO_COOKIE_NAME='edx-user-info'
SCHEDULE_EMAIL_SECTION='true'
APP_ID=''
MFE_CONFIG_API_URL=''
PARAGON_THEME_URLS={}

View File

@@ -1,3 +1,9 @@
const { createConfig } = require('@edx/frontend-build');
/* eslint-disable import/no-extraneous-dependencies */
module.exports = createConfig('eslint');
const { createConfig } = require('@openedx/frontend-build');
module.exports = createConfig('eslint', {
rules: {
'react/function-component-definition': 'off',
},
});

1
.github/CODEOWNERS vendored
View File

@@ -1 +0,0 @@
* @edx/community-engineering

View File

@@ -0,0 +1,19 @@
# Run the workflow that adds new tickets that are either:
# - labelled "DEPR"
# - title starts with "[DEPR]"
# - body starts with "Proposal Date" (this is the first template field)
# to the org-wide DEPR project board
name: Add newly created DEPR issues to the DEPR project board
on:
issues:
types: [opened]
jobs:
routeissue:
uses: openedx/.github/.github/workflows/add-depr-ticket-to-depr-board.yml@master
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 }}

View 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

View File

@@ -9,18 +9,18 @@ on:
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
node: [16]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Nodejs Env
run: echo "NODE_VER=`cat .nvmrc`" >> $GITHUB_ENV
- 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
@@ -33,7 +33,8 @@ jobs:
run: npm run build
- name: i18n_extract
run: npm run i18n_extract
- name: is-es5
run: npm run is-es5
- name: Coverage
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true

View File

@@ -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

12
.github/workflows/self-assign-issue.yml vendored Normal file
View 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

View File

@@ -0,0 +1,12 @@
name: Update Browserslist DB
on:
schedule:
- cron: '0 0 * * 1'
workflow_dispatch:
jobs:
update-browserslist:
uses: openedx/.github/.github/workflows/update-browserslist-db.yml@master
secrets:
requirements_bot_github_token: ${{ secrets.requirements_bot_github_token }}

2
.gitignore vendored
View File

@@ -5,6 +5,7 @@ node_modules
npm-debug.log
coverage
module.config.js
env.config.*
dist/
src/i18n/transifex_input.json
@@ -17,3 +18,4 @@ temp/babel-plugin-react-intl
*~
/temp
/.vscode
src/i18n/messages/

3
.nvmrc
View File

@@ -1,2 +1 @@
16
24

View File

@@ -1,21 +1,17 @@
transifex_resource = frontend-app-communications
transifex_langs = "ar,fr,es_419,zh_CN"
intl_imports = ./node_modules/.bin/intl-imports.js
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
precommit:
npm run lint
npm audit
requirements:
npm install
npm ci
i18n.extract:
# Pulling display strings from .jsx files into .json files...
@@ -33,20 +29,18 @@ 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)
rm -rf src/i18n/messages
mkdir src/i18n/messages
cd src/i18n/messages \
&& atlas pull $(ATLAS_OPTIONS) \
translations/frontend-component-header/src/i18n/messages:frontend-component-header \
translations/frontend-component-footer/src/i18n/messages:frontend-component-footer \
translations/paragon/src/i18n/messages:paragon \
translations/frontend-platform/src/i18n/messages:frontend-platform \
translations/frontend-app-communications/src/i18n/messages:frontend-app-communications
$(intl_imports) frontend-component-header frontend-component-footer paragon frontend-platform frontend-app-communications
# This target is used by Travis.
validate-no-uncommitted-package-lock-changes:

View File

@@ -1,55 +1,62 @@
|Codecov| |license|
.. |codecov| image:: https://codecov.io/gh/edx/frontend-app-learning/branch/master/graph/badge.svg?token=3z7XvuzTq3
:target: https://codecov.io/gh/edx/frontend-app-communications
.. |license| image:: https://img.shields.io/badge/license-AGPL-informational
:target: https://github.com/edx/frontend-app-account/blob/master/LICENSE
frontend-app-communications
==============================
###########################
Please tag **edx-aperture** on any PRs or issues. Thanks!
|license-badge| |status-badge| |ci-badge| |codecov-badge|
Introduction
------------
A tool used by course teams to communicate with thier learners. The interface for anything related to instructor to learner communications. Instructor bulk email, for example.
Purpose
*******
A tool used by course teams to communicate with their learners. The interface for anything related to instructor-to-learner communications. Instructor bulk email, for example.
Getting started
------------
---------------
For now, this repo is not intergrated with devstack. You'll be running the app locally and not through docker. This does make setup a little easier.
For now, this repo is not integrated with devstack. You'll be running the app locally and not through docker. This does make setup a little easier.
1. Clone the repo into your usual workspace
Cloning and Startup
===================
.. code-block::
1. Clone your new repo:
mkdir -p ~/workspace/
cd ~/workspace/
git clone https://github.com/edx/frontend-app-communications.git
.. code-block:: bash
2. Install frontend dependencies
git clone https://github.com/edx/frontend-app-communications.git
.. code-block::
2. Use node v18.x.
npm i
The current version of the micro-frontend build scripts supports node 18.
Using other major versions of node *may* work, but this is unsupported. For
convenience, this repository includes a ``.nvmrc`` file to help in setting the
correct node version via `nvm <https://github.com/nvm-sh/nvm>`_.
3. Start the devserver. The app will be running at ``localhost:1984``, or whatever port you change it too.
3. Install npm dependencies:
.. code-block::
.. code-block:: bash
cd frontend-app-communications && npm install
4. Update the application port to use for local development:
The default port is 1984. If this does not work for you, update the line
``PORT=1984`` to your port in all ``.env.*`` files
5. Start the devserver. The app will be running at ``localhost:1984``, or whatever port you change it too.
.. code-block:: bash
npm start
Environment Variables/Setup Notes
---------------------------------
If you wish to add new environment varibles for local testing, they should be listed in 2 places:
If you wish to add new environment variables for local testing, they should be listed in 2 places:
1. In ``.env.development``
2. Added to the ``mergeConfig`` found in ``src/index.jsx``
.. code-block::
.. code-block:: jsx
initialize({
config: () => {
@@ -58,10 +65,108 @@ If you wish to add new environment varibles for local testing, they should be li
}, 'CommuncationsAppConfig');
Running Tests
---------------------------
-------------
Tests use `jest` and `react-test-library`. To run all the tests for this repo:
.. code-block::
.. code-block::
npm test
npm test
Plugins
=======
This MFE can be customized using `Frontend Plugin Framework <https://github.com/openedx/frontend-plugin-framework>`_.
The parts of this MFE that can be customized in that manner are documented `here </src/plugin-slots>`_.
**Production Build**
The production build is created with ``npm run build``.
Internationalization
====================
Please refer to the `frontend-platform i18n howto`_ for documentation on
internationalization.
.. _frontend-platform i18n howto: https://github.com/openedx/frontend-platform/blob/master/docs/how_tos/i18n.rst
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-app-communications/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
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.
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/
People
******
The assigned maintainers for this component and other project details may be
found in `Backstage`_. Backstage pulls this data from the ``catalog-info.yaml``
file in this repo.
.. _Backstage: https://open-edx-backstage.herokuapp.com/catalog/default/component/frontend-app-communications
Reporting Security Issues
*************************
Please do not report security issues in public, and email security@openedx.org instead.
.. |license-badge| image:: https://img.shields.io/github/license/openedx/frontend-app-communications.svg
:target: https://github.com/openedx/frontend-app-communications/blob/master/LICENSE
:alt: License
.. |status-badge| image:: https://img.shields.io/badge/Status-Maintained-brightgreen
.. |ci-badge| image:: https://github.com/openedx/frontend-app-communications/actions/workflows/ci.yml/badge.svg
:target: https://github.com/openedx/frontend-app-communications/actions/workflows/ci.yml
:alt: Continuous Integration
.. |codecov-badge| image:: https://codecov.io/github/openedx/frontend-app-communications/coverage.svg?branch=master
:target: https://codecov.io/github/openedx/frontend-app-communications?branch=master
:alt: Codecov

19
catalog-info.yaml Normal file
View File

@@ -0,0 +1,19 @@
# 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-app-communications"
description: "A tool used by course teams to communicate with their learners."
links:
- url: "https://github.com/openedx/frontend-app-communications/blob/master/README.rst"
title: "README"
icon: "Article"
annotations:
openedx.org/arch-interest-groups: ""
openedx.org/release: "master"
spec:
owner: group:committers-frontend
type: "service"
lifecycle: "production"

View File

@@ -1,4 +1,4 @@
const { createConfig } = require('@edx/frontend-build');
const { createConfig } = require('@openedx/frontend-build');
module.exports = createConfig('jest', {
// setupFilesAfterEnv is used after the jest environment has been loaded. In general this is what you want.

View File

@@ -23,9 +23,9 @@ module.exports = {
**********************************************************************************************/
// { moduleName: '@edx/brand', dir: '../brand-openedx' }, // replace with your brand checkout
// { moduleName: '@edx/paragon/scss/core', dir: '../paragon', dist: 'scss/core' },
// { moduleName: '@edx/paragon/icons', dir: '../paragon', dist: 'icons' },
// { moduleName: '@edx/paragon', dir: '../paragon', dist: 'dist' },
// { moduleName: '@openedx/paragon/scss/core', dir: '../paragon', dist: 'scss/core' },
// { moduleName: '@openedx/paragon/icons', dir: '../paragon', dist: 'icons' },
// { moduleName: '@openedx/paragon', dir: '../paragon', dist: 'dist' },
// { moduleName: '@edx/frontend-platform', dir: '../frontend-platform', dist: 'dist' },
],
};

View File

@@ -1,9 +0,0 @@
# This file describes this Open edX repo, as described in OEP-2:
# http://open-edx-proposals.readthedocs.io/en/latest/oeps/oep-0002.html#specification
oeps: {}
openedx-release:
# The openedx-release key is described in OEP-10:
# https://open-edx-proposals.readthedocs.io/en/latest/oep-0010-proc-openedx-releases.html
# The FAQ might also be helpful: https://openedx.atlassian.net/wiki/spaces/COMM/pages/1331268879/Open+edX+Release+FAQ
ref: master

55325
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -7,24 +7,18 @@
"url": "git+https://github.com/edx/frontend-app-communications.git"
},
"browserslist": [
"last 2 versions",
"ie 11"
"extends @edx/browserslist-config"
],
"scripts": {
"build": "fedx-scripts webpack",
"i18n_extract": "BABEL_ENV=i18n fedx-scripts babel src --quiet > /dev/null",
"is-es5": "es-check es5 ./dist/*.js",
"lint": "fedx-scripts eslint --ext .js --ext .jsx .",
"lint:fix": "fedx-scripts eslint --fix --ext .js --ext .jsx .",
"i18n_extract": "fedx-scripts formatjs extract",
"lint": "fedx-scripts eslint --ext .js --ext .jsx src/",
"lint:fix": "fedx-scripts eslint --fix --ext .js --ext .jsx src/",
"snapshot": "fedx-scripts jest --updateSnapshot",
"start": "fedx-scripts webpack-dev-server --progress",
"dev": "PUBLIC_PATH=/communications/ MFE_CONFIG_API_URL='http://localhost:8000/api/mfe_config/v1' fedx-scripts webpack-dev-server --progress --host apps.local.openedx.io",
"test": "TZ=UTC fedx-scripts jest --coverage --passWithNoTests"
},
"husky": {
"hooks": {
"pre-commit": "npm run lint"
}
},
"author": "edX",
"license": "AGPL-3.0",
"homepage": "https://github.com/edx/frontend-app-communications#readme",
@@ -35,45 +29,46 @@
"url": "https://github.com/edx/frontend-app-communications/issues"
},
"dependencies": {
"@edx/brand": "npm:@edx/brand-openedx@1.1.0",
"@edx/frontend-component-footer": "11.2.1",
"@edx/frontend-component-header": "3.2.1",
"@edx/frontend-platform": "2.6.2",
"@edx/paragon": "19.25.3",
"@edx/brand": "npm:@openedx/brand-openedx@^1.2.2",
"@edx/frontend-component-footer": "^14.6.0",
"@edx/frontend-component-header": "^6.6.1",
"@edx/frontend-platform": "^8.3.7",
"@edx/openedx-atlas": "^0.6.0",
"@edx/tinymce-language-selector": "1.1.0",
"@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",
"@openedx/frontend-plugin-framework": "^1.6.0",
"@openedx/paragon": "^23.3.0",
"@tinymce/tinymce-react": "3.14.0",
"axios": "0.27.2",
"classnames": "2.3.2",
"core-js": "3.25.5",
"core-js": "3.26.1",
"jquery": "3.6.1",
"popper.js": "1.16.1",
"prop-types": "15.8.1",
"react": "16.14.0",
"react-dom": "16.14.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-helmet": "^6.1.0",
"react-redux": "7.2.9",
"react-router": "5.2.1",
"react-router-dom": "5.3.0",
"redux": "4.1.2",
"regenerator-runtime": "0.13.9",
"tinymce": "5.10.5"
"react-router": "6.15.0",
"react-router-dom": "6.15.0",
"redux": "4.2.0",
"regenerator-runtime": "0.13.11",
"tinymce": "5.10.7"
},
"devDependencies": {
"@edx/frontend-build": "9.2.2",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "12.1.5",
"@edx/browserslist-config": "^1.2.0",
"@edx/typescript-config": "^1.1.0",
"@openedx/frontend-build": "^14.6.2",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.2.0",
"axios-mock-adapter": "1.21.2",
"codecov": "3.8.3",
"es-check": "6.2.1",
"glob": "7.2.3",
"husky": "7.0.4",
"jest": "27.5.1",
"prettier": "2.7.1",
"reactifex": "1.1.1",
"jest": "29.7.0",
"prettier": "2.8.1",
"rosie": "2.1.0"
}
}

View File

@@ -22,6 +22,11 @@
"pin"
],
"automerge": true
},
{
"matchPackagePatterns": ["@edx", "@openedx"],
"matchUpdateTypes": ["minor", "patch"],
"automerge": true
}
],
"timezone": "America/New_York"

View File

@@ -0,0 +1,38 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`app registry subscribe: APP_INIT_ERROR. snapshot: displays an ErrorPage to root element 1`] = `
<UNDEFINED>
<ErrorPage
message="test-error-message"
/>
</UNDEFINED>
`;
exports[`app registry subscribe: APP_READY. links App to root element 1`] = `
<UNDEFINED>
<AppProvider>
<HelmetWrapper
defer={true}
encodeSpecialCharacters={true}
>
<link
href="favicon-url"
rel="shortcut icon"
type="image/x-icon"
/>
</HelmetWrapper>
<Routes>
<Route
element={
<AuthenticatedPageRoute>
<Page Container>
<Bulk Email Tool />
</Page Container>
</AuthenticatedPageRoute>
}
path="/courses/:courseId/bulk_email"
/>
</Routes>
</AppProvider>
</UNDEFINED>
`;

View File

@@ -3,7 +3,7 @@ import React from 'react';
import { useParams } from 'react-router-dom';
import { ErrorPage } from '@edx/frontend-platform/react';
import { Container } from '@edx/paragon';
import { Container } from '@openedx/paragon';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import BulkEmailTaskManager from './bulk-email-task-manager/BulkEmailTaskManager';
import NavigationTabs from '../navigation-tabs/NavigationTabs';
@@ -22,9 +22,9 @@ export default function BulkEmailTool() {
<NavigationTabs courseId={courseId} tabData={courseMetadata.tabs} />
<BulkEmailProvider>
<Container size="md">
<BackToInstructor />
<BackToInstructor courseId={courseId} />
<div className="row pb-4.5">
<h1 className="text-primary-500" id="main-content">
<h1 className="text-primary-500">
<FormattedMessage
id="bulk.email.send.email.header"
defaultMessage="Send an email"
@@ -33,7 +33,11 @@ export default function BulkEmailTool() {
</h1>
</div>
<div className="row">
<BulkEmailForm courseId={courseId} cohorts={courseMetadata.cohorts} />
<BulkEmailForm
courseId={courseId}
cohorts={courseMetadata.cohorts}
courseModes={courseMetadata.courseModes}
/>
</div>
<div className="row py-5">
<BulkEmailTaskManager courseId={courseId} />

View File

@@ -1,3 +1,5 @@
/* eslint-disable react/jsx-no-constructed-context-values */
import React from 'react';
import PropTypes from 'prop-types';
import useAsyncReducer, { combineReducers } from '../../../utils/useAsyncReducer';

View File

@@ -1,13 +1,14 @@
/* eslint-disable react/no-unstable-nested-components */
import React, { useContext, useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import {
Button,
Form, Icon, StatefulButton, Toast, useToggle,
} from '@edx/paragon';
} from '@openedx/paragon';
import {
SpinnerSimple, Cancel, Send, Event, Check,
} from '@edx/paragon/icons';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
} from '@openedx/paragon/icons';
import { useIntl } from '@edx/frontend-platform/i18n';
import classNames from 'classnames';
import { getConfig } from '@edx/frontend-platform';
import TextEditor from '../text-editor/TextEditor';
@@ -46,7 +47,12 @@ const FORM_ACTIONS = {
};
function BulkEmailForm(props) {
const { courseId, cohorts, intl } = props;
const {
courseId,
cohorts,
courseModes,
} = props;
const intl = useIntl();
const [{ editor }, dispatch] = useContext(BulkEmailContext);
const [emailFormStatus, setEmailFormStatus] = useState(FORM_SUBMIT_STATES.DEFAULT);
const [emailFormValidation, setEmailFormValidation] = useState({
@@ -205,6 +211,7 @@ function BulkEmailForm(props) {
} else {
setEmailFormStatus(FORM_SUBMIT_STATES.DEFAULT);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isScheduled, editor.editMode, editor.isLoading, editor.errorRetrievingData, editor.formComplete]);
const AlertMessage = () => (
@@ -270,10 +277,14 @@ function BulkEmailForm(props) {
handleCheckboxes={onRecipientChange}
additionalCohorts={cohorts}
isValid={emailFormValidation.recipients}
courseModes={courseModes}
/>
<Form.Group controlId="emailSubject">
<Form.Label className="h3 text-primary-500">{intl.formatMessage(messages.bulkEmailSubjectLabel)}</Form.Label>
<Form.Control name="emailSubject" className="w-lg-50" onChange={onFormChange} value={editor.emailSubject} />
<Form.Control name="emailSubject" className="w-lg-50" onChange={onFormChange} value={editor.emailSubject} maxLength={128} />
<Form.Control.Feedback className="px-3" type="default">
{intl.formatMessage(messages.bulkEmailFormSubjectTip)}
</Form.Control.Feedback>
{!emailFormValidation.subject && (
<Form.Control.Feedback className="px-3" hasIcon type="invalid">
{intl.formatMessage(messages.bulkEmailFormSubjectError)}
@@ -381,7 +392,13 @@ BulkEmailForm.defaultProps = {
BulkEmailForm.propTypes = {
courseId: PropTypes.string.isRequired,
cohorts: PropTypes.arrayOf(PropTypes.string),
intl: intlShape.isRequired,
courseModes: PropTypes.arrayOf(
PropTypes.shape({
slug: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
}),
).isRequired,
};
export default injectIntl(BulkEmailForm);
export default BulkEmailForm;

View File

@@ -2,13 +2,15 @@ import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import { Form } from '@edx/paragon';
import { Form } from '@openedx/paragon';
import useMobileResponsive from '../../../utils/useMobileResponsive';
function ScheduleEmailForm(props) {
const isMobile = useMobileResponsive();
const { isValid, onDateTimeChange, dateTime } = props;
const { date, time } = dateTime;
const descriptionDate = new Date();
descriptionDate.setDate(new Date().getDate() + 1);
return (
<Form.Group>
<div className={classNames('d-flex', isMobile ? 'flex-column' : 'flex-row', 'my-3')}>
@@ -30,7 +32,10 @@ function ScheduleEmailForm(props) {
<small className="text-gray-500 x-small">
<FormattedMessage
id="bulk.email.form.schedule.date.description"
defaultMessage="Enter a start date, e.g. 11/27/2023"
defaultMessage="Enter a start date, e.g. {date}"
values={{
date: descriptionDate.toLocaleDateString(),
}}
/>
</small>
</div>
@@ -52,7 +57,10 @@ function ScheduleEmailForm(props) {
<small className="text-gray-500 x-small">
<FormattedMessage
id="bulk.email.form.schedule.time.description"
defaultMessage="Enter a start time, e.g. 09:00 AM"
defaultMessage="Enter a start time, e.g. {time}"
values={{
time: descriptionDate.toLocaleTimeString([], { timeStyle: 'short' }),
}}
/>
</small>
</div>

View File

@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Form } from '@edx/paragon';
import { Form } from '@openedx/paragon';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import './bulkEmailRecepient.scss';
@@ -14,7 +14,13 @@ const DEFAULT_GROUPS = {
};
export default function BulkEmailRecipient(props) {
const { handleCheckboxes, selectedGroups, additionalCohorts } = props;
const {
handleCheckboxes,
selectedGroups,
additionalCohorts,
courseModes,
} = props;
const hasCourseModes = courseModes && courseModes.length > 1;
return (
<Form.Group>
<Form.Label>
@@ -50,18 +56,24 @@ export default function BulkEmailRecipient(props) {
description="A selectable choice from a list of potential email recipients"
/>
</Form.Checkbox>
<Form.Checkbox
key="track:verified"
value="track:verified"
disabled={selectedGroups.find((group) => group === DEFAULT_GROUPS.ALL_LEARNERS)}
className="col col-lg-4 col-sm-6 col-12"
>
<FormattedMessage
id="bulk.email.form.recipients.verified"
defaultMessage="Learners in the verified certificate track"
description="A selectable choice from a list of potential email recipients"
/>
</Form.Checkbox>
{
// additional modes
hasCourseModes
&& courseModes.map((courseMode) => (
<Form.Checkbox
key={`track:${courseMode.slug}`}
value={`track:${courseMode.slug}`}
disabled={selectedGroups.find((group) => group === DEFAULT_GROUPS.ALL_LEARNERS)}
className="col col-lg-4 col-sm-6 col-12"
>
<FormattedMessage
id="bulk.email.form.mode.label"
defaultMessage="Learners in the {courseModeName} Track"
values={{ courseModeName: courseMode.name }}
/>
</Form.Checkbox>
))
}
{
// additional cohorts
additionalCohorts
@@ -80,18 +92,6 @@ export default function BulkEmailRecipient(props) {
</Form.Checkbox>
))
}
<Form.Checkbox
key="track:audit"
value="track:audit"
disabled={selectedGroups.find((group) => group === DEFAULT_GROUPS.ALL_LEARNERS)}
className="col col-lg-4 col-sm-6 col-12"
>
<FormattedMessage
id="bulk.email.form.recipients.audit"
defaultMessage="Learners in the audit track"
description="A selectable choice from a list of potential email recipients"
/>
</Form.Checkbox>
<Form.Checkbox
key="learners"
value="learners"
@@ -127,4 +127,10 @@ BulkEmailRecipient.propTypes = {
handleCheckboxes: PropTypes.func.isRequired,
isValid: PropTypes.bool,
additionalCohorts: PropTypes.arrayOf(PropTypes.string),
courseModes: PropTypes.arrayOf(
PropTypes.shape({
slug: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
}),
).isRequired,
};

View File

@@ -1 +1,2 @@
// eslint-disable-next-line no-restricted-exports
export { default } from './BulkEmailRecipient';

View File

@@ -0,0 +1,22 @@
import { Factory } from 'rosie'; // eslint-disable-line import/no-extraneous-dependencies
/**
* Generates an array of course mode objects using Rosie Factory.
* @returns {Array<Object>} An array of course mode objects with attributes 'slug' and 'name'.
*/
const courseModeFactory = () => {
const AuditModeFactory = Factory.define('AuditModeFactory')
.attr('slug', 'audit')
.attr('name', 'Audit');
const VerifiedModeFactory = Factory.define('VerifiedModeFactory')
.attr('slug', 'verified')
.attr('name', 'Verified Certificate');
return [
AuditModeFactory.build(),
VerifiedModeFactory.build(),
];
};
export default courseModeFactory;

View File

@@ -1 +1,2 @@
// eslint-disable-next-line no-restricted-exports
export { default } from './BulkEmailForm';

View File

@@ -41,6 +41,11 @@ const messages = defineMessages({
defaultMessage: 'Subject',
description: 'Email subject line input label. Meant to have colon or equivilant punctuation.',
},
bulkEmailFormSubjectTip: {
id: 'bulk.email.form.subject.tip',
defaultMessage: '(Maximum 128 characters)',
description: 'Default Subject tip',
},
bulkEmailFormSubjectError: {
id: 'bulk.email.form.subject.error',
defaultMessage: 'A subject is required',

View File

@@ -12,6 +12,7 @@ import * as bulkEmailFormApi from '../data/api';
import { BulkEmailContext, BulkEmailProvider } from '../../bulk-email-context';
import { formatDate } from '../../../../utils/formatDateAndTime';
import cohortFactory from '../data/__factories__/bulkEmailFormCohort.factory';
import courseModeFactory from '../data/__factories__/bulkEmailFormCourseMode.factory';
jest.mock('../../text-editor/TextEditor');
@@ -20,12 +21,17 @@ const dispatchMock = jest.fn();
const tomorrow = new Date();
tomorrow.setDate(new Date().getDate() + 1);
const courseMode = courseModeFactory();
function renderBulkEmailForm() {
const { cohorts } = cohortFactory.build();
return (
<BulkEmailProvider>
<BulkEmailForm courseId="test" cohorts={cohorts} />
<BulkEmailForm
courseId="test"
cohorts={cohorts}
courseModes={courseMode}
/>
</BulkEmailProvider>
);
}
@@ -33,7 +39,7 @@ function renderBulkEmailForm() {
function renderBulkEmailFormContext(value) {
return (
<BulkEmailContext.Provider value={[value, dispatchMock]}>
<BulkEmailForm courseId="test" />
<BulkEmailForm courseId="test" courseModes={courseMode} />
</BulkEmailContext.Provider>
);
}
@@ -96,8 +102,8 @@ describe('bulk-email-form', () => {
test('Checking "All Learners" disables each learner group', async () => {
render(renderBulkEmailForm());
fireEvent.click(screen.getByRole('checkbox', { name: 'All Learners' }));
const verifiedLearners = screen.getByRole('checkbox', { name: 'Learners in the verified certificate track' });
const auditLearners = screen.getByRole('checkbox', { name: 'Learners in the audit track' });
const verifiedLearners = screen.getByRole('checkbox', { name: 'Learners in the Verified Certificate Track' });
const auditLearners = screen.getByRole('checkbox', { name: 'Learners in the Audit Track' });
const { cohorts } = cohortFactory.build();
cohorts.forEach(cohort => expect(screen.getByRole('checkbox', { name: `Cohort: ${cohort}` })).toBeDisabled());
expect(verifiedLearners).toBeDisabled();

View File

@@ -1,18 +1,21 @@
import React, { useState } from 'react';
/* eslint-disable react/no-unstable-nested-components */
import React, { useMemo, useState } from 'react';
import PropTypes from 'prop-types';
import { useParams } from 'react-router-dom';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { useIntl } from '@edx/frontend-platform/i18n';
import {
Button, Collapsible, Icon,
} from '@edx/paragon';
import { SpinnerSimple } from '@edx/paragon/icons';
} from '@openedx/paragon';
import { SpinnerSimple } from '@openedx/paragon/icons';
import messages from './messages';
import { getSentEmailHistory } from './data/api';
import BulkEmailTaskManagerTable from './BulkEmailHistoryTable';
import ViewEmailModal from './ViewEmailModal';
function BulkEmailContentHistory({ intl }) {
function BulkEmailContentHistory() {
const intl = useIntl();
const { courseId } = useParams();
const [emailHistoryData, setEmailHistoryData] = useState();
const [errorRetrievingData, setErrorRetrievingData] = useState(false);
@@ -49,17 +52,15 @@ function BulkEmailContentHistory({ intl }) {
* up a level (the `subject` field). We also convert the `sent_to` data to be a String rather than an array to fix a
* display bug in the table.
*/
function transformDataForTable() {
let tableData = [];
if (emailHistoryData) {
tableData = emailHistoryData.map((item) => ({
...item,
subject: item.email.subject,
sent_to: item.sent_to.join(', '),
}));
}
return tableData;
}
const transformDataForTable = useMemo(() => {
const tableData = emailHistoryData?.map((item) => ({
...item,
subject: item.email.subject,
sent_to: item.sent_to.join(', '),
created: new Date(item.created).toLocaleString(),
}));
return tableData || [];
}, [emailHistoryData]);
/**
* This function is responsible for setting the current `messageContent` state data. This will be the contents of a
@@ -100,7 +101,7 @@ function BulkEmailContentHistory({ intl }) {
* contents of a previously sent message.
*/
const additionalColumns = () => {
const tableData = transformDataForTable();
const tableData = transformDataForTable;
return [
{
@@ -131,12 +132,13 @@ function BulkEmailContentHistory({ intl }) {
styling="card"
title={intl.formatMessage(messages.emailHistoryTableSectionButton)}
className="mb-3"
// eslint-disable-next-line react/jsx-no-bind
onOpen={fetchSentEmailHistoryData}
>
{showHistoricalEmailContentTable ? (
<BulkEmailTaskManagerTable
errorRetrievingData={errorRetrievingData}
tableData={transformDataForTable()}
tableData={transformDataForTable}
tableDescription={intl.formatMessage(messages.emailHistoryTableViewMessageInstructions)}
alertWarningMessage={intl.formatMessage(messages.noEmailData)}
alertErrorMessage={intl.formatMessage(messages.errorFetchingEmailHistoryData)}
@@ -153,7 +155,6 @@ function BulkEmailContentHistory({ intl }) {
}
BulkEmailContentHistory.propTypes = {
intl: intlShape.isRequired,
row: PropTypes.shape({
index: PropTypes.number,
}),
@@ -163,4 +164,4 @@ BulkEmailContentHistory.defaultProps = {
row: {},
};
export default injectIntl(BulkEmailContentHistory);
export default BulkEmailContentHistory;

View File

@@ -1,4 +1,4 @@
import { Alert, DataTable } from '@edx/paragon';
import { Alert, DataTable } from '@openedx/paragon';
import PropTypes from 'prop-types';
import React from 'react';
@@ -71,12 +71,12 @@ export default function BulkEmailTaskManagerTable(props) {
BulkEmailTaskManagerTable.propTypes = {
errorRetrievingData: PropTypes.bool.isRequired,
tableData: PropTypes.arrayOf(PropTypes.object),
tableData: PropTypes.arrayOf(PropTypes.shape({})),
tableDescription: PropTypes.string,
alertWarningMessage: PropTypes.string.isRequired,
alertErrorMessage: PropTypes.string.isRequired,
columns: PropTypes.arrayOf(PropTypes.object).isRequired,
additionalColumns: PropTypes.arrayOf(PropTypes.object),
columns: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
additionalColumns: PropTypes.arrayOf(PropTypes.shape({})),
};
BulkEmailTaskManagerTable.defaultProps = {

View File

@@ -1,13 +1,14 @@
import React, { useState } from 'react';
import { useParams } from 'react-router-dom';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { useIntl } from '@edx/frontend-platform/i18n';
import { getInstructorTasks } from './data/api';
import messages from './messages';
import useInterval from '../../../utils/useInterval';
import BulkEmailTaskManagerTable from './BulkEmailHistoryTable';
function BulkEmailPendingTasks({ intl }) {
function BulkEmailPendingTasks() {
const intl = useIntl();
const { courseId } = useParams();
const [instructorTaskData, setInstructorTaskData] = useState();
@@ -89,8 +90,4 @@ function BulkEmailPendingTasks({ intl }) {
);
}
BulkEmailPendingTasks.propTypes = {
intl: intlShape.isRequired,
};
export default injectIntl(BulkEmailPendingTasks);
export default BulkEmailPendingTasks;

View File

@@ -1,34 +1,40 @@
import React from 'react';
import PropTypes from 'prop-types';
import { getConfig } from '@edx/frontend-platform';
import { Hyperlink, Alert } from '@edx/paragon';
import { WarningFilled } from '@edx/paragon/icons';
import { Hyperlink, Alert } from '@openedx/paragon';
import { WarningFilled } from '@openedx/paragon/icons';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
export default function BulkEmailPendingTasksAlert() {
export default function BulkEmailPendingTasksAlert(props) {
const { courseId } = props;
return (
<>
<Alert variant="warning" icon={WarningFilled}>
<Alert variant="warning" icon={WarningFilled}>
<FormattedMessage
id="bulk.email.pending.tasks.description.one"
defaultMessage="To view all pending tasks, including email, visit&nbsp;"
/>
<Hyperlink
destination={`${getConfig().LMS_BASE_URL}/courses/${courseId}/instructor#view-course-info`}
target="_blank"
isInline
showLaunchIcon={false}
>
<FormattedMessage
id="bulk.email.pending.tasks.description.one"
defaultMessage="To view all pending tasks, including email, visit&nbsp;"
id="bulk.email.pending.tasks.link"
defaultMessage="Course Info"
/>
<Hyperlink
destination={`${getConfig().LMS_BASE_URL}/courses/${window.location.pathname.split('/')[2]}/instructor#view-course-info`}
target="_blank"
isInline
showLaunchIcon={false}
>
<FormattedMessage
id="bulk.email.pending.tasks.link"
defaultMessage="Course Info"
/>
</Hyperlink>
<FormattedMessage
id="bulk.email.pending.tasks.description.two"
defaultMessage="&nbsp;in the Instructor Dashboard."
/>
</Alert>
</>
</Hyperlink>
<FormattedMessage
id="bulk.email.pending.tasks.description.two"
defaultMessage="&nbsp;in the Instructor Dashboard."
/>
</Alert>
);
}
BulkEmailPendingTasksAlert.propTypes = {
courseId: PropTypes.string.isRequired,
};

View File

@@ -1,9 +1,9 @@
import React, { useState } from 'react';
import React, { useMemo, useState } from 'react';
import { useParams } from 'react-router-dom';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { useIntl } from '@edx/frontend-platform/i18n';
import { Icon, Collapsible } from '@edx/paragon';
import { SpinnerSimple } from '@edx/paragon/icons';
import { Icon, Collapsible } from '@openedx/paragon';
import { SpinnerSimple } from '@openedx/paragon/icons';
import { getEmailTaskHistory } from './data/api';
import messages from './messages';
@@ -11,7 +11,8 @@ import BulkEmailTaskManagerTable from './BulkEmailHistoryTable';
import './bulkEmailTaskHistory.scss';
function BulkEmailTaskHistory({ intl }) {
function BulkEmailTaskHistory() {
const intl = useIntl();
const { courseId } = useParams();
const [emailTaskHistoryData, setEmailTaskHistoryData] = useState([]);
@@ -41,6 +42,14 @@ function BulkEmailTaskHistory({ intl }) {
setShowHistoricalTaskContentTable(true);
}
const transformDataForTable = useMemo(() => {
const tableData = emailTaskHistoryData?.map((item) => ({
...item,
created: new Date(item.created).toLocaleString(),
}));
return tableData || [];
}, [emailTaskHistoryData]);
const tableColumns = [
{
Header: `${intl.formatMessage(messages.taskHistoryTableColumnHeaderTaskType)}`,
@@ -89,12 +98,13 @@ function BulkEmailTaskHistory({ intl }) {
<Collapsible
styling="card"
title={intl.formatMessage(messages.emailTaskHistoryTableSectionButton)}
// eslint-disable-next-line react/jsx-no-bind
onOpen={fetchEmailTaskHistoryData}
>
{showHistoricalTaskContentTable ? (
<BulkEmailTaskManagerTable
errorRetrievingData={errorRetrievingData}
tableData={emailTaskHistoryData}
tableData={transformDataForTable}
alertWarningMessage={intl.formatMessage(messages.noTaskHistoryData)}
alertErrorMessage={intl.formatMessage(messages.errorFetchingTaskHistoryData)}
columns={tableColumns}
@@ -108,8 +118,4 @@ function BulkEmailTaskHistory({ intl }) {
);
}
BulkEmailTaskHistory.propTypes = {
intl: intlShape.isRequired,
};
export default injectIntl(BulkEmailTaskHistory);
export default BulkEmailTaskHistory;

View File

@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { useIntl } from '@edx/frontend-platform/i18n';
import { getConfig } from '@edx/frontend-platform';
import BulkEmailContentHistory from './BulkEmailContentHistory';
import BulkEmailTaskHistory from './BulkEmailTaskHistory';
@@ -8,7 +9,8 @@ import messages from './messages';
import BulkEmailScheduledEmailsTable from './bulk-email-scheduled-emails-table';
import BulkEmailPendingTasksAlert from './BulkEmailPendingTasksAlert';
function BulkEmailTaskManager({ intl }) {
function BulkEmailTaskManager({ courseId }) {
const intl = useIntl();
return (
<div className="w-100">
{getConfig().SCHEDULE_EMAIL_SECTION && (
@@ -26,14 +28,14 @@ function BulkEmailTaskManager({ intl }) {
</div>
<div className="border-top border-primary-500 pt-4.5">
<h2 className="h3 mb-4 text-primary-500">{intl.formatMessage(messages.pendingTasksHeader)}</h2>
<BulkEmailPendingTasksAlert />
<BulkEmailPendingTasksAlert courseId={courseId} />
</div>
</div>
);
}
BulkEmailTaskManager.propTypes = {
intl: intlShape.isRequired,
courseId: PropTypes.string.isRequired,
};
export default injectIntl(BulkEmailTaskManager);
export default BulkEmailTaskManager;

View File

@@ -1,21 +1,25 @@
import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import { Button, Modal } from '@edx/paragon';
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { ActionRow, Button, ModalDialog } from '@openedx/paragon';
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
import messages from './messages';
import { BulkEmailContext } from '../bulk-email-context';
import { copyToEditor } from '../bulk-email-form/data/actions';
function ViewEmailModal({
intl, messageContent, isOpen, setModalOpen,
messageContent, isOpen, setModalOpen,
}) {
const intl = useIntl();
const [, dispatch] = useContext(BulkEmailContext);
return (
<div>
<Modal
open={isOpen}
title=""
body={(
<ModalDialog
isOpen={isOpen}
onClose={() => setModalOpen(false)}
hasCloseButton
>
<ModalDialog.Body>
<div>
<div className="d-flex flex-row">
<p>{intl.formatMessage(messages.modalMessageSubject)}</p>
@@ -40,30 +44,35 @@ function ViewEmailModal({
<div dangerouslySetInnerHTML={{ __html: messageContent.email.html_message }} />
</div>
</div>
)}
onClose={() => setModalOpen(false)}
buttons={[
<Button
onClick={() => {
dispatch(
copyToEditor({
emailBody: messageContent.email.html_message,
emailSubject: messageContent.subject,
}),
);
setModalOpen(false);
}}
>
<FormattedMessage id="bulk.email.tool.copy.message.button" defaultMessage="Copy to editor" />
</Button>,
]}
/>
</ModalDialog.Body>
<ModalDialog.Footer>
<ActionRow>
<ModalDialog.CloseButton variant="link">
<FormattedMessage id="bulk.email.tool.close.modalDialog.button" defaultMessage="Close" />
</ModalDialog.CloseButton>
<Button
onClick={() => {
dispatch(
copyToEditor({
emailBody: messageContent.email.html_message,
emailSubject: messageContent.subject,
}),
);
setModalOpen(false);
}}
variant="primary"
>
<FormattedMessage id="bulk.email.tool.copy.message.button" defaultMessage="Copy to editor" />
</Button>
</ActionRow>
</ModalDialog.Footer>
</ModalDialog>
</div>
);
}
ViewEmailModal.propTypes = {
intl: intlShape.isRequired,
messageContent: PropTypes.shape({
subject: PropTypes.string,
requester: PropTypes.string,
@@ -77,4 +86,4 @@ ViewEmailModal.propTypes = {
setModalOpen: PropTypes.func.isRequired,
};
export default injectIntl(ViewEmailModal);
export default ViewEmailModal;

View File

@@ -1,14 +1,16 @@
/* eslint-disable react/prop-types */
/* eslint-disable react/no-unstable-nested-components */
import React, {
useCallback, useContext, useState, useEffect,
} from 'react';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { useIntl } from '@edx/frontend-platform/i18n';
import {
Alert, DataTable, Icon, IconButton, useToggle,
} from '@edx/paragon';
} from '@openedx/paragon';
import {
Delete, Info, Visibility, Edit,
} from '@edx/paragon/icons';
} from '@openedx/paragon/icons';
import { useParams } from 'react-router-dom';
import { BulkEmailContext } from '../../bulk-email-context';
import { deleteScheduledEmailThunk, getScheduledBulkEmailThunk } from './data/thunks';
@@ -24,12 +26,14 @@ function flattenScheduledEmailsArray(emails) {
emailId: email.courseEmail.id,
task: email.task,
taskDue: new Date(email.taskDue).toLocaleString(),
taskDueUTC: email.taskDue,
...email.courseEmail,
targets: email.courseEmail.targets.join(', '),
}));
}
function BulkEmailScheduledEmailsTable({ intl }) {
function BulkEmailScheduledEmailsTable() {
const intl = useIntl();
const { courseId } = useParams();
const [{ scheduledEmailsTable }, dispatch] = useContext(BulkEmailContext);
const [tableData, setTableData] = useState([]);
@@ -46,6 +50,7 @@ function BulkEmailScheduledEmailsTable({ intl }) {
const fetchTableData = useCallback((args) => {
dispatch(getScheduledBulkEmailThunk(courseId, args.pageIndex + 1));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const handleViewEmail = (row) => {
@@ -88,10 +93,10 @@ function BulkEmailScheduledEmailsTable({ intl }) {
const handleEditEmail = (row) => {
const {
original: {
htmlMessage: emailBody, subject: emailSubject, taskDue, targets, schedulingId, emailId,
htmlMessage: emailBody, subject: emailSubject, taskDueUTC, targets, schedulingId, emailId,
},
} = row;
const dateTime = new Date(taskDue);
const dateTime = new Date(taskDueUTC);
const emailRecipients = targets.replaceAll('-', ':').split(', ');
const scheduleDate = formatDate(dateTime);
const scheduleTime = formatTime(dateTime);
@@ -192,8 +197,4 @@ function BulkEmailScheduledEmailsTable({ intl }) {
);
}
BulkEmailScheduledEmailsTable.propTypes = {
intl: intlShape.isRequired,
};
export default injectIntl(BulkEmailScheduledEmailsTable);
export default BulkEmailScheduledEmailsTable;

View File

@@ -1 +1,2 @@
// eslint-disable-next-line no-restricted-exports
export { default } from './BulkEmailScheduledEmailsTable';

View File

@@ -34,6 +34,10 @@ const messages = defineMessages({
id: 'bulk.email.content.history.table.modal.messageBody',
defaultMessage: 'Message:',
},
modalCloseButton: {
id: 'bulk.email.tool.close.modalDialog.button',
defaultMessage: 'Close',
},
emailHistoryTableViewMessageInstructions: {
id: 'bulk.email.content.history.table.viewMessageInstructions',
defaultMessage: 'To read a sent email message, click the `View Message` button within the table.',

View File

@@ -3,7 +3,7 @@
*/
import React from 'react';
import {
render, screen, fireEvent, cleanup, act, initializeMockApp,
render, screen, fireEvent, cleanup, initializeMockApp,
} from '../../../../setupTest';
import { BulkEmailProvider } from '../../bulk-email-context';
import BulkEmailContentHistory from '../BulkEmailContentHistory';
@@ -41,105 +41,99 @@ describe('BulkEmailContentHistory component', () => {
});
test('renders a table when the button is pressed and data is returned', async () => {
await act(async () => {
const emailHistoryData = buildEmailContentHistoryData(1);
getSentEmailHistory.mockImplementation(() => emailHistoryData);
const emailHistoryData = buildEmailContentHistoryData(1);
getSentEmailHistory.mockImplementation(() => emailHistoryData);
render(renderBulkEmailContentHistory());
render(renderBulkEmailContentHistory());
const showEmailContentHistoryButton = await screen.findByText('Show Sent Email History');
fireEvent.click(showEmailContentHistoryButton);
const showEmailContentHistoryButton = await screen.findByText('Show Sent Email History');
fireEvent.click(showEmailContentHistoryButton);
// verify component structure
const tableDescription = await screen.findByText(
'To read a sent email message, click the `View Message` button within the table.',
);
expect(tableDescription).toBeTruthy();
// verify component structure
const tableDescription = await screen.findByText(
'To read a sent email message, click the `View Message` button within the table.',
);
expect(tableDescription).toBeTruthy();
// verify table structure
expect(await screen.findByText('Subject')).toBeTruthy();
expect(await screen.findByText('Sent By')).toBeTruthy();
expect(await screen.findByText('Sent To')).toBeTruthy();
expect(await screen.findByText('Time Sent')).toBeTruthy();
expect(await screen.findByText('Number Sent')).toBeTruthy();
// verify table structure
expect(await screen.findByText('Subject')).toBeTruthy();
expect(await screen.findByText('Sent By')).toBeTruthy();
expect(await screen.findByText('Sent To')).toBeTruthy();
expect(await screen.findByText('Time Sent')).toBeTruthy();
expect(await screen.findByText('Number Sent')).toBeTruthy();
// verify table contents
const { emails } = emailHistoryData;
const email = emails[0];
expect(await screen.findByText(email.created)).toBeTruthy();
expect(await screen.findByText(email.number_sent)).toBeTruthy();
expect(await screen.findByText(email.requester)).toBeTruthy();
expect(await screen.findByText(email.sent_to.join(', '))).toBeTruthy();
expect(await screen.findByText(email.email.subject)).toBeTruthy();
// verify screen reader only <span />
expect(await screen.findByText('0')).toHaveClass('sr-only');
expect(await screen.findAllByText('View Message')).toBeTruthy();
});
// verify table contents
const { emails } = emailHistoryData;
const email = emails[0];
const createdDate = new Date(email.created).toLocaleString();
expect(await screen.findByText(createdDate)).toBeTruthy();
expect(await screen.findByText(email.number_sent)).toBeTruthy();
expect(await screen.findByText(email.requester)).toBeTruthy();
expect(await screen.findByText(email.sent_to.join(', '))).toBeTruthy();
expect(await screen.findByText(email.email.subject)).toBeTruthy();
// verify screen reader only <span />
expect(await screen.findByText('0')).toHaveClass('sr-only');
expect(await screen.findAllByText('View Message')).toBeTruthy();
});
test('renders a modal that will display the contents of the previously sent message to a user', async () => {
await act(async () => {
const emailHistoryData = buildEmailContentHistoryData(1);
getSentEmailHistory.mockImplementation(() => emailHistoryData);
const emailHistoryData = buildEmailContentHistoryData(1);
getSentEmailHistory.mockImplementation(() => emailHistoryData);
render(renderBulkEmailContentHistory());
render(renderBulkEmailContentHistory());
const showEmailContentHistoryButton = await screen.findByText('Show Sent Email History');
fireEvent.click(showEmailContentHistoryButton);
const showEmailContentHistoryButton = await screen.findByText('Show Sent Email History');
fireEvent.click(showEmailContentHistoryButton);
const viewMessageButton = await screen.findByText('View Message');
fireEvent.click(viewMessageButton);
const viewMessageButton = await screen.findByText('View Message');
fireEvent.click(viewMessageButton);
// verify modal components and behavior
const { emails } = emailHistoryData;
const email = emails[0];
const closeButton = await screen.findAllByText('Close');
// verify modal components and behavior
const { emails } = emailHistoryData;
const email = emails[0];
const closeButton = await screen.findAllByText('Close');
expect(closeButton).toBeTruthy();
expect(await screen.findByText('Subject:')).toBeTruthy();
expect(await screen.findByText('Sent by:')).toBeTruthy();
expect(await screen.findByText('Time sent:')).toBeTruthy();
expect(await screen.findByText('Sent to:')).toBeTruthy();
expect(await screen.findByText('Message:')).toBeTruthy();
expect(await screen.findAllByText(email.email.subject)).toBeTruthy();
expect(await screen.findAllByText(email.requester)).toBeTruthy();
expect(await screen.findAllByText(email.created)).toBeTruthy();
expect(await screen.findAllByText(email.sent_to.join(', '))).toBeTruthy();
// .replace() call strips the HTML tags from the string
expect(await screen.findByText(email.email.html_message.replace(/<[^>]*>?/gm, ''))).toBeTruthy();
});
expect(closeButton).toBeTruthy();
expect(await screen.findByText('Subject:')).toBeTruthy();
expect(await screen.findByText('Sent by:')).toBeTruthy();
expect(await screen.findByText('Time sent:')).toBeTruthy();
expect(await screen.findByText('Sent to:')).toBeTruthy();
expect(await screen.findByText('Message:')).toBeTruthy();
expect(await screen.findAllByText(email.email.subject)).toBeTruthy();
expect(await screen.findAllByText(email.requester)).toBeTruthy();
const createdDate = new Date(email.created).toLocaleString();
expect(await screen.findAllByText(createdDate)).toBeTruthy();
expect(await screen.findAllByText(email.sent_to.join(', '))).toBeTruthy();
// .replace() call strips the HTML tags from the string
expect(await screen.findByText(email.email.html_message.replace(/<[^>]*>?/gm, ''))).toBeTruthy();
});
test('renders a warning Alert when the button is pressed but there is no data to display', async () => {
await act(async () => {
const emailHistoryData = buildEmailContentHistoryData(0);
getSentEmailHistory.mockImplementation(() => emailHistoryData);
// render the component
render(renderBulkEmailContentHistory());
// press the `show sent email history` button to initiate data retrieval
const showEmailContentHistoryButton = await screen.findByText('Show Sent Email History');
fireEvent.click(showEmailContentHistoryButton);
// verify that an alert is displayed since the array of tasks is empty
const alertMessage = await screen.findByText('There is no email history for this course.');
expect(alertMessage).toBeTruthy();
});
const emailHistoryData = buildEmailContentHistoryData(0);
getSentEmailHistory.mockImplementation(() => emailHistoryData);
// render the component
render(renderBulkEmailContentHistory());
// press the `show sent email history` button to initiate data retrieval
const showEmailContentHistoryButton = await screen.findByText('Show Sent Email History');
fireEvent.click(showEmailContentHistoryButton);
// verify that an alert is displayed since the array of tasks is empty
const alertMessage = await screen.findByText('There is no email history for this course.');
expect(alertMessage).toBeTruthy();
});
test('renders an error Alert when the button is pressed and an error occurs retrieving data', async () => {
await act(async () => {
getSentEmailHistory.mockImplementation(() => {
throw new Error();
});
// render the component
render(renderBulkEmailContentHistory());
// press the `show sent email history` button to initiate data retrieval
const showEmailContentHistoryButton = await screen.findByText('Show Sent Email History');
fireEvent.click(showEmailContentHistoryButton);
// verify that an alert is displayed since the array of tasks is empty
const alertMessage = await screen.findByText(
'An error occurred retrieving email history data for this course. Please try again later.',
);
expect(alertMessage).toBeTruthy();
getSentEmailHistory.mockImplementation(() => {
throw new Error();
});
// render the component
render(renderBulkEmailContentHistory());
// press the `show sent email history` button to initiate data retrieval
const showEmailContentHistoryButton = await screen.findByText('Show Sent Email History');
fireEvent.click(showEmailContentHistoryButton);
// verify that an alert is displayed since the array of tasks is empty
const alertMessage = await screen.findByText(
'An error occurred retrieving email history data for this course. Please try again later.',
);
expect(alertMessage).toBeTruthy();
});
});

View File

@@ -61,7 +61,7 @@ describe('BulkEmailPendingTasks component', () => {
expect(await screen.findByText('State')).toBeTruthy();
expect(await screen.findByText('Status')).toBeTruthy();
expect(await screen.findByText('Task Progress')).toBeTruthy();
expect(await screen.findAllByText('Showing 1 of 1.')).toBeTruthy();
expect(await screen.findAllByText('Showing 1 - 1 of 1.')).toBeTruthy();
// verification of table contents
const { tasks } = pendingInstructorTaskData;

View File

@@ -0,0 +1,33 @@
import React from 'react';
import BulkEmailPendingTasksAlert from '../BulkEmailPendingTasksAlert';
import {
initializeMockApp, render, screen,
} from '../../../../setupTest';
describe('Testing BulkEmailPendingTasksAlert Component', () => {
beforeAll(async () => {
await initializeMockApp();
});
test('Render without Public path', async () => {
render(<BulkEmailPendingTasksAlert courseId="test-course-id" />);
const linkEl = await screen.findByText('Course Info');
expect(linkEl.href).toEqual('http://localhost:18000/courses/test-course-id/instructor#view-course-info');
});
test('Render with Public path', async () => {
Object.defineProperty(window, 'location', {
get() {
return { pathname: '/communications/courses/test-course-id/bulk-email' };
},
});
render(<BulkEmailPendingTasksAlert courseId="test-course-id" />);
const linkEl = await screen.findByText('Course Info');
expect(linkEl.href).toEqual('http://localhost:18000/courses/test-course-id/instructor#view-course-info');
expect(window.location.pathname).toEqual('/communications/courses/test-course-id/bulk-email');
});
});

View File

@@ -3,7 +3,7 @@
*/
import React from 'react';
import {
render, screen, fireEvent, cleanup, act, initializeMockApp,
render, screen, fireEvent, cleanup, initializeMockApp,
} from '../../../../setupTest';
import BulkEmailTaskHistory from '../BulkEmailTaskHistory';
import { getEmailTaskHistory } from '../data/api';
@@ -32,71 +32,66 @@ describe('BulkEmailTaskHistory component', () => {
});
test('renders a table properly when the button is pressed and data is returned', async () => {
await act(async () => {
// build our mocked response
const taskHistoryData = buildEmailTaskHistoryData(1);
getEmailTaskHistory.mockImplementation(() => taskHistoryData);
// render the component
render(<BulkEmailTaskHistory />);
// press the `show task history button` to initiate data retrieval and rendering of the table in our component
const showTaskHistoryButton = await screen.findByText('Show Email Task History');
fireEvent.click(showTaskHistoryButton);
// verification of table structure
expect(await screen.findByText('Task Type')).toBeTruthy();
expect(await screen.findByText('Task Inputs')).toBeTruthy();
expect(await screen.findByText('Task Id')).toBeTruthy();
expect(await screen.findByText('Requester')).toBeTruthy();
expect(await screen.findByText('Submitted')).toBeTruthy();
expect(await screen.findByText('Duration (seconds)')).toBeTruthy();
expect(await screen.findByText('State')).toBeTruthy();
expect(await screen.findByText('Status')).toBeTruthy();
expect(await screen.findByText('Task Progress')).toBeTruthy();
expect(await screen.findAllByText('Showing 1 of 1.')).toBeTruthy();
// verification of row contents
const { tasks } = taskHistoryData;
const task = tasks[0];
expect(await screen.findByText(task.created)).toBeTruthy();
expect(await screen.findByText(task.duration_sec)).toBeTruthy();
expect(await screen.findByText(task.requester)).toBeTruthy();
expect(await screen.findByText(task.status)).toBeTruthy();
expect(await screen.findByText(task.task_id)).toBeTruthy();
expect(await screen.findByText(task.task_input)).toBeTruthy();
expect(await screen.findByText(task.task_message)).toBeTruthy();
expect(await screen.findByText(task.task_state)).toBeTruthy();
expect(await screen.findByText(task.task_type)).toBeTruthy();
});
// build our mocked response
const taskHistoryData = buildEmailTaskHistoryData(1);
getEmailTaskHistory.mockImplementation(() => taskHistoryData);
// render the component
render(<BulkEmailTaskHistory />);
// press the `show task history button` to initiate data retrieval and rendering of the table in our component
const showTaskHistoryButton = await screen.findByText('Show Email Task History');
fireEvent.click(showTaskHistoryButton);
// verification of table structure
expect(await screen.findByText('Task Type')).toBeTruthy();
expect(await screen.findByText('Task Inputs')).toBeTruthy();
expect(await screen.findByText('Task Id')).toBeTruthy();
expect(await screen.findByText('Requester')).toBeTruthy();
expect(await screen.findByText('Submitted')).toBeTruthy();
expect(await screen.findByText('Duration (seconds)')).toBeTruthy();
expect(await screen.findByText('State')).toBeTruthy();
expect(await screen.findByText('Status')).toBeTruthy();
expect(await screen.findByText('Task Progress')).toBeTruthy();
expect(await screen.findAllByText('Showing 1 - 1 of 1.')).toBeTruthy();
// verification of row contents
const { tasks } = taskHistoryData;
const task = tasks[0];
const createdDate = new Date(task.created).toLocaleString();
expect(await screen.findByText(createdDate)).toBeTruthy();
expect(await screen.findByText(task.duration_sec)).toBeTruthy();
expect(await screen.findByText(task.requester)).toBeTruthy();
expect(await screen.findByText(task.status)).toBeTruthy();
expect(await screen.findByText(task.task_id)).toBeTruthy();
expect(await screen.findByText(task.task_input)).toBeTruthy();
expect(await screen.findByText(task.task_message)).toBeTruthy();
expect(await screen.findByText(task.task_state)).toBeTruthy();
expect(await screen.findByText(task.task_type)).toBeTruthy();
});
test('renders a warning Alert when the button is pressed but there is no data to display', async () => {
await act(async () => {
const taskHistoryData = buildEmailTaskHistoryData(0);
getEmailTaskHistory.mockImplementation(() => taskHistoryData);
// render the component
render(<BulkEmailTaskHistory />);
// press the `show task history` button to initiate data retrieval
const showTaskHistoryButton = await screen.findByText('Show Email Task History');
fireEvent.click(showTaskHistoryButton);
// verify that an alert is displayed since the array of tasks is empty
const alertMessage = await screen.findByText('There is no email task history for this course.');
expect(alertMessage).toBeTruthy();
});
const taskHistoryData = buildEmailTaskHistoryData(0);
getEmailTaskHistory.mockImplementation(() => taskHistoryData);
// render the component
render(<BulkEmailTaskHistory />);
// press the `show task history` button to initiate data retrieval
const showTaskHistoryButton = await screen.findByText('Show Email Task History');
fireEvent.click(showTaskHistoryButton);
// verify that an alert is displayed since the array of tasks is empty
const alertMessage = await screen.findByText('There is no email task history for this course.');
expect(alertMessage).toBeTruthy();
});
test('renders an error Alert when the button is pressed and an error occurs retrieving data', async () => {
await act(async () => {
getEmailTaskHistory.mockImplementation(() => {
throw new Error();
});
// render the component
render(<BulkEmailTaskHistory />);
// press the `show task history` button to initiate data retrieval
const showTaskHistoryButton = await screen.findByText('Show Email Task History');
fireEvent.click(showTaskHistoryButton);
// verify that an alert is displayed since the array of tasks is empty
const alertMessage = await screen.findByText(
'Error fetching email task history data for this course. Please try again later.',
);
expect(alertMessage).toBeTruthy();
getEmailTaskHistory.mockImplementation(() => {
throw new Error();
});
// render the component
render(<BulkEmailTaskHistory />);
// press the `show task history` button to initiate data retrieval
const showTaskHistoryButton = await screen.findByText('Show Email Task History');
fireEvent.click(showTaskHistoryButton);
// verify that an alert is displayed since the array of tasks is empty
const alertMessage = await screen.findByText(
'Error fetching email task history data for this course. Please try again later.',
);
expect(alertMessage).toBeTruthy();
});
});

View File

@@ -1 +1,2 @@
// eslint-disable-next-line no-restricted-exports
export { default } from './BulkEmailTool';

View File

@@ -1,13 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import { ActionRow, AlertModal, Button } from '@edx/paragon';
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { ActionRow, AlertModal, Button } from '@openedx/paragon';
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
function TaskAlertModal(props) {
const {
isOpen, close, alertMessage, intl,
isOpen, close, alertMessage,
} = props;
const intl = useIntl();
const messages = {
taskAlertTitle: {
id: 'bulk.email.task.alert.title',
@@ -40,6 +40,7 @@ function TaskAlertModal(props) {
// causing strange click event target issues in safari. To solve this, we want to
// wrap the string in a fragment instead of a span, so that the whole button considered
// a "button" target, and not a "span inside a button"
// eslint-disable-next-line react/jsx-no-useless-fragment
msg => <>{msg}</>
}
</FormattedMessage>
@@ -56,7 +57,6 @@ TaskAlertModal.propTypes = {
isOpen: PropTypes.bool.isRequired,
close: PropTypes.func.isRequired,
alertMessage: PropTypes.node.isRequired,
intl: intlShape.isRequired,
};
export default injectIntl(TaskAlertModal);
export default TaskAlertModal;

View File

@@ -1 +1,2 @@
// eslint-disable-next-line no-restricted-exports
export { default } from './TaskAlertModal';

View File

@@ -18,7 +18,7 @@ import 'tinymce/plugins/codesample';
import '@edx/tinymce-language-selector';
import contentUiCss from 'tinymce/skins/ui/oxide/content.css';
import contentCss from 'tinymce/skins/content/default/content.css';
import contentCss from 'tinymce/skins/content/default/content.css?raw';
export default function TextEditor(props) {
const {
@@ -43,6 +43,8 @@ export default function TextEditor(props) {
block_unsupported_drop: false,
image_advtab: true,
name: 'emailBody',
relative_urls: false,
remove_script_host: false,
}}
onEditorChange={onChange}
value={value}

View File

@@ -1 +1,2 @@
// eslint-disable-next-line no-restricted-exports
export { default } from './TextEditor';

View File

@@ -1,16 +1,19 @@
import React from 'react';
import PropTypes from 'prop-types';
import { getConfig } from '@edx/frontend-platform';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import { Button, Icon } from '@edx/paragon';
import { ArrowBack } from '@edx/paragon/icons';
import { Button, Icon } from '@openedx/paragon';
import { ArrowBack } from '@openedx/paragon/icons';
export default function BackToInstructor(props) {
const { courseId } = props;
export default function BackToInstructor() {
return (
<Button
variant="tertiary"
className="mb-4.5 ml-n4.5 text-primary-500"
href={`${getConfig().LMS_BASE_URL}/courses/${window.location.pathname.split('/')[2]}/instructor#view-course-info`}
href={`${getConfig().LMS_BASE_URL}/courses/${courseId}/instructor#view-course-info`}
>
<Icon
src={ArrowBack}
@@ -24,3 +27,7 @@ export default function BackToInstructor() {
</Button>
);
}
BackToInstructor.propTypes = {
courseId: PropTypes.string.isRequired,
};

View File

@@ -0,0 +1,33 @@
import React from 'react';
import BackToInstructor from './BackToInstructor';
import {
initializeMockApp, render, screen,
} from '../../setupTest';
describe('Testing BackToInstructor Component', () => {
beforeAll(async () => {
await initializeMockApp();
});
test('Render without Public path', async () => {
render(<BackToInstructor courseId="test-course-id" />);
const linkEl = await screen.findByText('Back to Instructor Dashboard');
expect(linkEl.href).toEqual('http://localhost:18000/courses/test-course-id/instructor#view-course-info');
});
test('Render with Public path', async () => {
Object.defineProperty(window, 'location', {
get() {
return { pathname: '/communications/courses/test-course-id/bulk-email' };
},
});
render(<BackToInstructor courseId="test-course-id" />);
const linkEl = await screen.findByText('Back to Instructor Dashboard');
expect(linkEl.href).toEqual('http://localhost:18000/courses/test-course-id/instructor#view-course-info');
expect(window.location.pathname).toEqual('/communications/courses/test-course-id/bulk-email');
});
});

View File

@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Nav } from '@edx/paragon';
import { Nav } from '@openedx/paragon';
export default function NavigationTabs(props) {
const { tabData } = props;

View File

@@ -3,8 +3,8 @@ import PropTypes from 'prop-types';
import { useParams } from 'react-router-dom';
import { LearningHeader as Header } from '@edx/frontend-component-header';
import Footer from '@edx/frontend-component-footer';
import { Spinner } from '@edx/paragon';
import { FooterSlot } from '@edx/frontend-component-footer';
import { Spinner } from '@openedx/paragon';
import { getCohorts, getCourseHomeCourseMetadata } from './data/api';
@@ -39,7 +39,7 @@ export default function PageContainer(props) {
}
const {
org, number, title, tabs, originalUserIsStaff,
org, number, title, tabs, originalUserIsStaff, courseModes,
} = metadataResponse;
const { cohorts } = cohortsResponse;
@@ -48,11 +48,13 @@ export default function PageContainer(props) {
number,
title,
originalUserIsStaff,
courseModes,
tabs: [...tabs],
cohorts: cohorts.map(({ name }) => name),
});
}
fetchCourseMetadata();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
if (courseMetadata) {
@@ -65,10 +67,12 @@ export default function PageContainer(props) {
courseNumber={courseMetadata.number}
courseTitle={courseMetadata.title}
/>
<main>
{children}
</main>
<Footer />
<div className="pb-3 container">
<main id="main-content">
{children}
</main>
</div>
<FooterSlot />
</>
</CourseMetadataContext.Provider>
);

View File

@@ -1,10 +1,10 @@
import { camelCaseObject, getConfig } from '@edx/frontend-platform';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
const courseHomeBaseUrl = `${getConfig().LMS_BASE_URL}/api/course_home/v1/course_metadata`;
export const getCourseHomeBaseUrl = () => `${getConfig().LMS_BASE_URL}/api/course_home/v1/course_metadata`;
export async function getCourseHomeCourseMetadata(courseId) {
const courseHomeMetadataUrl = `${courseHomeBaseUrl}/${courseId}`;
const courseHomeMetadataUrl = `${getCourseHomeBaseUrl()}/${courseId}`;
const { data } = await getAuthenticatedHttpClient().get(courseHomeMetadataUrl);
return camelCaseObject(data);
}

View File

@@ -0,0 +1,24 @@
import { Factory } from 'rosie'; // eslint-disable-line import/no-extraneous-dependencies
import { camelCaseObject } from '@edx/frontend-platform';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import MockAdapter from 'axios-mock-adapter';
import { initializeMockApp } from '../../../setupTest';
import * as api from './api';
import './__factories__/courseMetadata.factory';
describe('api', () => {
beforeAll(async () => {
await initializeMockApp();
});
test('getCourseHomeCourseMetadata', async () => {
const axiosMock = new MockAdapter(getAuthenticatedHttpClient());
const courseMetadata = Factory.build('courseMetadata');
const { id: courseId } = courseMetadata;
axiosMock
.onGet(`${api.getCourseHomeBaseUrl()}/${courseId}`)
.reply(200, courseMetadata);
const data = await api.getCourseHomeCourseMetadata(courseId);
expect(data).toEqual(camelCaseObject(courseMetadata));
});
});

View File

@@ -4,7 +4,7 @@
import React from 'react';
import { Factory } from 'rosie';
import {
act, cleanup, initializeMockApp, render, screen,
cleanup, initializeMockApp, render, screen,
} from '../../../setupTest';
import PageContainer from '../PageContainer';
@@ -32,36 +32,32 @@ describe('PageContainer', () => {
afterEach(cleanup);
test('PageContainer renders properly when given course metadata', async () => {
await act(async () => {
const cohorts = { cohorts: [Factory.build('cohort'), Factory.build('cohort')] };
const courseMetadata = Factory.build('courseMetadata');
const cohorts = { cohorts: [Factory.build('cohort'), Factory.build('cohort')] };
const courseMetadata = Factory.build('courseMetadata');
getCohorts.mockImplementation(() => cohorts);
getCourseHomeCourseMetadata.mockImplementation(() => courseMetadata);
getCohorts.mockImplementation(() => cohorts);
getCourseHomeCourseMetadata.mockImplementation(() => courseMetadata);
render(<PageContainer />);
render(<PageContainer />);
// Look for the org, title, and number of the course, which should be displayed in the Header.
expect(await screen.findByText(`${courseMetadata.org} ${courseMetadata.number}`)).toBeTruthy();
expect(await screen.findByText(courseMetadata.title)).toBeTruthy();
});
// Look for the org, title, and number of the course, which should be displayed in the Header.
expect(await screen.findByText(`${courseMetadata.org} ${courseMetadata.number}`)).toBeTruthy();
expect(await screen.findByText(courseMetadata.title)).toBeTruthy();
});
test('PageContainer renders children nested within it.', async () => {
await act(async () => {
const cohorts = { cohorts: [Factory.build('cohort'), Factory.build('cohort')] };
const courseMetadata = Factory.build('courseMetadata');
const cohorts = { cohorts: [Factory.build('cohort'), Factory.build('cohort')] };
const courseMetadata = Factory.build('courseMetadata');
getCohorts.mockImplementation(() => cohorts);
getCourseHomeCourseMetadata.mockImplementation(() => courseMetadata);
getCohorts.mockImplementation(() => cohorts);
getCourseHomeCourseMetadata.mockImplementation(() => courseMetadata);
render(
<PageContainer>
<span>Test Text</span>
</PageContainer>,
);
render(
<PageContainer>
<span>Test Text</span>
</PageContainer>,
);
expect(await screen.findByText('Test Text')).toBeTruthy();
});
expect(await screen.findByText('Test Text')).toBeTruthy();
});
});

1
src/i18n/index.js Normal file
View File

@@ -0,0 +1 @@
export default [];

View File

@@ -1,32 +0,0 @@
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;

View File

@@ -1 +0,0 @@
{}

View File

@@ -1 +0,0 @@
{}

View File

@@ -1 +0,0 @@
{}

View File

@@ -1 +0,0 @@
{}

View File

@@ -1 +0,0 @@
{}

View File

@@ -1 +0,0 @@
{}

View File

@@ -1 +0,0 @@
{}

View File

@@ -1 +0,0 @@
{}

View File

@@ -1 +0,0 @@
{}

View File

@@ -1 +0,0 @@
{}

View File

@@ -1 +0,0 @@
{}

View File

@@ -1 +0,0 @@
{}

View File

@@ -1 +0,0 @@
{}

View File

@@ -2,40 +2,54 @@ import 'core-js/stable';
import 'regenerator-runtime/runtime';
import {
APP_INIT_ERROR, APP_READY, subscribe, initialize, mergeConfig,
APP_INIT_ERROR, APP_READY, subscribe, initialize, mergeConfig, getConfig,
} from '@edx/frontend-platform';
import { AppProvider, AuthenticatedPageRoute, ErrorPage } from '@edx/frontend-platform/react';
import ReactDOM from 'react-dom';
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { messages as headerMessages } from '@edx/frontend-component-header';
import { messages as footerMessages } from '@edx/frontend-component-footer';
import { Switch } from 'react-router-dom';
import appMessages from './i18n';
import { Helmet } from 'react-helmet';
import { Routes, Route } from 'react-router-dom';
import messages from './i18n';
import './index.scss';
import BulkEmailTool from './components/bulk-email-tool';
import PageContainer from './components/page-container/PageContainer';
subscribe(APP_READY, () => {
ReactDOM.render(
<AppProvider>
<div className="pb-3 container">
<Switch>
<AuthenticatedPageRoute path="/courses/:courseId/bulk_email">
<PageContainer>
<BulkEmailTool />
</PageContainer>
</AuthenticatedPageRoute>
</Switch>
</div>
</AppProvider>,
document.getElementById('root'),
const root = createRoot(document.getElementById('root'));
root.render(
<StrictMode>
<AppProvider>
<Helmet>
<link rel="shortcut icon" href={getConfig().FAVICON_URL} type="image/x-icon" />
</Helmet>
<Routes>
<Route
path="/courses/:courseId/bulk_email"
element={(
<AuthenticatedPageRoute>
<PageContainer>
<BulkEmailTool />
</PageContainer>
</AuthenticatedPageRoute>
)}
/>
</Routes>
</AppProvider>
</StrictMode>,
);
});
subscribe(APP_INIT_ERROR, (error) => {
ReactDOM.render(<ErrorPage message={error.message} />, document.getElementById('root'));
const root = createRoot(document.getElementById('root'));
root.render(
<StrictMode>
<ErrorPage message={error.message} />
</StrictMode>,
);
});
initialize({
@@ -50,5 +64,5 @@ initialize({
);
},
},
messages: [appMessages, headerMessages, footerMessages],
messages,
});

View File

@@ -1,7 +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/styles/css/core/custom-media-breakpoints" as paragonCustomMediaBreakpoints;
@import "~@edx/frontend-component-header/dist/index";
@import "~@edx/frontend-component-footer/dist/footer";

67
src/index.test.jsx Normal file
View File

@@ -0,0 +1,67 @@
import {
APP_INIT_ERROR, APP_READY, subscribe,
} from '@edx/frontend-platform';
// Jest needs this for module resolution
import * as app from '.'; // eslint-disable-line @typescript-eslint/no-unused-vars
// These need to be var not let so they get hoisted
// and can be used by jest.mock (which is also hoisted)
var mockRender; // eslint-disable-line no-var
var mockCreateRoot; // eslint-disable-line no-var
jest.mock('react-dom/client', () => {
mockRender = jest.fn();
mockCreateRoot = jest.fn(() => ({
render: mockRender,
}));
return ({
createRoot: mockCreateRoot,
});
});
jest.mock('@edx/frontend-platform', () => ({
APP_READY: 'app-is-ready-key',
APP_INIT_ERROR: 'app-init-error',
subscribe: jest.fn(),
initialize: jest.fn(),
mergeConfig: jest.fn(),
getConfig: () => ({
FAVICON_URL: 'favicon-url',
}),
ensureConfig: jest.fn(),
}));
jest.mock('./components/bulk-email-tool/BulkEmailTool', () => 'Bulk Email Tool');
jest.mock('./components/page-container/PageContainer', () => 'Page Container');
describe('app registry', () => {
let getElement;
beforeEach(() => {
mockCreateRoot.mockClear();
mockRender.mockClear();
getElement = window.document.getElementById;
window.document.getElementById = jest.fn(id => ({ id }));
});
afterAll(() => {
window.document.getElementById = getElement;
});
test('subscribe: APP_READY. links App to root element', () => {
const callArgs = subscribe.mock.calls[0];
expect(callArgs[0]).toEqual(APP_READY);
callArgs[1]();
const [rendered] = mockRender.mock.calls[0];
expect(rendered).toMatchSnapshot();
});
test('subscribe: APP_INIT_ERROR. snapshot: displays an ErrorPage to root element', () => {
const callArgs = subscribe.mock.calls[1];
expect(callArgs[0]).toEqual(APP_INIT_ERROR);
const error = { message: 'test-error-message' };
callArgs[1](error);
const [rendered] = mockRender.mock.calls[0];
expect(rendered).toMatchSnapshot();
});
});

View File

@@ -0,0 +1,53 @@
# Footer Slot
### Slot ID: `org.openedx.frontend.layout.footer.v1`
### Slot ID Aliases
* `footer_slot`
## Description
This slot is used to replace/modify/hide the footer.
The implementation of the `FooterSlot` component lives in [the `frontend-component-footer` repository](https://github.com/openedx/frontend-component-footer/).
## Example
The following `env.config.jsx` will replace the default footer.
![Screenshot of Default Footer](./images/default_footer.png)
with a simple custom footer
![Screenshot of Custom Footer](./images/custom_footer.png)
```jsx
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
const config = {
pluginSlots: {
'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;
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -0,0 +1,3 @@
# `frontend-app-communications` Plugin Slots
* [`org.openedx.frontend.layout.footer.v1`](./FooterSlot/)

View File

@@ -8,7 +8,13 @@ import { configure as configureI18n, IntlProvider } from '@edx/frontend-platform
import { configure as configureLogging, MockLoggingService } from '@edx/frontend-platform/logging';
import { getConfig, mergeConfig } from '@edx/frontend-platform';
import { configure as configureAuth, MockAuthService } from '@edx/frontend-platform/auth';
import appMessages from './i18n';
import messages from './i18n';
jest.mock('@edx/frontend-platform/react/hooks', () => ({
...jest.requireActual('@edx/frontend-platform/react/hooks'),
useTrackColorSchemeChoice: jest.fn(),
useParagonTheme: () => [{ isThemeLoaded: true }, jest.fn()],
}));
Object.defineProperty(window, 'matchMedia', {
writable: true,
@@ -24,6 +30,8 @@ Object.defineProperty(window, 'matchMedia', {
})),
});
global.Date.prototype.toLocaleDateString = jest.fn();
export function initializeMockApp() {
mergeConfig({
// MICROBA-1505: Remove this when we remove the flag from config
@@ -43,7 +51,7 @@ export function initializeMockApp() {
const i18nService = configureI18n({
config: getConfig(),
loggingService,
messages: [appMessages],
messages,
});
const authService = configureAuth(MockAuthService, { config: getConfig(), loggingService });

View File

@@ -37,6 +37,7 @@ export default function useMobileResponsive(breakpoint) {
window.addEventListener('resize', checkForMobile);
// return this function here to clean up the event listener
return () => window.removeEventListener('resize', checkForMobile);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return isMobileWindow;
}

13
tsconfig.json Normal file
View File

@@ -0,0 +1,13 @@
{
"extends": "@edx/typescript-config",
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"*": ["*"]
},
"rootDir": ".",
"outDir": "dist"
},
"include": ["*.js", ".eslintrc.js", "src/**/*", "plugins/**/*", "jest.config.ts"],
"exclude": ["*.js", ".eslintrc.js", "dist", "node_modules"]
}

View File

@@ -1,4 +1,4 @@
const { createConfig } = require('@edx/frontend-build');
const { createConfig } = require('@openedx/frontend-build');
const config = createConfig('webpack-dev');
@@ -22,8 +22,13 @@ const webpack5esmInteropRule = {
},
};
const rawAssetRule = {
resourceQuery: /raw/,
type: 'asset/source',
};
const otherRules = config.module.rules;
config.module.rules = [webpack5esmInteropRule, ...otherRules];
config.module.rules = [rawAssetRule, webpack5esmInteropRule, ...otherRules];
module.exports = config;

View File

@@ -1,4 +1,4 @@
const { createConfig } = require('@edx/frontend-build');
const { createConfig } = require('@openedx/frontend-build');
const config = createConfig('webpack-prod');
@@ -14,8 +14,13 @@ const webpack5esmInteropRule = {
},
};
const rawAssetRule = {
resourceQuery: /raw/,
type: 'asset/source',
};
const otherRules = config.module.rules;
config.module.rules = [webpack5esmInteropRule, ...otherRules];
config.module.rules = [rawAssetRule, webpack5esmInteropRule, ...otherRules];
module.exports = config;