@edx/frontend-plugin-learner-dashboard 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +10 -0
- package/.env +22 -0
- package/.env.development +23 -0
- package/.env.test +21 -0
- package/.eslintrc.js +4 -0
- package/.github/workflows/add-depr-ticket-to-depr-board.yml +19 -0
- package/.github/workflows/add-remove-label-on-comment.yml +20 -0
- package/.github/workflows/ci.yml +31 -0
- package/.github/workflows/commitlint.yml +10 -0
- package/.github/workflows/lockfileversion-check.yml +13 -0
- package/.github/workflows/release.yml +27 -0
- package/.github/workflows/self-assign-issue.yml +12 -0
- package/.github/workflows/update-browserslist-db.yml +12 -0
- package/.nvmrc +1 -0
- package/.releaserc +29 -0
- package/LICENSE +661 -0
- package/README.rst +107 -0
- package/catalog-info.yaml +16 -0
- package/codecov.yml +10 -0
- package/docs/decisions/0001-record-architecture-decisions.rst +32 -0
- package/docs/decisions/0002-feature-based-application-organization.rst +213 -0
- package/jest.config.js +13 -0
- package/module.config.js.example +31 -0
- package/package.json +67 -0
- package/renovate.json +33 -0
- package/src/assets/.gitkeep +0 -0
- package/src/career-menu/index.jsx +45 -0
- package/src/career-menu/index.test.jsx +41 -0
- package/src/career-menu/messages.js +16 -0
- package/src/dashboard-menu/index.jsx +54 -0
- package/src/dashboard-menu/index.test.jsx +42 -0
- package/src/dashboard-menu/messages.js +21 -0
- package/src/index.jsx +4 -0
- package/src/setupTest.js +2 -0
package/README.rst
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
frontend-plugin-learner-dashboard
|
|
2
|
+
#############################
|
|
3
|
+
|
|
4
|
+
|license-badge| |status-badge| |ci-badge|
|
|
5
|
+
|
|
6
|
+
.. |license-badge| image:: https://img.shields.io/badge/license-AGPL-informational
|
|
7
|
+
:target: https://github.com/edx/frontend-plugin-learner-dashboard/blob/main/LICENSE
|
|
8
|
+
:alt: License
|
|
9
|
+
|
|
10
|
+
.. |status-badge| image:: https://img.shields.io/badge/Status-Maintained-brightgreen
|
|
11
|
+
|
|
12
|
+
.. |ci-badge| image:: https://github.com/edx/frontend-plugin-learner-dashboard/actions/workflows/ci.yml/badge.svg
|
|
13
|
+
:target: https://github.com/edx/frontend-plugin-learner-dashboard/actions/workflows/ci.yml
|
|
14
|
+
:alt: Continuous Integration
|
|
15
|
+
|
|
16
|
+
Purpose
|
|
17
|
+
=======
|
|
18
|
+
|
|
19
|
+
This is the repository for storing Learner Dashboard MFE's frontend plugins. These plugins are intended to be used with
|
|
20
|
+
the `frontend-plugin-framework`_.
|
|
21
|
+
|
|
22
|
+
.. _frontend-plugin-framework: https://github.com/openedx/frontend-plugin-framework
|
|
23
|
+
|
|
24
|
+
Getting Started
|
|
25
|
+
===============
|
|
26
|
+
|
|
27
|
+
Devstack Installation
|
|
28
|
+
---------------------
|
|
29
|
+
|
|
30
|
+
These plugins are intended to be used with Learner Dashboard MFE. Make sure to follow the instructions on the MFE's
|
|
31
|
+
repository README for getting set up in a devstack.
|
|
32
|
+
|
|
33
|
+
Local Development
|
|
34
|
+
-----------------
|
|
35
|
+
|
|
36
|
+
Clone this repository into your main workspace folder so it is a sibling of the Learner Dashboard MFE.
|
|
37
|
+
|
|
38
|
+
Insert the following into the ``env.config.js`` file of Learner Dashboard MFE. If you haven't created one, create one
|
|
39
|
+
in the root that includes the following::
|
|
40
|
+
|
|
41
|
+
// Imports from frontend-plugin-framework
|
|
42
|
+
import { PLUGIN_OPERATIONS, DIRECT_PLUGIN } from '@openedx/frontend-plugin-framework';
|
|
43
|
+
|
|
44
|
+
// Import any of the exported plugin components from the npm package
|
|
45
|
+
import { PluginComponent } from '@edx/frontend-plugin-learner-dashboard';
|
|
46
|
+
|
|
47
|
+
const config = {
|
|
48
|
+
pluginSlots: {
|
|
49
|
+
|
|
50
|
+
// Add configuration for each pluginSlot
|
|
51
|
+
|
|
52
|
+
widget_sidebar_plugin_slot: { // this is the ID for the <PluginSlot> component in the MFE
|
|
53
|
+
plugins: [{
|
|
54
|
+
op: PLUGIN_OPERATIONS.Insert,
|
|
55
|
+
keepDefault: false, // removes any children components in the PluginSlot
|
|
56
|
+
widget: {
|
|
57
|
+
id: 'id_of_plugin_component',
|
|
58
|
+
type: DIRECT_PLUGIN,
|
|
59
|
+
priority: 60,
|
|
60
|
+
RenderWidget: PluginComponent,
|
|
61
|
+
},
|
|
62
|
+
}],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default config;
|
|
68
|
+
|
|
69
|
+
To develop while using this plugin library, modify the ``module.config.js`` file in the root of the MFE you are
|
|
70
|
+
developing in to reference the local version of the plugin.::
|
|
71
|
+
|
|
72
|
+
module.exports = {
|
|
73
|
+
localModules: [
|
|
74
|
+
// Add the below object to the localModules array
|
|
75
|
+
{
|
|
76
|
+
moduleName: '@edx/frontend-plugin-learner-dashboard',
|
|
77
|
+
dir: '../src/frontend-plugin-learner-dashboard',
|
|
78
|
+
dist: 'dist'
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
License
|
|
84
|
+
=======
|
|
85
|
+
|
|
86
|
+
The code in this repository is licensed under the AGPLv3 unless otherwise
|
|
87
|
+
noted.
|
|
88
|
+
|
|
89
|
+
Please see `LICENSE <LICENSE>`_ for details.
|
|
90
|
+
|
|
91
|
+
Contributing
|
|
92
|
+
============
|
|
93
|
+
|
|
94
|
+
Before considering whether or not something belongs in this repository, use the `plugins decision tree`_ to see ensure
|
|
95
|
+
it is the correct place.
|
|
96
|
+
|
|
97
|
+
.. _plugins decision tree: https://2u-internal.atlassian.net/wiki/spaces/microb/pages/597590081/Frontend+Plugin+Framework#Implementation
|
|
98
|
+
|
|
99
|
+
People
|
|
100
|
+
======
|
|
101
|
+
|
|
102
|
+
Contact @edx/edx-aperture if you are having any trouble developing in this repository.
|
|
103
|
+
|
|
104
|
+
Reporting Security Issues
|
|
105
|
+
=========================
|
|
106
|
+
|
|
107
|
+
Please do not report security issues in public. Email security@edx.org instead.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# This file records information about this repo. Its use is described in OEP-55:
|
|
2
|
+
# https://open-edx-proposals.readthedocs.io/en/latest/processes/oep-0055-proc-project-maintainers.html
|
|
3
|
+
|
|
4
|
+
apiVersion: backstage.io/v1alpha1
|
|
5
|
+
kind: Component
|
|
6
|
+
metadata:
|
|
7
|
+
name: "frontend-plugin-learner-dashboard"
|
|
8
|
+
description: "A repository for Learner Dashboard MFE's frontend plugins."
|
|
9
|
+
links:
|
|
10
|
+
- url: "https://github.com/edx/frontend-plugin-learner-dashboard/blob/master/README.rst"
|
|
11
|
+
title: "README"
|
|
12
|
+
icon: "Article"
|
|
13
|
+
spec:
|
|
14
|
+
owner: group:aperture
|
|
15
|
+
type: "plugin"
|
|
16
|
+
lifecycle: "experimental"
|
package/codecov.yml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
1. Record Architecture Decisions
|
|
2
|
+
--------------------------------
|
|
3
|
+
|
|
4
|
+
Status
|
|
5
|
+
------
|
|
6
|
+
|
|
7
|
+
Accepted
|
|
8
|
+
|
|
9
|
+
Context
|
|
10
|
+
-------
|
|
11
|
+
|
|
12
|
+
We would like to keep a historical record on the architectural
|
|
13
|
+
decisions we make with this app as it evolves over time.
|
|
14
|
+
|
|
15
|
+
Decision
|
|
16
|
+
--------
|
|
17
|
+
|
|
18
|
+
We will use Architecture Decision Records, as described by
|
|
19
|
+
Michael Nygard in `Documenting Architecture Decisions`_
|
|
20
|
+
|
|
21
|
+
.. _Documenting Architecture Decisions: http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-decisions
|
|
22
|
+
|
|
23
|
+
Consequences
|
|
24
|
+
------------
|
|
25
|
+
|
|
26
|
+
See Michael Nygard's article, linked above.
|
|
27
|
+
|
|
28
|
+
References
|
|
29
|
+
----------
|
|
30
|
+
|
|
31
|
+
* https://resources.sei.cmu.edu/asset_files/Presentation/2017_017_001_497746.pdf
|
|
32
|
+
* https://github.com/npryce/adr-tools/tree/master/doc/adr
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
2. Feature-based Application Organization
|
|
2
|
+
-----------------------------------------
|
|
3
|
+
|
|
4
|
+
Status
|
|
5
|
+
------
|
|
6
|
+
|
|
7
|
+
Proposed
|
|
8
|
+
|
|
9
|
+
Context
|
|
10
|
+
-------
|
|
11
|
+
|
|
12
|
+
The common, naive approach to organizing React/Redux applications says that code should be grouped into folders by type, putting like-types of code together. This means having directories like:
|
|
13
|
+
|
|
14
|
+
- components
|
|
15
|
+
- actions
|
|
16
|
+
- reducers
|
|
17
|
+
- constants
|
|
18
|
+
- selectors
|
|
19
|
+
- sagas
|
|
20
|
+
- services
|
|
21
|
+
|
|
22
|
+
This is often referred to as a "Ruby on Rails" approach, which organizes applications similarly.
|
|
23
|
+
|
|
24
|
+
As applications grow, it's acknowledged by the community that this organization starts to fall down and become difficult to maintain. It does nothing to help engineers keep their code modular and decoupled, as it groups code by how it looks and not how it's used. Code that functions as part of a unit is spread out over 7+ directories.
|
|
25
|
+
|
|
26
|
+
This ADR documents an approach and rules of thumb for organizing code modularly by feature, informed by articles and prior art.
|
|
27
|
+
|
|
28
|
+
Note on terminology: "feature" and "module" are used interchangeably in this ADR. In general, the feature refers to the semantically significant thing, whereas the module refers to the directory of code pertaining to that feature.
|
|
29
|
+
|
|
30
|
+
Decision
|
|
31
|
+
--------
|
|
32
|
+
|
|
33
|
+
**Following the spirit of these principles is more important than following them to the letter.**
|
|
34
|
+
|
|
35
|
+
These rules are guidelines. It won't always be reasonable or necessary to follow them to the letter. They provide a set of tools for dealing with complexity. It follows, then, that if you don't have complexity, then you may not need the tools.
|
|
36
|
+
|
|
37
|
+
Primary guiding principles
|
|
38
|
+
==========================
|
|
39
|
+
|
|
40
|
+
**1. Code is organized into feature directories.**
|
|
41
|
+
|
|
42
|
+
A feature is a logical or semantically significant grouping of code; what comprises a feature is subjective. It also may not be obvious at first - if code tends to be related or change together, then it's probably part of the same feature.
|
|
43
|
+
|
|
44
|
+
It's unlikely to be worth agonizing over your feature breakdown; time will tell what's correct moreso than overthinking it. That said, a sufficiently complex set of features will need a similarly robust taxonomy and organizational hierarchy. (This document endeavors to help inform that hierarchy.) A nice rule of thumb is that a feature should conceptually be able to be extracted into its own npm package with minimal effort.
|
|
45
|
+
|
|
46
|
+
**2. Create strict module boundaries**
|
|
47
|
+
|
|
48
|
+
A module should have a public interface exposed via an index.js file in the module directory. Consumers of a feature should limit themselves to importing only from the public exports.
|
|
49
|
+
|
|
50
|
+
::
|
|
51
|
+
|
|
52
|
+
import { MyComponent, reducer as myComponentReducer } from './submodule'; // Good
|
|
53
|
+
import MyComponent from './submodule/MyComponent'; // Bad
|
|
54
|
+
import reducer from './submodule/data/reducers'; // Bad
|
|
55
|
+
|
|
56
|
+
Modules are configured by their parent. Generally a module will expose a few things which need to be configured make use of them in the consuming code. The reason for doing this is so that the module doesn't make assumptions about it's context (effectively dependency injection).
|
|
57
|
+
|
|
58
|
+
Examples:
|
|
59
|
+
|
|
60
|
+
* For React components, this involves including them in JSX and giving them props.
|
|
61
|
+
* For services, this is calling their "configure" method and providing them apiClient/configuration, etc.
|
|
62
|
+
* For reducers, this is mounting the reducer at an agreed-upon place in the redux store's state tree.
|
|
63
|
+
|
|
64
|
+
**3. Avoid circular dependencies**
|
|
65
|
+
|
|
66
|
+
Circular dependencies are unresolvable in webpack, and will result in something being imported as 'undefined'. They're also incredibly difficult and frustrating to track down. Properly factoring your features and supporting modules should help avoid these sorts of issues. In general, a feature should never need to import from its parent or grandparents, and a more "general purpose" module should never be importing from a more specific one. If you find yourself importing from a domain-specific feature in your general utility module, then something is probably ill-factored.
|
|
67
|
+
|
|
68
|
+
File and directory naming
|
|
69
|
+
=========================
|
|
70
|
+
|
|
71
|
+
This section details a specific taxonomy and hierarchy to help make code modular, approachable and maintainable.
|
|
72
|
+
|
|
73
|
+
**A. Separate data management from components.**
|
|
74
|
+
|
|
75
|
+
In order to isolate our view layer (React) from the management of our data, global state, APIs, and side effects, we want to adopt the "ducks" organization (see references). This involves isolating data management into a
|
|
76
|
+
sub directory of a feature. We'll use the directory name "data" rather than the traditional "ducks".
|
|
77
|
+
|
|
78
|
+
**B. React components will be named semantically.**
|
|
79
|
+
|
|
80
|
+
The convention for React components is for the file to be named for what the component does, so we will preserve this. A given feature may break up its view layer into multiple sub-components without a sub-feature being present.
|
|
81
|
+
|
|
82
|
+
**C. Files in a module's data directory are named by function.**
|
|
83
|
+
|
|
84
|
+
In the data sub-directory, the file names describe what each piece of code does. Unlike React components, all of the data handlers (actions, reducers, sagas, selectors, services, etc.) are generally short functions, and so we put them all in the same file together with others of their kind.
|
|
85
|
+
|
|
86
|
+
::
|
|
87
|
+
|
|
88
|
+
/profile
|
|
89
|
+
/index.js // public interface
|
|
90
|
+
/ProfilePage.jsx // view
|
|
91
|
+
/ProfilePhotoUploader.jsx // supporting view
|
|
92
|
+
/data // Note: most files here are named with a plural, as they contain many of the things in question.
|
|
93
|
+
/actions.js
|
|
94
|
+
/constants.js
|
|
95
|
+
/reducers.js
|
|
96
|
+
/sagas.js
|
|
97
|
+
/selectors.js
|
|
98
|
+
/service.js // Note: singular - there's one 'service' here that provides many methods.
|
|
99
|
+
|
|
100
|
+
If you find yourself desiring to have multiple files of a particular type in the data directory, this is a strong sign that you actually need a sub-feature instead.
|
|
101
|
+
|
|
102
|
+
**D. Sub-features follow the same naming scheme.**
|
|
103
|
+
|
|
104
|
+
Sub-features should follow the same rules as any other module.
|
|
105
|
+
|
|
106
|
+
A module with a sub-module:
|
|
107
|
+
|
|
108
|
+
::
|
|
109
|
+
|
|
110
|
+
/profile
|
|
111
|
+
/index.js // public interface
|
|
112
|
+
/ProfilePage.jsx
|
|
113
|
+
/Avatar.jsx // additional components for a feature reside here at the top level, not in a "components" subdirectory.
|
|
114
|
+
/data
|
|
115
|
+
/actions.js
|
|
116
|
+
/reducers.js
|
|
117
|
+
/sagas.js
|
|
118
|
+
/service.js
|
|
119
|
+
/profile-photo
|
|
120
|
+
/index.js // public interface
|
|
121
|
+
/ProfilePhoto.jsx
|
|
122
|
+
/data
|
|
123
|
+
/actions.js
|
|
124
|
+
/reducers.js
|
|
125
|
+
/selectors.js
|
|
126
|
+
/education // Sparse sub-module
|
|
127
|
+
/index.js // public interface
|
|
128
|
+
/Education.jsx
|
|
129
|
+
/site-language // No view layer sub-module
|
|
130
|
+
/index.js // public interface
|
|
131
|
+
/data
|
|
132
|
+
/actions.js
|
|
133
|
+
/reducers.js
|
|
134
|
+
|
|
135
|
+
Note that a given feature need not contain files of all types, nor is having files of all types a prerequisite for having a feature. A feature may not contain a view (Component) layer, or in contrast to that, may not need a data directory at all!
|
|
136
|
+
|
|
137
|
+
Importing rules of thumb
|
|
138
|
+
========================
|
|
139
|
+
|
|
140
|
+
It can be difficult to figure out where it's okay to import from. Following these rules of thumb will help maintain a healthy code organization and should prevent the possibility of circular dependencies.
|
|
141
|
+
|
|
142
|
+
**I. A feature may not import from its parentage.**
|
|
143
|
+
|
|
144
|
+
As described above in "Avoid circular dependencies", features should not import from their parent, grandparent, etc. A feature should be agnostic to the context in which it is used. If a module is importing from its parent or grandparent, that implies something is ill-factored.
|
|
145
|
+
|
|
146
|
+
**II. A feature may import from its children, but not its grandchildren.**
|
|
147
|
+
|
|
148
|
+
The feature may only import from the exports of its child, which may include exports of the grandchildren. Importing directly from grandchildren (or great grandchildren, etc.) would violate the strict module boundary of the child.
|
|
149
|
+
|
|
150
|
+
**III. Features may import from their siblings.**
|
|
151
|
+
|
|
152
|
+
It's acceptable to import from a module's siblings, or the siblings of their parents, grandparents, etc. This is necessary to support code re-use. As an example, assume we have a sub-module with common code to support our web forms.
|
|
153
|
+
|
|
154
|
+
::
|
|
155
|
+
|
|
156
|
+
/feature1
|
|
157
|
+
/sub-form-1
|
|
158
|
+
/sub-form-2
|
|
159
|
+
/forms-common-code
|
|
160
|
+
|
|
161
|
+
The sub-form modules can import from forms-common-code. The latter has its own strict module boundary and could conceptually be extracted into its own repository/completely independent module as far as they're concerned. They're unaware, conceptually, that it's a child of feature1, and they don't care.
|
|
162
|
+
|
|
163
|
+
**IV. Features may import from the siblings of their parentage.**
|
|
164
|
+
|
|
165
|
+
This is less intuitive, but is not really any different than the above.
|
|
166
|
+
|
|
167
|
+
If another feature (feature2) also needs forms-common-code, it should be brought up a level so it's available to feature2, as feature2 cannot "reach into" feature1:
|
|
168
|
+
|
|
169
|
+
::
|
|
170
|
+
|
|
171
|
+
/feature1
|
|
172
|
+
/sub-form-1
|
|
173
|
+
/sub-form-2
|
|
174
|
+
/forms-common-code
|
|
175
|
+
/feature2 // can now use forms-common-code
|
|
176
|
+
|
|
177
|
+
In a complex app, you could imagine that forms-common-code needs to be brought up several levels, in which case our imports might look like:
|
|
178
|
+
|
|
179
|
+
::
|
|
180
|
+
|
|
181
|
+
import { formStuff } from '../../../forms-common-code';
|
|
182
|
+
|
|
183
|
+
This is okay. Conceptually it's no different than importing from a third party npm package, we just happen to know the code we want is up a few directories nearby, rather than using the syntactic sugar of a pathless import from node_modules.
|
|
184
|
+
|
|
185
|
+
At some point, if forms-common-code is general purpose enough, we may want to extract it from this repository/set of features all together.
|
|
186
|
+
|
|
187
|
+
Consequences
|
|
188
|
+
------------
|
|
189
|
+
|
|
190
|
+
This organization has been implemented in several of our micro-frontends so far (frontend-app-account and frontend-app-payment most significantly) and we feel it has improved the organization and approachability of the apps. When converting frontend-app-account to use this organization, it took 2-3 days to refactor the code.
|
|
191
|
+
|
|
192
|
+
It's worth noting that to get this right, it may actually involve changing the way the modules interact with each other. It isn't as simple as just moving files around and copy/pasting code. For instance, in frontend-app-account, it became obvious very quickly that to create strict module boundaries, we had to change the way that our service layers (server requests) were configured to keep them from importing their own configuration from their parent/grandparent. Similarly, our redux store tree of reducers became more complex and deeply nested.
|
|
193
|
+
|
|
194
|
+
References
|
|
195
|
+
----------
|
|
196
|
+
|
|
197
|
+
Articles on react/redux application organization:
|
|
198
|
+
|
|
199
|
+
* Primary reference:
|
|
200
|
+
|
|
201
|
+
- https://jaysoo.ca/2016/02/28/organizing-redux-application/
|
|
202
|
+
|
|
203
|
+
* Ducks references:
|
|
204
|
+
|
|
205
|
+
- https://github.com/erikras/ducks-modular-redux
|
|
206
|
+
- https://medium.freecodecamp.org/scaling-your-redux-app-with-ducks-6115955638be
|
|
207
|
+
|
|
208
|
+
* Other reading:
|
|
209
|
+
|
|
210
|
+
- https://hackernoon.com/fractal-a-react-app-structure-for-infinite-scale-4dab943092af
|
|
211
|
+
- https://marmelab.com/blog/2015/12/17/react-directory-structure.html
|
|
212
|
+
- https://redux.js.org/faq/code-structure
|
|
213
|
+
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { createConfig } = require('@openedx/frontend-build');
|
|
2
|
+
|
|
3
|
+
module.exports = createConfig('jest', {
|
|
4
|
+
// setupFilesAfterEnv is used after the jest environment has been loaded. In general this is what you want.
|
|
5
|
+
// If you want to add config BEFORE jest loads, use setupFiles instead.
|
|
6
|
+
setupFilesAfterEnv: [
|
|
7
|
+
'<rootDir>/src/setupTest.js',
|
|
8
|
+
],
|
|
9
|
+
coveragePathIgnorePatterns: [
|
|
10
|
+
'src/setupTest.js',
|
|
11
|
+
'src/i18n',
|
|
12
|
+
],
|
|
13
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
/*
|
|
3
|
+
Modules you want to use from local source code. Adding a module here means that when this app
|
|
4
|
+
runs its build, it'll resolve the source from peer directories of this app.
|
|
5
|
+
|
|
6
|
+
moduleName: the name you use to import code from the module.
|
|
7
|
+
dir: The relative path to the module's source code.
|
|
8
|
+
dist: The sub-directory of the source code where it puts its build artifact. Often "dist".
|
|
9
|
+
|
|
10
|
+
To use a module config:
|
|
11
|
+
|
|
12
|
+
1. Copy module.config.js.example and remove the '.example' extension
|
|
13
|
+
2. Uncomment modules below in the localModules array to load them from local source code.
|
|
14
|
+
3. Remember to re-build the production builds of those local modules if they have one.
|
|
15
|
+
See note below.
|
|
16
|
+
*/
|
|
17
|
+
localModules: [
|
|
18
|
+
/*********************************************************************************************
|
|
19
|
+
IMPORTANT NOTE: If any of the below packages (like paragon or frontend-platform) have a build
|
|
20
|
+
step that populates their 'dist' directories, you must manually run that step. For paragon
|
|
21
|
+
and frontend-platform, for instance, you need to run `npm run build` in the repo before
|
|
22
|
+
module.config.js will work.
|
|
23
|
+
**********************************************************************************************/
|
|
24
|
+
|
|
25
|
+
// { moduleName: '@edx/brand', dir: '../brand-openedx' }, // replace with your brand checkout
|
|
26
|
+
// { moduleName: '@openedx/paragon/scss/core', dir: '../paragon', dist: 'scss/core' },
|
|
27
|
+
// { moduleName: '@openedx/paragon/icons', dir: '../paragon', dist: 'icons' },
|
|
28
|
+
// { moduleName: '@openedx/paragon', dir: '../paragon', dist: 'dist' },
|
|
29
|
+
// { moduleName: '@edx/frontend-platform', dir: '../frontend-platform', dist: 'dist' },
|
|
30
|
+
],
|
|
31
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@edx/frontend-plugin-learner-dashboard",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Repository for Learner Dashboard MFE frontend plugins",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/edx/frontend-plugin-learner-dashboard.git"
|
|
9
|
+
},
|
|
10
|
+
"browserslist": [
|
|
11
|
+
"extends @edx/browserslist-config"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "make build",
|
|
15
|
+
"i18n_extract": "fedx-scripts formatjs extract",
|
|
16
|
+
"lint": "fedx-scripts eslint --ext .js --ext .jsx .",
|
|
17
|
+
"lint:fix": "fedx-scripts eslint --fix --ext .js --ext .jsx .",
|
|
18
|
+
"snapshot": "fedx-scripts jest --updateSnapshot",
|
|
19
|
+
"test": "fedx-scripts jest --coverage --passWithNoTests"
|
|
20
|
+
},
|
|
21
|
+
"husky": {
|
|
22
|
+
"hooks": {
|
|
23
|
+
"pre-commit": "npm run lint"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"author": "edX",
|
|
27
|
+
"license": "AGPL-3.0",
|
|
28
|
+
"homepage": "https://github.com/edx/frontend-plugin-learner-dashboard#readme",
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/edx/frontend-plugin-learner-dashboard/issues"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
37
|
+
"lodash": "^4.17.21",
|
|
38
|
+
"react-dom": "17.0.2",
|
|
39
|
+
"react-responsive": "^10.0.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@edx/browserslist-config": "^1.1.1",
|
|
43
|
+
"@edx/reactifex": "^2.1.1",
|
|
44
|
+
"@openedx/frontend-build": "14.0.14",
|
|
45
|
+
"@testing-library/jest-dom": "^5.17.0",
|
|
46
|
+
"@testing-library/react": "^12.1.5",
|
|
47
|
+
"glob": "7.2.3",
|
|
48
|
+
"husky": "7.0.4",
|
|
49
|
+
"jest": "29.7.0",
|
|
50
|
+
"rosie": "2.1.1",
|
|
51
|
+
"semantic-release": "^21.0.7"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"@edx/brand": "npm:@openedx/brand-openedx@^1.2.2",
|
|
55
|
+
"@edx/frontend-platform": "^8.1.0",
|
|
56
|
+
"@fortawesome/fontawesome-svg-core": "1.2.36",
|
|
57
|
+
"@fortawesome/free-brands-svg-icons": "5.15.4",
|
|
58
|
+
"@fortawesome/free-regular-svg-icons": "5.15.4",
|
|
59
|
+
"@fortawesome/free-solid-svg-icons": "5.15.4",
|
|
60
|
+
"@fortawesome/react-fontawesome": "0.2.2",
|
|
61
|
+
"@openedx/paragon": "^22.7.0",
|
|
62
|
+
"core-js": "3.37.1",
|
|
63
|
+
"prop-types": "15.8.1",
|
|
64
|
+
"react": "17.0.2",
|
|
65
|
+
"regenerator-runtime": "0.14.1"
|
|
66
|
+
}
|
|
67
|
+
}
|
package/renovate.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": [
|
|
3
|
+
"config:base",
|
|
4
|
+
"schedule:weekly",
|
|
5
|
+
":automergeLinters",
|
|
6
|
+
":automergeMinor",
|
|
7
|
+
":automergeTesters",
|
|
8
|
+
":enableVulnerabilityAlerts",
|
|
9
|
+
":rebaseStalePrs",
|
|
10
|
+
":semanticCommits",
|
|
11
|
+
":updateNotScheduled"
|
|
12
|
+
],
|
|
13
|
+
"packageRules": [
|
|
14
|
+
{
|
|
15
|
+
"matchDepTypes": [
|
|
16
|
+
"devDependencies"
|
|
17
|
+
],
|
|
18
|
+
"matchUpdateTypes": [
|
|
19
|
+
"lockFileMaintenance",
|
|
20
|
+
"minor",
|
|
21
|
+
"patch",
|
|
22
|
+
"pin"
|
|
23
|
+
],
|
|
24
|
+
"automerge": true
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"matchPackagePatterns": ["@edx", "@openedx"],
|
|
28
|
+
"matchUpdateTypes": ["minor", "patch"],
|
|
29
|
+
"automerge": true
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"timezone": "America/New_York"
|
|
33
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { getConfig } from '@edx/frontend-platform';
|
|
3
|
+
import { useIntl } from '@edx/frontend-platform/i18n';
|
|
4
|
+
import {
|
|
5
|
+
Badge, breakpoints, Dropdown, useWindowSize,
|
|
6
|
+
} from '@openedx/paragon';
|
|
7
|
+
|
|
8
|
+
import _ from 'lodash';
|
|
9
|
+
|
|
10
|
+
import { reduxHooks } from 'hooks'; // eslint-disable-line
|
|
11
|
+
import messages from './messages';
|
|
12
|
+
|
|
13
|
+
const UserCareerMenu = () => {
|
|
14
|
+
const { formatMessage } = useIntl();
|
|
15
|
+
const { width } = useWindowSize();
|
|
16
|
+
const dashboard = reduxHooks.useEnterpriseDashboardData();
|
|
17
|
+
const isMobile = width <= breakpoints.small.maxWidth;
|
|
18
|
+
|
|
19
|
+
if (_.isEmpty(dashboard) && getConfig().CAREER_LINK_URL) {
|
|
20
|
+
if (!isMobile) {
|
|
21
|
+
return (
|
|
22
|
+
<Dropdown.Item href={`${getConfig().CAREER_LINK_URL}`} key="item-career">
|
|
23
|
+
{formatMessage(messages.career)}
|
|
24
|
+
<Badge className="px-2 mx-2" variant="warning">
|
|
25
|
+
{formatMessage(messages.newAlert)}
|
|
26
|
+
</Badge>
|
|
27
|
+
</Dropdown.Item>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<li className="nav-item" key="item-career">
|
|
33
|
+
<a href={`${getConfig().CAREER_LINK_URL}`} className="nav-link">
|
|
34
|
+
{formatMessage(messages.career)}
|
|
35
|
+
<Badge className="px-2 mx-2" variant="warning">
|
|
36
|
+
{formatMessage(messages.newAlert)}
|
|
37
|
+
</Badge>
|
|
38
|
+
</a>
|
|
39
|
+
</li>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default UserCareerMenu;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mergeConfig } from '@edx/frontend-platform';
|
|
3
|
+
import { injectIntl, IntlProvider } from '@edx/frontend-platform/i18n';
|
|
4
|
+
import {
|
|
5
|
+
screen,
|
|
6
|
+
render,
|
|
7
|
+
} from '@testing-library/react';
|
|
8
|
+
import { reduxHooks } from 'hooks'; // eslint-disable-line
|
|
9
|
+
|
|
10
|
+
import UserCareerMenu from './index'; // eslint-disable-line
|
|
11
|
+
|
|
12
|
+
jest.mock(
|
|
13
|
+
'hooks',
|
|
14
|
+
() => ({
|
|
15
|
+
reduxHooks: { useEnterpriseDashboardData: jest.fn() },
|
|
16
|
+
}),
|
|
17
|
+
{ virtual: true },
|
|
18
|
+
);
|
|
19
|
+
mergeConfig({ CAREER_LINK_URL: 'edx.org/carrer' });
|
|
20
|
+
const IntlUserCareerMenu = injectIntl(UserCareerMenu);
|
|
21
|
+
|
|
22
|
+
describe('User Career Menu', () => {
|
|
23
|
+
const Wrapper = children => (
|
|
24
|
+
// eslint-disable-next-line react/jsx-filename-extension
|
|
25
|
+
<IntlProvider locale="en">
|
|
26
|
+
{children}
|
|
27
|
+
</IntlProvider>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
it('should render carrer menue in the user menue dropdown', () => {
|
|
31
|
+
reduxHooks.useEnterpriseDashboardData.mockReturnValueOnce({
|
|
32
|
+
url: 'url',
|
|
33
|
+
});
|
|
34
|
+
render(Wrapper(<IntlUserCareerMenu />));
|
|
35
|
+
|
|
36
|
+
const careerMenu = screen.getByText('Career');
|
|
37
|
+
const newAlert = screen.getByText('New');
|
|
38
|
+
expect(careerMenu).toBeTruthy();
|
|
39
|
+
expect(newAlert).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineMessages } from '@edx/frontend-platform/i18n';
|
|
2
|
+
|
|
3
|
+
const messages = defineMessages({
|
|
4
|
+
career: {
|
|
5
|
+
id: 'leanerDashboard.menu.career.label',
|
|
6
|
+
defaultMessage: 'Career',
|
|
7
|
+
description: 'The text for the user menu Career navigation link.',
|
|
8
|
+
},
|
|
9
|
+
newAlert: {
|
|
10
|
+
id: 'header.menu.new.label',
|
|
11
|
+
defaultMessage: 'New',
|
|
12
|
+
description: 'The text announcing that an item in the user menu is New',
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export default messages;
|