Cookie cutter boilerplate.
This commit is contained in:
26
.babelrc
Executable file
26
.babelrc
Executable file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"presets": [
|
||||
[
|
||||
"env",
|
||||
{
|
||||
"targets": {
|
||||
"browsers": ["last 2 versions", "ie 11"]
|
||||
}
|
||||
}
|
||||
],
|
||||
"babel-preset-react"
|
||||
],
|
||||
"plugins": [
|
||||
"transform-object-rest-spread",
|
||||
"transform-class-properties"
|
||||
],
|
||||
"env": {
|
||||
"i18n": {
|
||||
"plugins": [
|
||||
["react-intl", {
|
||||
"messagesDir": "./temp"
|
||||
}]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
10
.dockerignore
Executable file
10
.dockerignore
Executable file
@@ -0,0 +1,10 @@
|
||||
node_modules
|
||||
npm-debug.log
|
||||
README.md
|
||||
LICENSE
|
||||
.babelrc
|
||||
.eslintignore
|
||||
.eslintrc.json
|
||||
.gitignore
|
||||
.npmignore
|
||||
commitlint.config.js
|
||||
4
.eslintignore
Executable file
4
.eslintignore
Executable file
@@ -0,0 +1,4 @@
|
||||
coverage/*
|
||||
dist/
|
||||
node_modules/
|
||||
__mocks__/
|
||||
34
.eslintrc
Executable file
34
.eslintrc
Executable file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"extends": "eslint-config-edx",
|
||||
"parser": "babel-eslint",
|
||||
"rules": {
|
||||
"import/no-extraneous-dependencies": [
|
||||
"error",
|
||||
{
|
||||
"devDependencies": [
|
||||
"webpack/*.js",
|
||||
"**/*.test.jsx",
|
||||
"**/*.test.js"
|
||||
]
|
||||
}
|
||||
],
|
||||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/issues/340#issuecomment-338424908
|
||||
"jsx-a11y/anchor-is-valid": [ "error", {
|
||||
"components": [ "Link" ],
|
||||
"specialLink": [ "to" ]
|
||||
}],
|
||||
"jsx-a11y/label-has-for": [ 2, {
|
||||
"components": [ "label" ],
|
||||
"required": {
|
||||
"some": [ "nesting", "id" ]
|
||||
},
|
||||
"allowChildren": false
|
||||
}]
|
||||
},
|
||||
"env": {
|
||||
"jest": true
|
||||
},
|
||||
"globals": {
|
||||
"newrelic": false
|
||||
}
|
||||
}
|
||||
16
.gitignore
vendored
Executable file
16
.gitignore
vendored
Executable file
@@ -0,0 +1,16 @@
|
||||
.DS_Store
|
||||
.eslintcache
|
||||
.idea
|
||||
node_modules
|
||||
npm-debug.log
|
||||
coverage
|
||||
|
||||
dist/
|
||||
|
||||
### pyenv ###
|
||||
.python-version
|
||||
|
||||
### Emacs ###
|
||||
*~
|
||||
/temp
|
||||
/.vscode
|
||||
13
.npmignore
Executable file
13
.npmignore
Executable file
@@ -0,0 +1,13 @@
|
||||
.eslintignore
|
||||
.eslintrc.json
|
||||
.gitignore
|
||||
.travis.yml
|
||||
docker-compose.yml
|
||||
Dockerfile
|
||||
Makefile
|
||||
npm-debug.log
|
||||
|
||||
webpack
|
||||
coverage
|
||||
node_modules
|
||||
public
|
||||
21
.travis.yml
Executable file
21
.travis.yml
Executable file
@@ -0,0 +1,21 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- lts/*
|
||||
cache:
|
||||
directories:
|
||||
- "~/.npm"
|
||||
before_install:
|
||||
- npm install -g npm@latest
|
||||
- npm install -g greenkeeper-lockfile@1.14.0
|
||||
install:
|
||||
- npm ci
|
||||
before_script: greenkeeper-lockfile-update
|
||||
after_script: greenkeeper-lockfile-upload
|
||||
script:
|
||||
- make validate-no-uncommitted-package-lock-changes
|
||||
- npm run lint
|
||||
- npm run test
|
||||
- npm run build
|
||||
after_success:
|
||||
- npm run coveralls
|
||||
- codecov
|
||||
8
.tx/config
Normal file
8
.tx/config
Normal file
@@ -0,0 +1,8 @@
|
||||
[main]
|
||||
host = https://www.transifex.com
|
||||
|
||||
[edx-platform.frontend-app-account]
|
||||
file_filter = src/i18n/messages/<lang>.json
|
||||
source_file = src/i18n/transifex_input.json
|
||||
source_lang = en
|
||||
type = KEYVALUEJSON
|
||||
674
LICENSE
Executable file
674
LICENSE
Executable file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
36
Makefile
Executable file
36
Makefile
Executable file
@@ -0,0 +1,36 @@
|
||||
extract_translations: ## no prerequisites so we can control order of operations
|
||||
echo "We have to define this target due to tooling assumptions"
|
||||
echo "Also we have to npm install using this hook b/c there's no other place for it in the current setup"
|
||||
npm install
|
||||
npm run-script i18n_extract
|
||||
|
||||
i18n.extract:
|
||||
# Pulling display strings from .jsx files into .json files...
|
||||
npm run-script i18n_extract
|
||||
|
||||
i18n.concat:
|
||||
# Gathering JSON messages into one file...
|
||||
./src/i18n/i18n-concat.js ./temp/src ./src/i18n/transifex_input.json
|
||||
|
||||
detect_changed_source_translations:
|
||||
git diff --exit-code ./src/i18n/transifex_input.json
|
||||
|
||||
tx_url1 = https://www.transifex.com/api/2/project/edx-platform/resource/frontend-app-account/translation/en/strings/
|
||||
tx_url2 = https://www.transifex.com/api/2/project/edx-platform/resource/frontend-app-account/source/
|
||||
|
||||
# push translations to Transifex, doing magic so we can include the translator comments
|
||||
push_translations: | i18n.extract
|
||||
# Adding translator comments...
|
||||
# Fetching strings from Transifex...
|
||||
./node_modules/reactifex/bash_scripts/get_hashed_strings.sh $(tx_url1)
|
||||
# Writing out comments to file...
|
||||
./src/i18n/i18n-concat.js ./temp/src --comments
|
||||
# Adding comments to Transifex...
|
||||
./node_modules/reactifex/bash_scripts/put_comments.sh $(tx_url2)
|
||||
|
||||
# pull translations from Transifex
|
||||
pull_translations: ## must be exactly this name for edx tooling support, see ecommerce-scripts/transifex/pull.py
|
||||
tx pull -f --mode reviewed --language="ar,fr,es_419,zh_CN"
|
||||
|
||||
validate-no-uncommitted-package-lock-changes:
|
||||
git diff --exit-code package-lock.json
|
||||
22
README.rst
Normal file
22
README.rst
Normal file
@@ -0,0 +1,22 @@
|
||||
|Build Status| |Coveralls| |npm_version| |npm_downloads| |license|
|
||||
|
||||
frontend-app-account
|
||||
=========================
|
||||
|
||||
Please tag **@edx/arch-team** on any PRs or issues. Thanks.
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
React app for account settings.
|
||||
|
||||
.. |Build Status| image:: https://api.travis-ci.org/edx/frontend-app-account.svg?branch=master
|
||||
:target: https://travis-ci.org/edx/frontend-app-account
|
||||
.. |Coveralls| image:: https://img.shields.io/coveralls/edx/frontend-app-account.svg?branch=master
|
||||
:target: https://coveralls.io/github/edx/frontend-app-account
|
||||
.. |npm_version| image:: https://img.shields.io/npm/v/@edx/frontend-app-account.svg
|
||||
:target: @edx/frontend-app-account
|
||||
.. |npm_downloads| image:: https://img.shields.io/npm/dt/@edx/frontend-app-account.svg
|
||||
:target: @edx/frontend-app-account
|
||||
.. |license| image:: https://img.shields.io/npm/l/@edx/frontend-app-account.svg
|
||||
:target: @edx/frontend-app-account
|
||||
1
__mocks__/fileMock.js
Normal file
1
__mocks__/fileMock.js
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = 'test-file-stub';
|
||||
1
__mocks__/svgrMock.js
Normal file
1
__mocks__/svgrMock.js
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = { ReactComponent: 'IconMock' };
|
||||
32
docs/decisions/0001-record-architecture-decisions.rst
Normal file
32
docs/decisions/0001-record-architecture-decisions.rst
Normal file
@@ -0,0 +1,32 @@
|
||||
1. Record Architecture Decisions
|
||||
--------------------------------
|
||||
|
||||
Status
|
||||
------
|
||||
|
||||
Accepted
|
||||
|
||||
Context
|
||||
-------
|
||||
|
||||
We would like to keep a historical record on the architectural
|
||||
decisions we make with this app as it evolves over time.
|
||||
|
||||
Decision
|
||||
--------
|
||||
|
||||
We will use Architecture Decision Records, as described by
|
||||
Michael Nygard in `Documenting Architecture Decisions`_
|
||||
|
||||
.. _Documenting Architecture Decisions: http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-decisions
|
||||
|
||||
Consequences
|
||||
------------
|
||||
|
||||
See Michael Nygard's article, linked above.
|
||||
|
||||
References
|
||||
----------
|
||||
|
||||
* https://resources.sei.cmu.edu/asset_files/Presentation/2017_017_001_497746.pdf
|
||||
* https://github.com/npryce/adr-tools/tree/master/doc/adr
|
||||
6
openedx.yaml
Normal file
6
openedx.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
# This file describes this Open edX repo, as described in OEP-2:
|
||||
# https://open-edx-proposals.readthedocs.io/en/latest/oep-0002-bp-repo-metadata.html#specification
|
||||
|
||||
nick: acct
|
||||
oeps: {}
|
||||
owner: edx/arch-team
|
||||
22346
package-lock.json
generated
Normal file
22346
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
142
package.json
Executable file
142
package.json
Executable file
@@ -0,0 +1,142 @@
|
||||
{
|
||||
"name": "@edx/frontend-app-account",
|
||||
"version": "0.1.0",
|
||||
"description": "User account React app",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/edx/frontend-app-account.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "NODE_ENV=production BABEL_ENV=production webpack --config=webpack/webpack.prod.config.js",
|
||||
"coveralls": "cat ./coverage/lcov.info | coveralls",
|
||||
"i18n_extract": "BABEL_ENV=i18n babel src --quiet > /dev/null",
|
||||
"is-es5": "es-check es5 ./dist/*.js",
|
||||
"lint": "eslint --ext .js --ext .jsx .",
|
||||
"precommit": "npm run lint",
|
||||
"start": "NODE_ENV=development BABEL_ENV=development webpack-dev-server --config=webpack/webpack.dev.config.js --progress",
|
||||
"test": "jest --coverage --passWithNoTests",
|
||||
"travis-deploy-once": "travis-deploy-once"
|
||||
},
|
||||
"author": "edX",
|
||||
"license": "AGPL-3.0",
|
||||
"homepage": "https://github.com/edx/frontend-app-account#readme",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"@cospired/i18n-iso-languages": "^2.0.2",
|
||||
"@edx/edx-bootstrap": "^2.0.1",
|
||||
"@edx/frontend-analytics": "^1.0.0",
|
||||
"@edx/frontend-auth": "^4.0.0",
|
||||
"@edx/frontend-component-footer": "^2.0.3",
|
||||
"@edx/frontend-component-site-header": "^2.1.4",
|
||||
"@edx/frontend-logging": "^1.0.2",
|
||||
"@edx/paragon": "^4.1.3",
|
||||
"@fortawesome/fontawesome-svg-core": "^1.2.14",
|
||||
"@fortawesome/free-brands-svg-icons": "^5.7.2",
|
||||
"@fortawesome/free-regular-svg-icons": "^5.7.1",
|
||||
"@fortawesome/free-solid-svg-icons": "^5.7.1",
|
||||
"@fortawesome/react-fontawesome": "^0.1.4",
|
||||
"babel-polyfill": "^6.26.0",
|
||||
"classnames": "^2.2.6",
|
||||
"connected-react-router": "^5.0.1",
|
||||
"email-prop-type": "^1.1.5",
|
||||
"font-awesome": "^4.7.0",
|
||||
"form-urlencoded": "^3.0.0",
|
||||
"glob": "^7.1.3",
|
||||
"history": "^4.7.2",
|
||||
"i18n-iso-countries": "^3.7.8",
|
||||
"iso-countries-languages": "^0.2.1",
|
||||
"lodash.camelcase": "^4.3.0",
|
||||
"lodash.get": "^4.4.2",
|
||||
"lodash.pick": "^4.4.0",
|
||||
"lodash.snakecase": "^4.1.1",
|
||||
"newrelic": "^5.5.0",
|
||||
"prop-types": "^15.5.10",
|
||||
"react": "^16.8.3",
|
||||
"react-dom": "^16.8.3",
|
||||
"react-intl": "^2.8.0",
|
||||
"react-redux": "^5.1.1",
|
||||
"react-router": "^4.2.0",
|
||||
"react-router-dom": "^4.2.2",
|
||||
"react-transition-group": "^2.5.3",
|
||||
"redux": "^4.0.1",
|
||||
"redux-devtools-extension": "^2.13.2",
|
||||
"redux-logger": "^3.0.6",
|
||||
"redux-saga": "^1.0.1",
|
||||
"redux-thunk": "^2.2.0",
|
||||
"reselect": "^4.0.0",
|
||||
"universal-cookie": "^3.1.0",
|
||||
"webpack-rtl-plugin": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@svgr/webpack": "^4.2.0",
|
||||
"autoprefixer": "^9.4.2",
|
||||
"axios-mock-adapter": "^1.15.0",
|
||||
"babel-cli": "^6.26.0",
|
||||
"babel-eslint": "^8.2.2",
|
||||
"babel-jest": "^22.4.0",
|
||||
"babel-loader": "^7.1.2",
|
||||
"babel-plugin-react-intl": "^3.0.1",
|
||||
"babel-plugin-transform-class-properties": "^6.24.1",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"babel-preset-react": "^6.24.1",
|
||||
"clean-webpack-plugin": "^0.1.19",
|
||||
"codecov": "^3.0.0",
|
||||
"copy-webpack-plugin": "^4.6.0",
|
||||
"css-loader": "^0.28.9",
|
||||
"enzyme": "^3.3.0",
|
||||
"enzyme-adapter-react-16": "^1.1.1",
|
||||
"es-check": "^2.0.2",
|
||||
"eslint-config-edx": "^4.0.3",
|
||||
"fetch-mock": "^6.3.0",
|
||||
"file-loader": "^1.1.9",
|
||||
"html-webpack-harddisk-plugin": "^0.2.0",
|
||||
"html-webpack-new-relic-plugin": "^1.1.0",
|
||||
"html-webpack-plugin": "^3.0.3",
|
||||
"husky": "^0.14.3",
|
||||
"identity-obj-proxy": "^3.0.0",
|
||||
"image-webpack-loader": "^4.2.0",
|
||||
"jest": "^22.4.0",
|
||||
"mini-css-extract-plugin": "^0.4.0",
|
||||
"node-sass": "^4.7.2",
|
||||
"postcss-loader": "^3.0.0",
|
||||
"react-dev-utils": "^5.0.0",
|
||||
"react-test-renderer": "^16.8.6",
|
||||
"reactifex": "1.1.1",
|
||||
"redux-mock-store": "^1.5.3",
|
||||
"sass-loader": "^6.0.6",
|
||||
"style-loader": "^0.20.2",
|
||||
"travis-deploy-once": "^5.0.9",
|
||||
"url-loader": "^1.1.2",
|
||||
"webpack": "^4.25.1",
|
||||
"webpack-cli": "^3.1.2",
|
||||
"webpack-dev-server": "^3.1.0",
|
||||
"webpack-merge": "^4.1.1"
|
||||
},
|
||||
"jest": {
|
||||
"testURL": "http://localhost/",
|
||||
"setupFiles": [
|
||||
"./src/setupTest.js"
|
||||
],
|
||||
"moduleNameMapper": {
|
||||
"\\.svg": "<rootDir>/__mocks__/svgrMock.js",
|
||||
"\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
|
||||
"\\.(css|scss)$": "identity-obj-proxy",
|
||||
"@edx/frontend-i18n(.*)$": "<rootDir>/src/i18n$1"
|
||||
},
|
||||
"collectCoverageFrom": [
|
||||
"src/**/*.{js,jsx}"
|
||||
],
|
||||
"coveragePathIgnorePatterns": [
|
||||
"/node_modules/",
|
||||
"src/setupTest.js",
|
||||
"src/index.js",
|
||||
"/tests/"
|
||||
],
|
||||
"transformIgnorePatterns": [
|
||||
"/node_modules/(?!(@edx/paragon)/).*/"
|
||||
]
|
||||
}
|
||||
}
|
||||
11
public/index.html
Executable file
11
public/index.html
Executable file
@@ -0,0 +1,11 @@
|
||||
<!doctype html>
|
||||
<html lang="en-us">
|
||||
<head>
|
||||
<title>Account | edX</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
||||
BIN
src/assets/dot-pattern-light.png
Normal file
BIN
src/assets/dot-pattern-light.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
BIN
src/assets/edx-footer.png
Normal file
BIN
src/assets/edx-footer.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/assets/edx-sm.png
Normal file
BIN
src/assets/edx-sm.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
15
src/assets/logo.svg
Normal file
15
src/assets/logo.svg
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="1168px" height="540px" viewBox="0 0 1168 540" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 53.2 (72643) - https://sketchapp.com -->
|
||||
<title>logo</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<g id="logo" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<polygon id="Path" fill="#209FDA" fill-rule="nonzero" points="1166.81993 85.5 1166.81993 2.84217094e-14 953.759925 2.84217094e-14 953.759925 85.5 1002.17993 85.5 915.859925 191.98 829.459925 85.5 878.099925 85.5 878.099925 2.84217094e-14 718.919925 2.84217094e-14 718.919925 95.72 856.479925 265.26 718.919925 434.96 718.919925 452.02 784.499925 452.02 784.499925 539.64 878.099925 539.64 878.099925 452.02 823.919925 452.02 915.919925 338.52 915.939925 338.52 1008.03993 452.02 953.759925 452.02 953.759925 539.64 1166.81993 539.64 1166.81993 452.02 1126.85993 452.02 975.319925 265.26 1121.01993 85.5"></polygon>
|
||||
<polygon id="Path" fill="#026BA4" fill-rule="nonzero" points="664.019925 7.10542736e-15 664.019925 85.5 710.619925 85.5 718.919925 95.72 718.919925 7.10542736e-15"></polygon>
|
||||
<polygon id="Path" fill="#026BA4" fill-rule="nonzero" points="718.919925 452.02 718.919925 434.96 705.079925 452.02 664.019925 452.02 664.019925 539.64 784.499925 539.64 784.499925 452.02"></polygon>
|
||||
<path d="M321.999925,411.86 L397.659925,411.86 C388.805702,433.829527 376.258024,454.122269 360.559925,471.86 C344.364089,454.216816 331.320914,433.921419 321.999925,411.86" id="Path" fill="#78212E" fill-rule="nonzero"></path>
|
||||
<path d="M360.559925,189.28 C338.58337,213.190393 322.501981,241.908137 313.599925,273.14 C317.134915,280.039338 320.007771,287.25831 322.179925,294.7 L397.059925,294.7 C399.306706,287.354671 402.25356,280.242036 405.859925,273.46 C397.464721,242.277678 381.959326,213.464341 360.559925,189.28 Z M322.179925,294.7 C328.784599,317.438017 328.978396,341.558795 322.739925,364.4 L396.399925,364.4 C389.855554,341.597488 390.06397,317.386469 396.999925,294.7 L322.179925,294.7 Z M322.179925,294.7 L308.679925,294.7 C304.690779,317.752715 304.575868,341.309464 308.339925,364.4 L322.739925,364.4 C328.978396,341.558795 328.784599,317.438017 322.179925,294.7 L322.179925,294.7 Z" id="Shape" fill="#78212E" fill-rule="nonzero"></path>
|
||||
<path d="M710.619925,85.5 L664.019925,85.5 L664.019925,0.02 L576.019925,0.02 L576.019925,85.5 L632.859925,85.5 L632.859925,159.2 C598.417874,134.487772 557.04992,121.286425 514.659925,121.48 C456.044663,121.405246 400.107354,146.01621 360.559925,189.28 C381.937732,213.470272 397.422343,242.283149 405.799925,273.46 C426.944121,233.500977 468.451514,208.51034 513.659925,208.52 C581.059925,208.52 632.879925,263.16 632.879925,330.52 L632.879925,331.2 C632.539925,398.28 580.879925,452.56 513.659925,452.56 C468.477451,452.593197 426.976426,427.652566 405.799925,387.74 L405.799925,387.74 C401.869213,380.340239 398.718926,372.551658 396.399925,364.5 L308.399925,364.5 C309.686934,372.450225 311.443338,380.317312 313.659925,388.06 C315.970162,396.190434 318.775397,404.171995 322.059925,411.96 L397.659925,411.96 C388.805702,433.929527 376.258024,454.222269 360.559925,471.96 C400.107354,515.22379 456.044663,539.834754 514.659925,539.76 C571.465111,540.091874 625.745998,516.316729 664.019925,474.34 L664.019925,452.04 L705.059925,452.04 L718.899925,434.96 L718.899925,95.74 L710.619925,85.5 Z M632.879925,501.9 L632.879925,539.74 L664.019925,539.74 L664.019925,474.18 C654.623775,484.469293 644.18821,493.758755 632.879925,501.9 L632.879925,501.9 Z M313.599925,273.14 C311.569597,280.231983 309.927163,287.429316 308.679925,294.7 L322.179925,294.7 C320.007771,287.25831 317.134915,280.039338 313.599925,273.14 L313.599925,273.14 Z" id="Shape" fill="#8A8C8F" fill-rule="nonzero"></path>
|
||||
<path d="M410.399925,294.7 C409.199925,287.5 407.659925,280.4 405.799925,273.46 C402.19356,280.242036 399.246706,287.354671 396.999925,294.7 C390.06397,317.386469 389.855554,341.597488 396.399925,364.4 L410.719925,364.4 C414.264276,341.293291 414.156293,317.77319 410.399925,294.7 L410.399925,294.7 Z M209.059925,121.48 C107.422724,121.487508 20.5081632,194.571683 3.05992537,294.7 L91.3999254,294.7 C107.135726,243.467257 154.465065,208.503753 208.059925,208.52 C252.638644,208.335148 293.496156,233.351373 313.599925,273.14 C322.501981,241.908137 338.58337,213.190393 360.559925,189.28 C322.206855,145.880863 266.976617,121.163964 209.059925,121.48 L209.059925,121.48 Z M297.479925,411.86 C275.077969,437.877726 242.392659,452.761934 208.059925,452.58 C153.691226,452.598435 105.87164,416.63791 90.7999254,364.4 L308.339925,364.4 C304.575868,341.309464 304.690779,317.752715 308.679925,294.7 L3.05992537,294.7 C-0.902504563,317.755068 -1.01739385,341.307372 2.71992537,364.4 L2.71992537,364.4 C19.3292424,465.441984 106.661918,539.594765 209.059925,539.6 C266.986094,539.900862 322.217868,515.161403 360.559925,471.74 C344.364089,454.096816 331.320914,433.801419 321.999925,411.74 L297.479925,411.86 Z" id="Shape" fill="#B72768" fill-rule="nonzero"></path>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.0 KiB |
11
src/common/actions.js
Normal file
11
src/common/actions.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import { fetchUserAccount as _fetchUserAccount, UserAccountApiService } from '@edx/frontend-auth';
|
||||
|
||||
let userAccountApiService = null;
|
||||
|
||||
export function configureUserAccountApiService(configuration, apiClient) {
|
||||
userAccountApiService = new UserAccountApiService(apiClient, configuration.LMS_BASE_URL);
|
||||
}
|
||||
|
||||
export function fetchUserAccount(username) {
|
||||
return _fetchUserAccount(userAccountApiService, username);
|
||||
}
|
||||
37
src/common/components/PageLoading.jsx
Normal file
37
src/common/components/PageLoading.jsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
export default class PageLoading extends Component {
|
||||
renderSrMessage() {
|
||||
if (!this.props.srMessage) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<span className="sr-only">
|
||||
{this.props.srMessage}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<div
|
||||
className="d-flex justify-content-center align-items-center flex-column"
|
||||
style={{
|
||||
height: '50vh',
|
||||
}}
|
||||
>
|
||||
<div className="spinner-border text-primary" role="status">
|
||||
{this.renderSrMessage()}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
PageLoading.propTypes = {
|
||||
srMessage: PropTypes.string.isRequired,
|
||||
};
|
||||
10
src/common/index.js
Normal file
10
src/common/index.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import * as utils from './utils';
|
||||
import PageLoading from './components/PageLoading';
|
||||
import { configureUserAccountApiService, fetchUserAccount } from './actions';
|
||||
|
||||
export {
|
||||
PageLoading,
|
||||
utils,
|
||||
configureUserAccountApiService,
|
||||
fetchUserAccount,
|
||||
};
|
||||
81
src/common/utils.js
Normal file
81
src/common/utils.js
Normal file
@@ -0,0 +1,81 @@
|
||||
import camelCase from 'lodash.camelcase';
|
||||
import snakeCase from 'lodash.snakecase';
|
||||
|
||||
export function modifyObjectKeys(object, modify) {
|
||||
// If the passed in object is not an object, return it.
|
||||
if (
|
||||
object === undefined ||
|
||||
object === null ||
|
||||
(typeof object !== 'object' && !Array.isArray(object))
|
||||
) {
|
||||
return object;
|
||||
}
|
||||
|
||||
if (Array.isArray(object)) {
|
||||
return object.map(value => modifyObjectKeys(value, modify));
|
||||
}
|
||||
|
||||
// Otherwise, process all its keys.
|
||||
const result = {};
|
||||
Object.entries(object).forEach(([key, value]) => {
|
||||
result[modify(key)] = modifyObjectKeys(value, modify);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
export function camelCaseObject(object) {
|
||||
return modifyObjectKeys(object, camelCase);
|
||||
}
|
||||
|
||||
export function snakeCaseObject(object) {
|
||||
return modifyObjectKeys(object, snakeCase);
|
||||
}
|
||||
|
||||
export function convertKeyNames(object, nameMap) {
|
||||
const transformer = key => (nameMap[key] === undefined ? key : nameMap[key]);
|
||||
|
||||
return modifyObjectKeys(object, transformer);
|
||||
}
|
||||
|
||||
export function keepKeys(data, whitelist) {
|
||||
const result = {};
|
||||
Object.keys(data).forEach((key) => {
|
||||
if (whitelist.indexOf(key) > -1) {
|
||||
result[key] = data[key];
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class to save time when writing out action types for asynchronous methods. Also helps
|
||||
* ensure that actions are namespaced.
|
||||
*
|
||||
* TODO: Put somewhere common to it can be used by other MFEs.
|
||||
*/
|
||||
export class AsyncActionType {
|
||||
constructor(topic, name) {
|
||||
this.topic = topic;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
get BASE() {
|
||||
return `${this.topic}__${this.name}`;
|
||||
}
|
||||
|
||||
get BEGIN() {
|
||||
return `${this.topic}__${this.name}__BEGIN`;
|
||||
}
|
||||
|
||||
get SUCCESS() {
|
||||
return `${this.topic}__${this.name}__SUCCESS`;
|
||||
}
|
||||
|
||||
get FAILURE() {
|
||||
return `${this.topic}__${this.name}__FAILURE`;
|
||||
}
|
||||
|
||||
get RESET() {
|
||||
return `${this.topic}__${this.name}__RESET`;
|
||||
}
|
||||
}
|
||||
118
src/common/utils.test.js
Normal file
118
src/common/utils.test.js
Normal file
@@ -0,0 +1,118 @@
|
||||
import { AsyncActionType, modifyObjectKeys, camelCaseObject, snakeCaseObject, convertKeyNames, keepKeys } from './utils';
|
||||
|
||||
describe('modifyObjectKeys', () => {
|
||||
it('should use the provided modify function to change all keys in and object and its children', () => {
|
||||
function meowKeys(key) {
|
||||
return `${key}Meow`;
|
||||
}
|
||||
|
||||
const result = modifyObjectKeys(
|
||||
{
|
||||
one: undefined,
|
||||
two: null,
|
||||
three: '',
|
||||
four: 0,
|
||||
five: NaN,
|
||||
six: [1, 2, { seven: 'woof' }],
|
||||
eight: { nine: { ten: 'bark' }, eleven: true },
|
||||
},
|
||||
meowKeys,
|
||||
);
|
||||
|
||||
expect(result).toEqual({
|
||||
oneMeow: undefined,
|
||||
twoMeow: null,
|
||||
threeMeow: '',
|
||||
fourMeow: 0,
|
||||
fiveMeow: NaN,
|
||||
sixMeow: [1, 2, { sevenMeow: 'woof' }],
|
||||
eightMeow: { nineMeow: { tenMeow: 'bark' }, elevenMeow: true },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('camelCaseObject', () => {
|
||||
it('should make everything camelCase', () => {
|
||||
const result = camelCaseObject({
|
||||
what_now: 'brown cow',
|
||||
but_who: { says_you_people: 'okay then', but_how: { will_we_even_know: 'the song is over' } },
|
||||
'dot.dot.dot': 123,
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
whatNow: 'brown cow',
|
||||
butWho: { saysYouPeople: 'okay then', butHow: { willWeEvenKnow: 'the song is over' } },
|
||||
dotDotDot: 123,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('snakeCaseObject', () => {
|
||||
it('should make everything snake_case', () => {
|
||||
const result = snakeCaseObject({
|
||||
whatNow: 'brown cow',
|
||||
butWho: { saysYouPeople: 'okay then', butHow: { willWeEvenKnow: 'the song is over' } },
|
||||
'dot.dot.dot': 123,
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
what_now: 'brown cow',
|
||||
but_who: { says_you_people: 'okay then', but_how: { will_we_even_know: 'the song is over' } },
|
||||
dot_dot_dot: 123,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('convertKeyNames', () => {
|
||||
it('should replace the specified keynames', () => {
|
||||
const result = convertKeyNames(
|
||||
{
|
||||
one: { two: { three: 'four' } },
|
||||
five: 'six',
|
||||
},
|
||||
{
|
||||
two: 'blue',
|
||||
five: 'alive',
|
||||
seven: 'heaven',
|
||||
},
|
||||
);
|
||||
|
||||
expect(result).toEqual({
|
||||
one: { blue: { three: 'four' } },
|
||||
alive: 'six',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('keepKeys', () => {
|
||||
it('should keep the specified keys only', () => {
|
||||
const result = keepKeys({
|
||||
one: 123,
|
||||
two: { three: 'skip me' },
|
||||
four: 'five',
|
||||
six: null,
|
||||
8: 'sneaky',
|
||||
}, [
|
||||
'one', 'three', 'six', 'seven', '8', // yup, the 8 integer will be converted to a string.
|
||||
]);
|
||||
|
||||
expect(result).toEqual({
|
||||
one: 123,
|
||||
six: null,
|
||||
8: 'sneaky',
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('AsyncActionType', () => {
|
||||
it('should return well formatted action strings', () => {
|
||||
const actionType = new AsyncActionType('HOUSE_CATS', 'START_THE_RACE');
|
||||
|
||||
expect(actionType.BASE).toBe('HOUSE_CATS__START_THE_RACE');
|
||||
expect(actionType.BEGIN).toBe('HOUSE_CATS__START_THE_RACE__BEGIN');
|
||||
expect(actionType.SUCCESS).toBe('HOUSE_CATS__START_THE_RACE__SUCCESS');
|
||||
expect(actionType.FAILURE).toBe('HOUSE_CATS__START_THE_RACE__FAILURE');
|
||||
expect(actionType.RESET).toBe('HOUSE_CATS__START_THE_RACE__RESET');
|
||||
});
|
||||
});
|
||||
});
|
||||
234
src/components/App.jsx
Normal file
234
src/components/App.jsx
Normal file
@@ -0,0 +1,234 @@
|
||||
import React, { Component } from 'react';
|
||||
import { connect, Provider } from 'react-redux';
|
||||
import PropTypes from 'prop-types';
|
||||
import { IntlProvider, injectIntl, intlShape } from 'react-intl';
|
||||
import { Route, Switch } from 'react-router-dom';
|
||||
import { ConnectedRouter } from 'connected-react-router';
|
||||
import { sendTrackEvent } from '@edx/frontend-analytics';
|
||||
import SiteHeader from '@edx/frontend-component-site-header';
|
||||
import SiteFooter from '@edx/frontend-component-footer';
|
||||
import { getLocale, getMessages } from '@edx/frontend-i18n'; // eslint-disable-line
|
||||
|
||||
import { PageLoading, fetchUserAccount } from '../common';
|
||||
import { ConnectedFeaturePage } from '../feature';
|
||||
|
||||
import FooterLogo from '../assets/edx-footer.png';
|
||||
import HeaderLogo from '../assets/logo.svg';
|
||||
import ErrorPage from './ErrorPage';
|
||||
import NotFoundPage from './NotFoundPage';
|
||||
|
||||
import messages from './App.messages';
|
||||
import WelcomePage from './WelcomePage';
|
||||
|
||||
|
||||
function PageContent({
|
||||
ready,
|
||||
configuration,
|
||||
username,
|
||||
avatar,
|
||||
intl,
|
||||
}) {
|
||||
if (!ready) {
|
||||
return <PageLoading srMessage={intl.formatMessage(messages['app.loading.message'])} />;
|
||||
}
|
||||
|
||||
const mainMenu = [
|
||||
{
|
||||
type: 'item',
|
||||
href: `${process.env.MARKETING_SITE_BASE_URL}/course`,
|
||||
content: intl.formatMessage(messages['siteheader.links.courses']),
|
||||
},
|
||||
{
|
||||
type: 'item',
|
||||
href: `${process.env.MARKETING_SITE_BASE_URL}/course?program=all`,
|
||||
content: intl.formatMessage(messages['siteheader.links.programs']),
|
||||
},
|
||||
{
|
||||
type: 'item',
|
||||
href: `${process.env.MARKETING_SITE_BASE_URL}/schools-partners`,
|
||||
content: intl.formatMessage(messages['siteheader.links.schools']),
|
||||
},
|
||||
];
|
||||
const userMenu = [
|
||||
{
|
||||
type: 'item',
|
||||
href: `${process.env.LMS_BASE_URL}`,
|
||||
content: intl.formatMessage(messages['siteheader.user.menu.dashboard']),
|
||||
},
|
||||
{
|
||||
type: 'item',
|
||||
href: `${process.env.LMS_BASE_URL}/u/${username}`,
|
||||
content: intl.formatMessage(messages['siteheader.user.menu.profile']),
|
||||
},
|
||||
{
|
||||
type: 'item',
|
||||
href: `${process.env.LMS_BASE_URL}/account/settings`,
|
||||
content: intl.formatMessage(messages['siteheader.user.menu.account.settings']),
|
||||
},
|
||||
{
|
||||
type: 'item',
|
||||
href: process.env.LOGOUT_URL,
|
||||
content: intl.formatMessage(messages['siteheader.user.menu.logout']),
|
||||
},
|
||||
];
|
||||
const loggedOutItems = [
|
||||
{
|
||||
type: 'item',
|
||||
href: `${process.env.LMS_BASE_URL}/login`,
|
||||
content: intl.formatMessage(messages['siteheader.user.menu.login']),
|
||||
},
|
||||
{
|
||||
type: 'item',
|
||||
href: `${process.env.LMS_BASE_URL}/register`,
|
||||
content: intl.formatMessage(messages['siteheader.user.menu.register']),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div id="app">
|
||||
<SiteHeader
|
||||
logo={HeaderLogo}
|
||||
loggedIn
|
||||
username={username}
|
||||
avatar={avatar}
|
||||
logoAltText={configuration.SITE_NAME}
|
||||
logoDestination={configuration.MARKETING_SITE_BASE_URL}
|
||||
mainMenu={mainMenu}
|
||||
userMenu={userMenu}
|
||||
loggedOutItems={loggedOutItems}
|
||||
/>
|
||||
<main>
|
||||
<Switch>
|
||||
<Route path="/feature" component={ConnectedFeaturePage} />
|
||||
<Route path="/error" component={ErrorPage} />
|
||||
<Route path="/notfound" component={NotFoundPage} />
|
||||
<Route path="/" component={WelcomePage} />
|
||||
<Route path="*" component={NotFoundPage} />
|
||||
</Switch>
|
||||
</main>
|
||||
<SiteFooter
|
||||
siteName={configuration.SITE_NAME}
|
||||
siteLogo={FooterLogo}
|
||||
marketingSiteBaseUrl={configuration.MARKETING_SITE_BASE_URL}
|
||||
supportUrl={configuration.SUPPORT_URL}
|
||||
contactUrl={configuration.CONTACT_URL}
|
||||
openSourceUrl={configuration.OPEN_SOURCE_URL}
|
||||
termsOfServiceUrl={configuration.TERMS_OF_SERVICE_URL}
|
||||
privacyPolicyUrl={configuration.PRIVACY_POLICY_URL}
|
||||
facebookUrl={configuration.FACEBOOK_URL}
|
||||
twitterUrl={configuration.TWITTER_URL}
|
||||
youTubeUrl={configuration.YOU_TUBE_URL}
|
||||
linkedInUrl={configuration.LINKED_IN_URL}
|
||||
googlePlusUrl={configuration.GOOGLE_PLUS_URL}
|
||||
redditUrl={configuration.REDDIT_URL}
|
||||
appleAppStoreUrl={configuration.APPLE_APP_STORE_URL}
|
||||
googlePlayUrl={configuration.GOOGLE_PLAY_URL}
|
||||
handleAllTrackEvents={sendTrackEvent}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
PageContent.propTypes = {
|
||||
username: PropTypes.string.isRequired,
|
||||
avatar: PropTypes.string,
|
||||
ready: PropTypes.bool,
|
||||
configuration: PropTypes.shape({
|
||||
SITE_NAME: PropTypes.string.isRequired,
|
||||
MARKETING_SITE_BASE_URL: PropTypes.string.isRequired,
|
||||
SUPPORT_URL: PropTypes.string.isRequired,
|
||||
CONTACT_URL: PropTypes.string.isRequired,
|
||||
OPEN_SOURCE_URL: PropTypes.string.isRequired,
|
||||
TERMS_OF_SERVICE_URL: PropTypes.string.isRequired,
|
||||
PRIVACY_POLICY_URL: PropTypes.string.isRequired,
|
||||
FACEBOOK_URL: PropTypes.string.isRequired,
|
||||
TWITTER_URL: PropTypes.string.isRequired,
|
||||
YOU_TUBE_URL: PropTypes.string.isRequired,
|
||||
LINKED_IN_URL: PropTypes.string.isRequired,
|
||||
GOOGLE_PLUS_URL: PropTypes.string.isRequired,
|
||||
REDDIT_URL: PropTypes.string.isRequired,
|
||||
APPLE_APP_STORE_URL: PropTypes.string.isRequired,
|
||||
GOOGLE_PLAY_URL: PropTypes.string.isRequired,
|
||||
}).isRequired,
|
||||
intl: intlShape.isRequired,
|
||||
};
|
||||
|
||||
PageContent.defaultProps = {
|
||||
ready: false,
|
||||
avatar: null,
|
||||
};
|
||||
|
||||
const IntlPageContent = injectIntl(PageContent);
|
||||
|
||||
class App extends Component {
|
||||
componentDidMount() {
|
||||
const { username } = this.props;
|
||||
this.props.fetchUserAccount(username);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<IntlProvider locale={getLocale()} messages={getMessages()}>
|
||||
<Provider store={this.props.store}>
|
||||
<ConnectedRouter history={this.props.history}>
|
||||
<IntlPageContent
|
||||
ready={this.props.ready}
|
||||
configuration={this.props.configuration}
|
||||
username={this.props.username}
|
||||
avatar={this.props.avatar}
|
||||
/>
|
||||
</ConnectedRouter>
|
||||
</Provider>
|
||||
</IntlProvider>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
App.propTypes = {
|
||||
fetchUserAccount: PropTypes.func.isRequired,
|
||||
username: PropTypes.string.isRequired,
|
||||
avatar: PropTypes.string,
|
||||
store: PropTypes.object.isRequired, // eslint-disable-line
|
||||
history: PropTypes.object.isRequired, // eslint-disable-line
|
||||
ready: PropTypes.bool,
|
||||
configuration: PropTypes.shape({
|
||||
SITE_NAME: PropTypes.string.isRequired,
|
||||
MARKETING_SITE_BASE_URL: PropTypes.string.isRequired,
|
||||
SUPPORT_URL: PropTypes.string.isRequired,
|
||||
CONTACT_URL: PropTypes.string.isRequired,
|
||||
OPEN_SOURCE_URL: PropTypes.string.isRequired,
|
||||
TERMS_OF_SERVICE_URL: PropTypes.string.isRequired,
|
||||
PRIVACY_POLICY_URL: PropTypes.string.isRequired,
|
||||
FACEBOOK_URL: PropTypes.string.isRequired,
|
||||
TWITTER_URL: PropTypes.string.isRequired,
|
||||
YOU_TUBE_URL: PropTypes.string.isRequired,
|
||||
LINKED_IN_URL: PropTypes.string.isRequired,
|
||||
GOOGLE_PLUS_URL: PropTypes.string.isRequired,
|
||||
REDDIT_URL: PropTypes.string.isRequired,
|
||||
APPLE_APP_STORE_URL: PropTypes.string.isRequired,
|
||||
GOOGLE_PLAY_URL: PropTypes.string.isRequired,
|
||||
}).isRequired,
|
||||
};
|
||||
|
||||
App.defaultProps = {
|
||||
ready: false,
|
||||
avatar: null,
|
||||
};
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
username: state.authentication.username,
|
||||
// An error means that we tried to load the user account and failed,
|
||||
// which also means we're ready to display something.
|
||||
ready: state.userAccount.loaded || state.userAccount.error != null,
|
||||
configuration: state.configuration,
|
||||
avatar: state.userAccount.profileImage.hasImage
|
||||
? state.userAccount.profileImage.imageUrlMedium
|
||||
: null,
|
||||
});
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
{
|
||||
fetchUserAccount,
|
||||
},
|
||||
)(App);
|
||||
56
src/components/App.messages.jsx
Normal file
56
src/components/App.messages.jsx
Normal file
@@ -0,0 +1,56 @@
|
||||
import { defineMessages } from 'react-intl';
|
||||
|
||||
const messages = defineMessages({
|
||||
'siteheader.links.courses': {
|
||||
id: 'siteheader.links.courses',
|
||||
defaultMessage: 'Courses',
|
||||
description: 'Link to the course catalog',
|
||||
},
|
||||
'siteheader.links.programs': {
|
||||
id: 'siteheader.links.programs',
|
||||
defaultMessage: 'Programs & Degrees',
|
||||
description: 'Link to the programs catalog',
|
||||
},
|
||||
'siteheader.links.schools': {
|
||||
id: 'siteheader.links.schools',
|
||||
defaultMessage: 'Schools & Partners',
|
||||
description: 'Link to the schools and partners landing page',
|
||||
},
|
||||
'siteheader.user.menu.dashboard': {
|
||||
id: 'siteheader.user.menu.dashboard',
|
||||
defaultMessage: 'Dashboard',
|
||||
description: 'Link to the user dashboard',
|
||||
},
|
||||
'siteheader.user.menu.profile': {
|
||||
id: 'siteheader.user.menu.profile',
|
||||
defaultMessage: 'Profile',
|
||||
description: 'Link to the user profile',
|
||||
},
|
||||
'siteheader.user.menu.account.settings': {
|
||||
id: 'siteheader.user.menu.account.settings',
|
||||
defaultMessage: 'Account',
|
||||
description: 'Link to account settings',
|
||||
},
|
||||
'siteheader.user.menu.logout': {
|
||||
id: 'siteheader.user.menu.logout',
|
||||
defaultMessage: 'Logout',
|
||||
description: 'Logout link',
|
||||
},
|
||||
'siteheader.user.menu.login': {
|
||||
id: 'siteheader.user.menu.login',
|
||||
defaultMessage: 'Login',
|
||||
description: 'Login link',
|
||||
},
|
||||
'siteheader.user.menu.register': {
|
||||
id: 'siteheader.user.menu.register',
|
||||
defaultMessage: 'Sign Up',
|
||||
description: 'Link to registration',
|
||||
},
|
||||
'app.loading.message': {
|
||||
id: 'app.loading.message',
|
||||
defaultMessage: 'Loading',
|
||||
description: 'Message shown when page content is loading.',
|
||||
},
|
||||
});
|
||||
|
||||
export default messages;
|
||||
20
src/components/ErrorPage.jsx
Normal file
20
src/components/ErrorPage.jsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import React from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
export default function ErrorPage() {
|
||||
return (
|
||||
<div className="container-fluid py-5 justify-content-center align-items-start text-center">
|
||||
<div className="row">
|
||||
<div className="col">
|
||||
<p className="my-0 py-5 text-muted">
|
||||
<FormattedMessage
|
||||
id="error.unexpected.message"
|
||||
defaultMessage="An unexpected error occurred."
|
||||
description="error message when an unexpected error occurs"
|
||||
/>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
16
src/components/NotFoundPage.jsx
Normal file
16
src/components/NotFoundPage.jsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import React from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
export default function NotFoundPage() {
|
||||
return (
|
||||
<div className="container-fluid d-flex py-5 justify-content-center align-items-start text-center">
|
||||
<p className="my-0 py-5 text-muted" style={{ maxWidth: '32em' }}>
|
||||
<FormattedMessage
|
||||
id="error.notfound.message"
|
||||
defaultMessage="The page you're looking for is unavailable or there's an error in the URL. Please check the URL and try again."
|
||||
description="error message when a page does not exist"
|
||||
/>
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
26
src/components/WelcomePage.jsx
Normal file
26
src/components/WelcomePage.jsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import React from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
export default function WelcomePage() {
|
||||
return (
|
||||
<div className="py-5 justify-content-center align-items-start text-center">
|
||||
<p className="my-0 pt-5 text-muted">
|
||||
<FormattedMessage
|
||||
id="app.page"
|
||||
defaultMessage="Congratulations! You have a new micro-frontend."
|
||||
description="Default page content for a new frontend application"
|
||||
/>
|
||||
</p>
|
||||
<p className="my-0 pt-3 text-muted">
|
||||
<Link to="/feature">
|
||||
<FormattedMessage
|
||||
id="app.feature.link"
|
||||
defaultMessage="Click here to visit a feature page that loads data."
|
||||
description="A link to an example page that loads data."
|
||||
/>
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
41
src/environment.js
Normal file
41
src/environment.js
Normal file
@@ -0,0 +1,41 @@
|
||||
export const configuration = {
|
||||
BASE_URL: process.env.BASE_URL,
|
||||
LMS_BASE_URL: process.env.LMS_BASE_URL,
|
||||
ECOMMERCE_BASE_URL: process.env.ECOMMERCE_BASE_URL,
|
||||
CREDENTIALS_BASE_URL: process.env.CREDENTIALS_BASE_URL,
|
||||
LOGIN_URL: process.env.LOGIN_URL,
|
||||
LOGOUT_URL: process.env.LOGOUT_URL,
|
||||
CSRF_TOKEN_API_PATH: process.env.CSRF_TOKEN_API_PATH,
|
||||
REFRESH_ACCESS_TOKEN_ENDPOINT: process.env.REFRESH_ACCESS_TOKEN_ENDPOINT,
|
||||
SEGMENT_KEY: process.env.SEGMENT_KEY,
|
||||
ACCESS_TOKEN_COOKIE_NAME: process.env.ACCESS_TOKEN_COOKIE_NAME,
|
||||
USER_INFO_COOKIE_NAME: process.env.USER_INFO_COOKIE_NAME,
|
||||
CSRF_COOKIE_NAME: process.env.CSRF_COOKIE_NAME,
|
||||
LANGUAGE_PREFERENCE_COOKIE_NAME: process.env.LANGUAGE_PREFERENCE_COOKIE_NAME,
|
||||
SITE_NAME: process.env.SITE_NAME,
|
||||
MARKETING_SITE_BASE_URL: process.env.MARKETING_SITE_BASE_URL,
|
||||
SUPPORT_URL: process.env.SUPPORT_URL,
|
||||
CONTACT_URL: process.env.CONTACT_URL,
|
||||
OPEN_SOURCE_URL: process.env.OPEN_SOURCE_URL,
|
||||
TERMS_OF_SERVICE_URL: process.env.TERMS_OF_SERVICE_URL,
|
||||
PRIVACY_POLICY_URL: process.env.PRIVACY_POLICY_URL,
|
||||
FACEBOOK_URL: process.env.FACEBOOK_URL,
|
||||
TWITTER_URL: process.env.TWITTER_URL,
|
||||
YOU_TUBE_URL: process.env.YOU_TUBE_URL,
|
||||
LINKED_IN_URL: process.env.LINKED_IN_URL,
|
||||
GOOGLE_PLUS_URL: process.env.GOOGLE_PLUS_URL,
|
||||
REDDIT_URL: process.env.REDDIT_URL,
|
||||
APPLE_APP_STORE_URL: process.env.APPLE_APP_STORE_URL,
|
||||
GOOGLE_PLAY_URL: process.env.GOOGLE_PLAY_URL,
|
||||
ACCOUNT_SETTINGS_URL: `${process.env.LMS_BASE_URL}/account/settings`,
|
||||
DATA_API_BASE_URL: process.env.DATA_API_BASE_URL,
|
||||
SECURE_COOKIES: process.env.NODE_ENV !== 'development',
|
||||
ENVIRONMENT: process.env.NODE_ENV,
|
||||
ACCOUNTS_API_BASE_URL: `${process.env.LMS_BASE_URL}/api/user/v1/accounts`,
|
||||
PREFERENCES_API_BASE_URL: `${process.env.LMS_BASE_URL}/api/user/v1/preferences`,
|
||||
CERTIFICATES_API_BASE_URL: `${process.env.LMS_BASE_URL}/api/certificates/v0/certificates`,
|
||||
VIEW_MY_RECORDS_URL: `${process.env.CREDENTIALS_BASE_URL}/records`,
|
||||
ECOMMERCE_API_BASE_URL: `${process.env.ECOMMERCE_BASE_URL}/api/v2`,
|
||||
};
|
||||
|
||||
export const features = {};
|
||||
78
src/feature/FeaturePage.jsx
Normal file
78
src/feature/FeaturePage.jsx
Normal file
@@ -0,0 +1,78 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { injectIntl, intlShape } from 'react-intl';
|
||||
|
||||
import messages from './FeaturePage.messages';
|
||||
|
||||
// Actions
|
||||
import { fetchFeatureData } from './actions';
|
||||
import { featureSelector } from './selectors';
|
||||
import { PageLoading } from '../common';
|
||||
|
||||
class FeaturePage extends React.Component {
|
||||
componentDidMount() {
|
||||
this.props.fetchFeatureData('Hello feature data!');
|
||||
}
|
||||
|
||||
renderContent() {
|
||||
return (
|
||||
<div>{this.props.data}</div>
|
||||
);
|
||||
}
|
||||
|
||||
renderError() {
|
||||
return (
|
||||
<div>
|
||||
{this.props.intl.formatMessage(messages['feature.loading.error'], {
|
||||
error: this.props.loadingError,
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
renderLoading() {
|
||||
return (
|
||||
<PageLoading srMessage={this.props.intl.formatMessage(messages['feature.loading.message'])} />
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
loading,
|
||||
loaded,
|
||||
loadingError,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<div className="page__feature container-fluid py-5">
|
||||
<h1>
|
||||
{this.props.intl.formatMessage(messages['feature.page.heading'])}
|
||||
</h1>
|
||||
{loading ? this.renderLoading() : null}
|
||||
{loaded ? this.renderContent() : null}
|
||||
{loadingError ? this.renderError() : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
FeaturePage.propTypes = {
|
||||
intl: intlShape.isRequired,
|
||||
data: PropTypes.string,
|
||||
loading: PropTypes.bool,
|
||||
loaded: PropTypes.bool,
|
||||
loadingError: PropTypes.string,
|
||||
fetchFeatureData: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
FeaturePage.defaultProps = {
|
||||
data: null,
|
||||
loading: false,
|
||||
loaded: false,
|
||||
loadingError: null,
|
||||
};
|
||||
|
||||
export default connect(featureSelector, {
|
||||
fetchFeatureData,
|
||||
})(injectIntl(FeaturePage));
|
||||
21
src/feature/FeaturePage.messages.jsx
Normal file
21
src/feature/FeaturePage.messages.jsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import { defineMessages } from 'react-intl';
|
||||
|
||||
const messages = defineMessages({
|
||||
'feature.page.heading': {
|
||||
id: 'feature.page.heading',
|
||||
defaultMessage: 'Feature Page',
|
||||
description: 'The page heading for a feature page.',
|
||||
},
|
||||
'feature.loading.message': {
|
||||
id: 'feature.loading.message',
|
||||
defaultMessage: 'Loading',
|
||||
description: 'Message when data is being loaded',
|
||||
},
|
||||
'feature.loading.error': {
|
||||
id: 'feature.loading.error',
|
||||
defaultMessage: 'Error: {error}',
|
||||
description: 'Message when data failed to load',
|
||||
},
|
||||
});
|
||||
|
||||
export default messages;
|
||||
3
src/feature/_style.scss
Normal file
3
src/feature/_style.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
.page__feature {
|
||||
|
||||
}
|
||||
34
src/feature/actions.js
Normal file
34
src/feature/actions.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import { utils } from '../common';
|
||||
|
||||
const { AsyncActionType } = utils;
|
||||
|
||||
export const FETCH_FEATURE_DATA = new AsyncActionType('FEATURE', 'FETCH_FEATURE_DATA');
|
||||
|
||||
// FETCH FEATURE ACTIONS
|
||||
|
||||
export const fetchFeatureData = data => ({
|
||||
type: FETCH_FEATURE_DATA.BASE,
|
||||
payload: {
|
||||
data,
|
||||
},
|
||||
});
|
||||
|
||||
export const fetchFeatureDataBegin = () => ({
|
||||
type: FETCH_FEATURE_DATA.BEGIN,
|
||||
});
|
||||
|
||||
export const fetchFeatureDataSuccess = data => ({
|
||||
type: FETCH_FEATURE_DATA.SUCCESS,
|
||||
payload: {
|
||||
data,
|
||||
},
|
||||
});
|
||||
|
||||
export const fetchFeatureDataFailure = error => ({
|
||||
type: FETCH_FEATURE_DATA.FAILURE,
|
||||
payload: { error },
|
||||
});
|
||||
|
||||
export const fetchFeatureDataReset = () => ({
|
||||
type: FETCH_FEATURE_DATA.RESET,
|
||||
});
|
||||
13
src/feature/index.js
Normal file
13
src/feature/index.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import ConnectedFeaturePage from './FeaturePage';
|
||||
import reducer from './reducers';
|
||||
import saga from './sagas';
|
||||
import { configureApiService } from './service';
|
||||
import { storeName } from './selectors';
|
||||
|
||||
export {
|
||||
ConnectedFeaturePage,
|
||||
reducer,
|
||||
saga,
|
||||
configureApiService,
|
||||
storeName,
|
||||
};
|
||||
46
src/feature/reducers.js
Normal file
46
src/feature/reducers.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import { FETCH_FEATURE_DATA } from './actions';
|
||||
|
||||
export const defaultState = {
|
||||
loading: false,
|
||||
loaded: false,
|
||||
loadingError: null,
|
||||
data: null,
|
||||
};
|
||||
|
||||
const feature = (state = defaultState, action) => {
|
||||
switch (action.type) {
|
||||
case FETCH_FEATURE_DATA.BEGIN:
|
||||
return {
|
||||
...state,
|
||||
loading: true,
|
||||
loaded: false,
|
||||
loadingError: null,
|
||||
};
|
||||
case FETCH_FEATURE_DATA.SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
data: action.payload.data,
|
||||
loading: false,
|
||||
loaded: true,
|
||||
loadingError: null,
|
||||
};
|
||||
case FETCH_FEATURE_DATA.FAILURE:
|
||||
return {
|
||||
...state,
|
||||
loading: false,
|
||||
loaded: false,
|
||||
loadingError: action.payload.error,
|
||||
};
|
||||
case FETCH_FEATURE_DATA.RESET:
|
||||
return {
|
||||
...state,
|
||||
loading: false,
|
||||
loaded: false,
|
||||
loadingError: null,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default feature;
|
||||
32
src/feature/sagas.js
Normal file
32
src/feature/sagas.js
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
import { call, put, takeEvery } from 'redux-saga/effects';
|
||||
import { push } from 'connected-react-router';
|
||||
import LoggingService from '@edx/frontend-logging';
|
||||
|
||||
// Actions
|
||||
import {
|
||||
FETCH_FEATURE_DATA,
|
||||
fetchFeatureDataBegin,
|
||||
fetchFeatureDataSuccess,
|
||||
fetchFeatureDataFailure,
|
||||
} from './actions';
|
||||
|
||||
// Services
|
||||
import * as ApiService from './service';
|
||||
|
||||
export function* handleFetchFeatureData(action) {
|
||||
try {
|
||||
yield put(fetchFeatureDataBegin());
|
||||
|
||||
const data = yield call(ApiService.getData, action.payload.data);
|
||||
yield put(fetchFeatureDataSuccess(data));
|
||||
} catch (e) {
|
||||
LoggingService.logAPIErrorResponse(e);
|
||||
yield put(fetchFeatureDataFailure(e.message));
|
||||
yield put(push('/error'));
|
||||
}
|
||||
}
|
||||
|
||||
export default function* saga() {
|
||||
yield takeEvery(FETCH_FEATURE_DATA.BASE, handleFetchFeatureData);
|
||||
}
|
||||
4
src/feature/selectors.js
Normal file
4
src/feature/selectors.js
Normal file
@@ -0,0 +1,4 @@
|
||||
export const storeName = 'feature';
|
||||
|
||||
// Pass everything in state as props for now
|
||||
export const featureSelector = state => ({ ...state[storeName] });
|
||||
32
src/feature/service.js
Normal file
32
src/feature/service.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import pick from 'lodash.pick';
|
||||
|
||||
let config = {
|
||||
ACCOUNTS_API_BASE_URL: null,
|
||||
ECOMMERCE_API_BASE_URL: null,
|
||||
LMS_BASE_URL: null,
|
||||
};
|
||||
|
||||
let apiClient = null;
|
||||
|
||||
function validateConfiguration(newConfig) {
|
||||
Object.keys(config).forEach((key) => {
|
||||
if (newConfig[key] === undefined) {
|
||||
throw new Error(`Service configuration error: ${key} is required.`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function configureApiService(newConfig, newApiClient) {
|
||||
validateConfiguration(newConfig);
|
||||
config = pick(newConfig, Object.keys(config));
|
||||
apiClient = newApiClient;
|
||||
}
|
||||
|
||||
export async function getData(data) {
|
||||
//const { data } = await apiClient.get(`${config.API_BASE_URL}/feature/`, {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve(data);
|
||||
}, 2000);
|
||||
});;
|
||||
}
|
||||
63
src/i18n/i18n-concat.js
Executable file
63
src/i18n/i18n-concat.js
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* See the Makefile for how the required hash file is downloaded from Transifex.
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const glob = require('glob');
|
||||
const path = require('path');
|
||||
|
||||
// Expected input: a directory, possibly containing subdirectories, with .json files. Each .json
|
||||
// file is an array of translation triplets (id, description, defaultMessage).
|
||||
function gatherJson(dir) {
|
||||
const ret = [];
|
||||
const files = glob.sync(`${dir}/**/*.json`);
|
||||
|
||||
files.forEach((filename) => {
|
||||
const messages = JSON.parse(fs.readFileSync(filename));
|
||||
ret.push(...messages);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
// the hash file returns ids whose periods are "escaped" (sort of), like this:
|
||||
// "key": "profile\\.sociallinks\\.social\\.links"
|
||||
// so our regular messageIds won't match them out of the box
|
||||
function escapeDots(messageId) {
|
||||
return messageId.replace(/\./g, '\\.');
|
||||
}
|
||||
|
||||
const jsonDir = process.argv[2];
|
||||
const messageObjects = gatherJson(jsonDir);
|
||||
|
||||
if (process.argv[3] === '--comments') { // prepare to handle the translator notes
|
||||
const loggingPrefix = path.basename(`${__filename}`); // the name of this JS file
|
||||
const bashScriptsPath = './node_modules/reactifex/bash_scripts';
|
||||
|
||||
const hashFile = `${bashScriptsPath}/hashmap.json`;
|
||||
process.stdout.write(`${loggingPrefix}: reading hash file ${hashFile}\n`);
|
||||
const messageInfo = JSON.parse(fs.readFileSync(hashFile));
|
||||
|
||||
const outputFile = `${bashScriptsPath}/hashed_data.txt`;
|
||||
process.stdout.write(`${loggingPrefix}: writing to output file ${outputFile}\n`);
|
||||
fs.writeFileSync(outputFile, '');
|
||||
|
||||
messageObjects.forEach((message) => {
|
||||
const transifexFormatId = escapeDots(message.id);
|
||||
|
||||
const info = messageInfo.find(mi => mi.key === transifexFormatId);
|
||||
if (info) {
|
||||
fs.appendFileSync(outputFile, `${info.string_hash}|${message.description}\n`);
|
||||
} else {
|
||||
process.stdout.write(`${loggingPrefix}: string ${message.id} does not yet exist on transifex!\n`);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
const output = {};
|
||||
|
||||
messageObjects.forEach((message) => {
|
||||
output[message.id] = message.defaultMessage;
|
||||
});
|
||||
fs.writeFileSync(process.argv[3], JSON.stringify(output, null, 2));
|
||||
}
|
||||
165
src/i18n/i18n-loader.js
Normal file
165
src/i18n/i18n-loader.js
Normal file
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* For each locale we want to support, react-intl needs 1) the locale-data, which includes
|
||||
* information about how to format numbers, handle plurals, etc., and 2) the translations, as an
|
||||
* object holding message id / translated string pairs. A locale string and the messages object are
|
||||
* passed into the IntlProvider element that wraps your element hierarchy.
|
||||
*
|
||||
* Note that react-intl has no way of checking if the translations you give it actually have
|
||||
* anything to do with the locale you pass it; it will happily use whatever messages object you pass
|
||||
* in. However, if the locale data for the locale you passed into the IntlProvider was not
|
||||
* correctly installed with addLocaleData, all of your translations will fall back to the default
|
||||
* (in our case English), *even if you gave IntlProvider the correct messages object for that
|
||||
* locale*.
|
||||
*/
|
||||
|
||||
import { addLocaleData } from 'react-intl';
|
||||
import Cookies from 'universal-cookie';
|
||||
|
||||
import arLocale from 'react-intl/locale-data/ar';
|
||||
import enLocale from 'react-intl/locale-data/en';
|
||||
import es419Locale from 'react-intl/locale-data/es';
|
||||
import frLocale from 'react-intl/locale-data/fr';
|
||||
import zhcnLocale from 'react-intl/locale-data/zh';
|
||||
|
||||
import COUNTRIES, { langs as countryLangs } from 'i18n-iso-countries';
|
||||
import LANGUAGES, { langs as languageLangs } from '@cospired/i18n-iso-languages';
|
||||
|
||||
import arMessages from './messages/ar.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';
|
||||
|
||||
addLocaleData([...arLocale, ...enLocale, ...es419Locale, ...frLocale, ...zhcnLocale]);
|
||||
|
||||
// TODO: When we start dynamically loading translations only for the current locale, change this.
|
||||
COUNTRIES.registerLocale(require('i18n-iso-countries/langs/ar.json'));
|
||||
COUNTRIES.registerLocale(require('i18n-iso-countries/langs/en.json'));
|
||||
COUNTRIES.registerLocale(require('i18n-iso-countries/langs/es.json'));
|
||||
COUNTRIES.registerLocale(require('i18n-iso-countries/langs/fr.json'));
|
||||
COUNTRIES.registerLocale(require('i18n-iso-countries/langs/zh.json'));
|
||||
|
||||
// TODO: When we start dynamically loading translations only for the current locale, change this.
|
||||
// TODO: Also note that Arabic (ar) and Chinese (zh) are missing here. That's because they're
|
||||
// not implemented in this library. If you read this and it's been a while, go check and see
|
||||
// if that's changed!
|
||||
LANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/en.json'));
|
||||
LANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/es.json'));
|
||||
LANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/fr.json'));
|
||||
|
||||
const messages = { // current fallback strategy is to use the first two letters of the locale code
|
||||
ar: arMessages,
|
||||
es: es419Messages,
|
||||
fr: frMessages,
|
||||
zh: zhcnMessages,
|
||||
};
|
||||
|
||||
const cookies = new Cookies();
|
||||
|
||||
const getTwoLetterLanguageCode = code => code.substr(0, 2);
|
||||
|
||||
// Get the locale by setting priority. Skip if we don't support that language.
|
||||
const getLocale = (localeStr) => {
|
||||
// 1. Explicit application request
|
||||
if (localeStr && messages[localeStr] !== undefined) {
|
||||
return localeStr;
|
||||
}
|
||||
// 2. User setting in cookie
|
||||
const cookieLangPref = cookies.get(process.env.LANGUAGE_PREFERENCE_COOKIE_NAME);
|
||||
if (cookieLangPref && messages[getTwoLetterLanguageCode(cookieLangPref)] !== undefined) {
|
||||
return getTwoLetterLanguageCode(cookieLangPref);
|
||||
}
|
||||
// 3. Browser language (default)
|
||||
return getTwoLetterLanguageCode(window.navigator.language);
|
||||
};
|
||||
|
||||
const getMessages = (locale = getLocale()) => messages[locale];
|
||||
|
||||
const rtlLocales = ['ar', 'he', 'fa', 'ur'];
|
||||
const isRtl = locale => rtlLocales.includes(locale);
|
||||
|
||||
const handleRtl = () => {
|
||||
if (isRtl(getLocale())) {
|
||||
document.getElementsByTagName('html')[0].setAttribute('dir', 'rtl');
|
||||
document.styleSheets[0].disabled = true;
|
||||
} else {
|
||||
document.styleSheets[1].disabled = true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Provides a lookup table of country IDs to country names for the current locale.
|
||||
*/
|
||||
const getCountryMessages = (locale) => {
|
||||
const finalLocale = countryLangs().includes(locale) ? locale : 'en';
|
||||
|
||||
return COUNTRIES.getNames(finalLocale);
|
||||
};
|
||||
|
||||
/**
|
||||
* Provides a lookup table of language IDs to language names for the current locale.
|
||||
*/
|
||||
const getLanguageMessages = (locale) => {
|
||||
const finalLocale = languageLangs().includes(locale) ? locale : 'en';
|
||||
|
||||
return LANGUAGES.getNames(finalLocale);
|
||||
};
|
||||
|
||||
const sortFunction = (a, b) => {
|
||||
// If localeCompare exists, use that. (Not supported in some older browsers)
|
||||
if (typeof String.prototype.localeCompare === 'function') {
|
||||
return a[1].localeCompare(b[1], getLocale());
|
||||
}
|
||||
if (a[1] === b[1]) {
|
||||
return 0;
|
||||
}
|
||||
// Otherwise make a best effort.
|
||||
return a[1] > b[1] ? 1 : -1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Provides a list of countries represented as objects of the following shape:
|
||||
*
|
||||
* {
|
||||
* key, // The ID of the country
|
||||
* name // The localized name of the country
|
||||
* }
|
||||
*
|
||||
* The list is sorted alphabetically in the current locale.
|
||||
* This is useful for select dropdowns primarily.
|
||||
*/
|
||||
const getCountryList = (locale) => {
|
||||
const countryMessages = getCountryMessages(locale);
|
||||
return Object.entries(countryMessages)
|
||||
.sort(sortFunction)
|
||||
.map(([code, name]) => ({ code, name }));
|
||||
};
|
||||
|
||||
/**
|
||||
* Provides a list of languages represented as objects of the following shape:
|
||||
*
|
||||
* {
|
||||
* key, // The ID of the language
|
||||
* name // The localized name of the language
|
||||
* }
|
||||
*
|
||||
* The list is sorted alphabetically in the current locale.
|
||||
* This is useful for select dropdowns primarily.
|
||||
*/
|
||||
const getLanguageList = (locale) => {
|
||||
const languageMessages = getLanguageMessages(locale);
|
||||
return Object.entries(languageMessages)
|
||||
.sort(sortFunction)
|
||||
.map(([code, name]) => ({ code, name }));
|
||||
};
|
||||
|
||||
export {
|
||||
getCountryList,
|
||||
getCountryMessages,
|
||||
getLanguageList,
|
||||
getLanguageMessages,
|
||||
getLocale,
|
||||
getMessages,
|
||||
handleRtl,
|
||||
isRtl,
|
||||
};
|
||||
25
src/i18n/index.jsx
Normal file
25
src/i18n/index.jsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { intlShape } from 'react-intl';
|
||||
import injectIntlWithShim from './injectIntlWithShim';
|
||||
import {
|
||||
getCountryList,
|
||||
getCountryMessages,
|
||||
getLanguageList,
|
||||
getLanguageMessages,
|
||||
getLocale,
|
||||
getMessages,
|
||||
handleRtl,
|
||||
isRtl,
|
||||
} from './i18n-loader';
|
||||
|
||||
export {
|
||||
injectIntlWithShim as injectIntl,
|
||||
getCountryList,
|
||||
getCountryMessages,
|
||||
getLanguageList,
|
||||
getLanguageMessages,
|
||||
getLocale,
|
||||
getMessages,
|
||||
handleRtl,
|
||||
isRtl,
|
||||
intlShape,
|
||||
};
|
||||
41
src/i18n/injectIntlWithShim.jsx
Normal file
41
src/i18n/injectIntlWithShim.jsx
Normal file
@@ -0,0 +1,41 @@
|
||||
import React from 'react';
|
||||
import { injectIntl, intlShape } from 'react-intl';
|
||||
import LoggingService from '@edx/frontend-logging';
|
||||
|
||||
|
||||
const injectIntlWithShim = (WrappedComponent) => {
|
||||
class ShimmedIntlComponent extends React.Component {
|
||||
static propTypes = {
|
||||
intl: intlShape.isRequired,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.shimmedIntl = Object.create(this.props.intl, {
|
||||
formatMessage: {
|
||||
value: (definition) => {
|
||||
if (definition === undefined || definition.id === undefined) {
|
||||
const error = new Error('i18n error: An undefined message was supplied to intl.formatMessage.');
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
console.error(error); // eslint-disable-line no-console
|
||||
return '!!! Missing message supplied to intl.formatMessage !!!';
|
||||
}
|
||||
LoggingService.logError(error);
|
||||
return ''; // Fail silent in production
|
||||
}
|
||||
return this.props.intl.formatMessage(definition);
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return <WrappedComponent {...this.props} intl={this.shimmedIntl} />;
|
||||
}
|
||||
}
|
||||
|
||||
return injectIntl(ShimmedIntlComponent);
|
||||
};
|
||||
|
||||
|
||||
export default injectIntlWithShim;
|
||||
11
src/i18n/messages/ar.json
Normal file
11
src/i18n/messages/ar.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"siteheader.links.courses": "Courses",
|
||||
"siteheader.links.programs": "Programs & Degrees",
|
||||
"siteheader.links.schools": "Schools & Partners",
|
||||
"siteheader.user.menu.dashboard": "Dashboard",
|
||||
"siteheader.user.menu.profile": "Profile",
|
||||
"siteheader.user.menu.account.settings": "Account",
|
||||
"siteheader.user.menu.logout": "Logout",
|
||||
"siteheader.user.menu.login": "Login",
|
||||
"siteheader.user.menu.register": "Sign Up"
|
||||
}
|
||||
11
src/i18n/messages/es_419.json
Normal file
11
src/i18n/messages/es_419.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"siteheader.links.courses": "Cursos",
|
||||
"siteheader.links.programs": "Programas y Titulos",
|
||||
"siteheader.links.schools": "Escuelas y Socios",
|
||||
"siteheader.user.menu.dashboard": "Panel de Control",
|
||||
"siteheader.user.menu.profile": "Perfil",
|
||||
"siteheader.user.menu.account.settings": "Cuenta",
|
||||
"siteheader.user.menu.logout": "Salir",
|
||||
"siteheader.user.menu.login": "Iniciar Sesión",
|
||||
"siteheader.user.menu.register": "Registrarse"
|
||||
}
|
||||
11
src/i18n/messages/fr.json
Normal file
11
src/i18n/messages/fr.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"siteheader.links.courses": "Cours",
|
||||
"siteheader.links.programs": "Programs & Degrees",
|
||||
"siteheader.links.schools": "Écoles et Partenaires",
|
||||
"siteheader.user.menu.dashboard": "Tableau de bord",
|
||||
"siteheader.user.menu.profile": "Profil",
|
||||
"siteheader.user.menu.account.settings": "Compte",
|
||||
"siteheader.user.menu.logout": "Déconnexion",
|
||||
"siteheader.user.menu.login": "Connexion",
|
||||
"siteheader.user.menu.register": "S'inscrire"
|
||||
}
|
||||
11
src/i18n/messages/zh_CN.json
Normal file
11
src/i18n/messages/zh_CN.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"siteheader.links.courses": "Courses",
|
||||
"siteheader.links.programs": "Programs & Degrees",
|
||||
"siteheader.links.schools": "Schools & Partners",
|
||||
"siteheader.user.menu.dashboard": "Dashboard",
|
||||
"siteheader.user.menu.profile": "Profile",
|
||||
"siteheader.user.menu.account.settings": "Account",
|
||||
"siteheader.user.menu.logout": "Logout",
|
||||
"siteheader.user.menu.login": "Login",
|
||||
"siteheader.user.menu.register": "Sign Up"
|
||||
}
|
||||
19
src/i18n/transifex_input.json
Normal file
19
src/i18n/transifex_input.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"siteheader.links.courses": "Courses",
|
||||
"siteheader.links.programs": "Programs & Degrees",
|
||||
"siteheader.links.schools": "Schools & Partners",
|
||||
"siteheader.user.menu.dashboard": "Dashboard",
|
||||
"siteheader.user.menu.profile": "Profile",
|
||||
"siteheader.user.menu.account.settings": "Account",
|
||||
"siteheader.user.menu.logout": "Logout",
|
||||
"siteheader.user.menu.login": "Login",
|
||||
"siteheader.user.menu.register": "Sign Up",
|
||||
"app.loading.message": "Loading",
|
||||
"error.unexpected.message": "An unexpected error occurred.",
|
||||
"error.notfound.message": "The page you're looking for is unavailable or there's an error in the URL. Please check the URL and try again.",
|
||||
"app.page": "Congratulations! You have a new micro-frontend.",
|
||||
"app.feature.link": "Click here to visit a feature page that loads data.",
|
||||
"feature.page.heading": "Feature Page",
|
||||
"feature.loading.message": "Loading",
|
||||
"feature.loading.error": "Error: {error}"
|
||||
}
|
||||
70
src/index.jsx
Executable file
70
src/index.jsx
Executable file
@@ -0,0 +1,70 @@
|
||||
import 'babel-polyfill';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { identifyAuthenticatedUser, sendPageEvent, configureAnalytics, initializeSegment } from '@edx/frontend-analytics';
|
||||
import LoggingService from '@edx/frontend-logging';
|
||||
import { getAuthenticatedAPIClient } from '@edx/frontend-auth';
|
||||
|
||||
import { configuration } from './environment';
|
||||
import { handleRtl } from './i18n/i18n-loader';
|
||||
import configureStore from './store';
|
||||
import { configureUserAccountApiService } from './common';
|
||||
import { configureApiService as configureFeatureApiService } from './feature';
|
||||
|
||||
import './index.scss';
|
||||
import App from './components/App';
|
||||
|
||||
const apiClient = getAuthenticatedAPIClient({
|
||||
appBaseUrl: configuration.BASE_URL,
|
||||
authBaseUrl: configuration.LMS_BASE_URL,
|
||||
loginUrl: configuration.LOGIN_URL,
|
||||
logoutUrl: configuration.LOGOUT_URL,
|
||||
csrfTokenApiPath: configuration.CSRF_TOKEN_API_PATH,
|
||||
refreshAccessTokenEndpoint: configuration.REFRESH_ACCESS_TOKEN_ENDPOINT,
|
||||
accessTokenCookieName: configuration.ACCESS_TOKEN_COOKIE_NAME,
|
||||
userInfoCookieName: configuration.USER_INFO_COOKIE_NAME,
|
||||
csrfCookieName: configuration.CSRF_COOKIE_NAME,
|
||||
});
|
||||
|
||||
/**
|
||||
* We need to merge the application configuration with the authentication state
|
||||
* so that we can hand it all to the redux store's initializer.
|
||||
*/
|
||||
function createInitialState() {
|
||||
return Object.assign({}, { configuration }, apiClient.getAuthenticationState());
|
||||
}
|
||||
|
||||
function configure() {
|
||||
const { store, history } = configureStore(createInitialState(), configuration.ENVIRONMENT);
|
||||
|
||||
configureFeatureApiService(configuration, apiClient);
|
||||
configureUserAccountApiService(configuration, apiClient);
|
||||
initializeSegment(configuration.SEGMENT_KEY);
|
||||
configureAnalytics({
|
||||
loggingService: LoggingService,
|
||||
authApiClient: apiClient,
|
||||
analyticsApiBaseUrl: configuration.LMS_BASE_URL,
|
||||
});
|
||||
|
||||
if (configuration.ENVIRONMENT === 'production') {
|
||||
handleRtl();
|
||||
}
|
||||
|
||||
return {
|
||||
store,
|
||||
history,
|
||||
};
|
||||
}
|
||||
|
||||
apiClient.ensurePublicOrAuthenticationAndCookies(
|
||||
window.location.pathname,
|
||||
() => {
|
||||
const { store, history } = configure();
|
||||
|
||||
ReactDOM.render(<App store={store} history={history} />, document.getElementById('root'));
|
||||
|
||||
identifyAuthenticatedUser();
|
||||
sendPageEvent();
|
||||
},
|
||||
);
|
||||
|
||||
37
src/index.scss
Executable file
37
src/index.scss
Executable file
@@ -0,0 +1,37 @@
|
||||
@import "~@edx/edx-bootstrap/scss/edx/theme.scss";
|
||||
|
||||
$fa-font-path: "~font-awesome/fonts";
|
||||
@import "~font-awesome/scss/font-awesome";
|
||||
|
||||
@import "~@edx/paragon/src/index.scss";
|
||||
@import "~@edx/frontend-component-site-header/src/index";
|
||||
@import "~@edx/frontend-component-footer/src/lib/scss/site-footer";
|
||||
|
||||
@import "./feature/style";
|
||||
|
||||
.word-break-all {
|
||||
word-break: break-all !important;
|
||||
}
|
||||
|
||||
// TODO: Update edx-bootstrap theme to incorporate these edits.
|
||||
.btn, a.btn {
|
||||
text-decoration: none;
|
||||
&:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
.btn-link {
|
||||
text-decoration: underline;
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
#app {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
& > main {
|
||||
flex-grow: 1;
|
||||
}
|
||||
}
|
||||
8
src/postcss.config.js
Normal file
8
src/postcss.config.js
Normal file
@@ -0,0 +1,8 @@
|
||||
/* I'm here to allow autoprefixing in webpack.prod.config.js */
|
||||
module.exports = {
|
||||
plugins: [
|
||||
/* eslint-disable-next-line global-require, import/no-extraneous-dependencies */
|
||||
require('autoprefixer')({ grid: true, browsers: ['>1%'] }),
|
||||
],
|
||||
};
|
||||
|
||||
25
src/reducers.js
Executable file
25
src/reducers.js
Executable file
@@ -0,0 +1,25 @@
|
||||
import { combineReducers } from 'redux';
|
||||
import { userAccount } from '@edx/frontend-auth';
|
||||
import { connectRouter } from 'connected-react-router';
|
||||
import {
|
||||
reducer as featureReducer,
|
||||
storeName as featureStoreName,
|
||||
} from './feature';
|
||||
|
||||
const identityReducer = (state) => {
|
||||
const newState = { ...state };
|
||||
return newState;
|
||||
};
|
||||
|
||||
const createRootReducer = history =>
|
||||
combineReducers({
|
||||
// The authentication state is added as initialState when
|
||||
// creating the store in data/store.js.
|
||||
authentication: identityReducer,
|
||||
configuration: identityReducer,
|
||||
userAccount,
|
||||
[featureStoreName]: featureReducer,
|
||||
router: connectRouter(history),
|
||||
});
|
||||
|
||||
export default createRootReducer;
|
||||
8
src/sagas.js
Normal file
8
src/sagas.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import { all } from 'redux-saga/effects';
|
||||
import { saga as featureSaga } from './feature';
|
||||
|
||||
export default function* rootSaga() {
|
||||
yield all([
|
||||
featureSaga(),
|
||||
]);
|
||||
}
|
||||
10
src/setupTest.js
Executable file
10
src/setupTest.js
Executable file
@@ -0,0 +1,10 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
|
||||
import Enzyme from 'enzyme';
|
||||
import Adapter from 'enzyme-adapter-react-16';
|
||||
|
||||
Enzyme.configure({ adapter: new Adapter() });
|
||||
|
||||
// These configuration values are usually set in webpack's EnvironmentPlugin however
|
||||
// Jest does not use webpack so we need to set these so for testing
|
||||
process.env.LMS_BASE_URL = 'http://localhost:18000';
|
||||
29
src/store/configureStore.dev.js
Normal file
29
src/store/configureStore.dev.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import { applyMiddleware, createStore } from 'redux';
|
||||
import createSagaMiddleware from 'redux-saga';
|
||||
import thunkMiddleware from 'redux-thunk';
|
||||
import { createBrowserHistory } from 'history';
|
||||
import { routerMiddleware } from 'connected-react-router';
|
||||
import { composeWithDevTools } from 'redux-devtools-extension/logOnlyInProduction';
|
||||
import { createLogger } from 'redux-logger';
|
||||
|
||||
import createRootReducer from '../reducers';
|
||||
import rootSaga from '../sagas';
|
||||
|
||||
export default function configureStore(initialState = {}) {
|
||||
const history = createBrowserHistory();
|
||||
|
||||
const loggerMiddleware = createLogger({
|
||||
collapsed: true,
|
||||
});
|
||||
const sagaMiddleware = createSagaMiddleware();
|
||||
|
||||
const store = createStore(
|
||||
createRootReducer(history),
|
||||
initialState,
|
||||
composeWithDevTools(applyMiddleware(thunkMiddleware, sagaMiddleware, routerMiddleware(history), loggerMiddleware)), // eslint-disable-line
|
||||
);
|
||||
|
||||
sagaMiddleware.run(rootSaga);
|
||||
|
||||
return { store, history };
|
||||
}
|
||||
24
src/store/configureStore.prod.js
Normal file
24
src/store/configureStore.prod.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { applyMiddleware, createStore, compose } from 'redux';
|
||||
import createSagaMiddleware from 'redux-saga';
|
||||
import thunkMiddleware from 'redux-thunk';
|
||||
import { createBrowserHistory } from 'history';
|
||||
import { routerMiddleware } from 'connected-react-router';
|
||||
|
||||
import createRootReducer from '../reducers';
|
||||
import rootSaga from '../sagas';
|
||||
|
||||
export default function configureStore(initialState = {}) {
|
||||
const history = createBrowserHistory();
|
||||
|
||||
const sagaMiddleware = createSagaMiddleware();
|
||||
|
||||
const store = createStore(
|
||||
createRootReducer(history),
|
||||
initialState,
|
||||
compose(applyMiddleware(thunkMiddleware, sagaMiddleware, routerMiddleware(history))),
|
||||
);
|
||||
|
||||
sagaMiddleware.run(rootSaga);
|
||||
|
||||
return { store, history };
|
||||
}
|
||||
9
src/store/index.js
Normal file
9
src/store/index.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import configureStoreProd from './configureStore.prod';
|
||||
import configureStoreDev from './configureStore.dev';
|
||||
|
||||
export default function configureStore(state, env) {
|
||||
if (env === 'production') {
|
||||
return configureStoreProd(state);
|
||||
}
|
||||
return configureStoreDev(state);
|
||||
}
|
||||
19
webpack/webpack.common.config.js
Executable file
19
webpack/webpack.common.config.js
Executable file
@@ -0,0 +1,19 @@
|
||||
// This is the common Webpack config. The dev and prod Webpack configs both
|
||||
// inherit config defined here.
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
entry: {
|
||||
app: path.resolve(__dirname, '../src/index.jsx'),
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, '../dist'),
|
||||
publicPath: '/',
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.js', '.jsx'],
|
||||
alias: {
|
||||
'@edx/frontend-i18n': path.resolve(__dirname, '../src/i18n/'),
|
||||
},
|
||||
},
|
||||
};
|
||||
153
webpack/webpack.dev.config.js
Executable file
153
webpack/webpack.dev.config.js
Executable file
@@ -0,0 +1,153 @@
|
||||
// This is the dev Webpack config. All settings here should prefer a fast build
|
||||
// time at the expense of creating larger, unoptimized bundles.
|
||||
|
||||
const Merge = require('webpack-merge');
|
||||
const path = require('path');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const webpack = require('webpack');
|
||||
|
||||
const commonConfig = require('./webpack.common.config.js');
|
||||
|
||||
module.exports = Merge.smart(commonConfig, {
|
||||
mode: 'development',
|
||||
devtool: 'eval-source-map',
|
||||
entry: {
|
||||
// enable react's custom hot dev client so we get errors reported in the browser
|
||||
hot: require.resolve('react-dev-utils/webpackHotDevClient'),
|
||||
app: path.resolve(__dirname, '../src/index.jsx'),
|
||||
},
|
||||
module: {
|
||||
// Specify file-by-file rules to Webpack. Some file-types need a particular kind of loader.
|
||||
rules: [
|
||||
// The babel-loader transforms newer ES2015+ syntax to older ES5 for older browsers.
|
||||
// Babel is configured with the .babelrc file at the root of the project.
|
||||
{
|
||||
test: /\.(js|jsx)$/,
|
||||
include: [
|
||||
path.resolve(__dirname, '../src'),
|
||||
],
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
// Caches result of loader to the filesystem. Future builds will attempt to read from the
|
||||
// cache to avoid needing to run the expensive recompilation process on each run.
|
||||
cacheDirectory: true,
|
||||
},
|
||||
},
|
||||
// We are not extracting CSS from the javascript bundles in development because extracting
|
||||
// prevents hot-reloading from working, it increases build time, and we don't care about
|
||||
// flash-of-unstyled-content issues in development.
|
||||
{
|
||||
test: /(.scss|.css)$/,
|
||||
use: [
|
||||
'style-loader', // creates style nodes from JS strings
|
||||
{
|
||||
loader: 'css-loader', // translates CSS into CommonJS
|
||||
options: {
|
||||
sourceMap: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: 'sass-loader', // compiles Sass to CSS
|
||||
options: {
|
||||
sourceMap: true,
|
||||
includePaths: [
|
||||
path.join(__dirname, '../node_modules'),
|
||||
path.join(__dirname, '../src'),
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /.svg$/,
|
||||
issuer: {
|
||||
test: /\.jsx?$/,
|
||||
},
|
||||
loader: '@svgr/webpack',
|
||||
},
|
||||
// Webpack, by default, uses the url-loader for images and fonts that are required/included by
|
||||
// files it processes, which just base64 encodes them and inlines them in the javascript
|
||||
// bundles. This makes the javascript bundles ginormous and defeats caching so we will use the
|
||||
// file-loader instead to copy the files directly to the output directory.
|
||||
{
|
||||
test: /\.(woff2?|ttf|svg|eot)(\?v=\d+\.\d+\.\d+)?$/,
|
||||
loader: 'file-loader',
|
||||
},
|
||||
{
|
||||
test: /\.(jpe?g|png|gif|ico)(\?v=\d+\.\d+\.\d+)?$/,
|
||||
use: [
|
||||
'file-loader',
|
||||
{
|
||||
loader: 'image-webpack-loader',
|
||||
options: {
|
||||
optimizationlevel: 7,
|
||||
mozjpeg: {
|
||||
progressive: true,
|
||||
},
|
||||
gifsicle: {
|
||||
interlaced: false,
|
||||
},
|
||||
pngquant: {
|
||||
quality: '65-90',
|
||||
speed: 4,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
// Specify additional processing or side-effects done on the Webpack output bundles as a whole.
|
||||
plugins: [
|
||||
// Generates an HTML file in the output directory.
|
||||
new HtmlWebpackPlugin({
|
||||
inject: true, // Appends script tags linking to the webpack bundles at the end of the body
|
||||
template: path.resolve(__dirname, '../public/index.html'),
|
||||
}),
|
||||
new webpack.EnvironmentPlugin({
|
||||
NODE_ENV: 'development',
|
||||
BASE_URL: 'localhost:1997',
|
||||
LMS_BASE_URL: 'http://localhost:18000',
|
||||
CREDENTIALS_BASE_URL: 'http://localhost:18150',
|
||||
ECOMMERCE_BASE_URL: 'http://localhost:18130',
|
||||
LOGIN_URL: 'http://localhost:18000/login',
|
||||
LOGOUT_URL: 'http://localhost:18000/login',
|
||||
CSRF_TOKEN_API_PATH: '/csrf/api/v1/token',
|
||||
REFRESH_ACCESS_TOKEN_ENDPOINT: 'http://localhost:18000/login_refresh',
|
||||
SEGMENT_KEY: null,
|
||||
ACCESS_TOKEN_COOKIE_NAME: 'edx-jwt-cookie-header-payload',
|
||||
USER_INFO_COOKIE_NAME: 'edx-user-info',
|
||||
CSRF_COOKIE_NAME: 'csrftoken',
|
||||
LANGUAGE_PREFERENCE_COOKIE_NAME: 'openedx-language-preference',
|
||||
SITE_NAME: 'edX',
|
||||
MARKETING_SITE_BASE_URL: 'http://localhost:18000',
|
||||
SUPPORT_URL: 'http://localhost:18000/support',
|
||||
CONTACT_URL: 'http://localhost:18000/contact',
|
||||
OPEN_SOURCE_URL: 'http://localhost:18000/openedx',
|
||||
TERMS_OF_SERVICE_URL: 'http://localhost:18000/terms-of-service',
|
||||
PRIVACY_POLICY_URL: 'http://localhost:18000/privacy-policy',
|
||||
FACEBOOK_URL: 'https://www.facebook.com',
|
||||
TWITTER_URL: 'https://twitter.com',
|
||||
YOU_TUBE_URL: 'https://www.youtube.com',
|
||||
LINKED_IN_URL: 'https://www.linkedin.com',
|
||||
GOOGLE_PLUS_URL: 'https://plus.google.com',
|
||||
REDDIT_URL: 'https://www.reddit.com',
|
||||
APPLE_APP_STORE_URL: 'https://www.apple.com/ios/app-store/',
|
||||
GOOGLE_PLAY_URL: 'https://play.google.com/store',
|
||||
}),
|
||||
// when the --hot option is not passed in as part of the command
|
||||
// the HotModuleReplacementPlugin has to be specified in the Webpack configuration
|
||||
// https://webpack.js.org/configuration/dev-server/#devserver-hot
|
||||
new webpack.HotModuleReplacementPlugin(),
|
||||
],
|
||||
// This configures webpack-dev-server which serves bundles from memory and provides live
|
||||
// reloading.
|
||||
devServer: {
|
||||
host: '0.0.0.0',
|
||||
port: 1997,
|
||||
historyApiFallback: true,
|
||||
hot: true,
|
||||
inline: true,
|
||||
publicPath: '/',
|
||||
},
|
||||
});
|
||||
174
webpack/webpack.prod.config.js
Executable file
174
webpack/webpack.prod.config.js
Executable file
@@ -0,0 +1,174 @@
|
||||
// This is the prod Webpack config. All settings here should prefer smaller,
|
||||
// optimized bundles at the expense of a longer build time.
|
||||
const Merge = require('webpack-merge');
|
||||
const commonConfig = require('./webpack.common.config.js');
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
||||
const HtmlWebpackNewRelicPlugin = require('html-webpack-new-relic-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
|
||||
const WebpackRTLPlugin = require('webpack-rtl-plugin');
|
||||
|
||||
module.exports = Merge.smart(commonConfig, {
|
||||
mode: 'production',
|
||||
devtool: 'source-map',
|
||||
output: {
|
||||
filename: '[name].[chunkhash].js',
|
||||
path: path.resolve(__dirname, '../dist'),
|
||||
},
|
||||
module: {
|
||||
// Specify file-by-file rules to Webpack. Some file-types need a particular kind of loader.
|
||||
rules: [
|
||||
// The babel-loader transforms newer ES2015+ syntax to older ES5 for older browsers.
|
||||
// Babel is configured with the .babelrc file at the root of the project.
|
||||
{
|
||||
test: /\.(js|jsx)$/,
|
||||
include: [
|
||||
path.resolve(__dirname, '../src'),
|
||||
],
|
||||
loader: 'babel-loader',
|
||||
},
|
||||
// Webpack, by default, includes all CSS in the javascript bundles. Unfortunately, that means:
|
||||
// a) The CSS won't be cached by browsers separately (a javascript change will force CSS
|
||||
// re-download). b) Since CSS is applied asyncronously, it causes an ugly
|
||||
// flash-of-unstyled-content.
|
||||
//
|
||||
// To avoid these problems, we extract the CSS from the bundles into separate CSS files that
|
||||
// can be included as <link> tags in the HTML <head> manually.
|
||||
//
|
||||
// We will not do this in development because it prevents hot-reloading from working and it
|
||||
// increases build time.
|
||||
{
|
||||
test: /(.scss|.css)$/,
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
{
|
||||
loader: 'css-loader', // translates CSS into CommonJS
|
||||
options: {
|
||||
sourceMap: true,
|
||||
minimize: true,
|
||||
},
|
||||
},
|
||||
'postcss-loader',
|
||||
{
|
||||
loader: 'sass-loader', // compiles Sass to CSS
|
||||
options: {
|
||||
sourceMap: true,
|
||||
includePaths: [
|
||||
path.join(__dirname, '../node_modules'),
|
||||
path.join(__dirname, '../src'),
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /.svg$/,
|
||||
issuer: {
|
||||
test: /\.jsx?$/,
|
||||
},
|
||||
loader: '@svgr/webpack',
|
||||
},
|
||||
// Webpack, by default, uses the url-loader for images and fonts that are required/included by
|
||||
// files it processes, which just base64 encodes them and inlines them in the javascript
|
||||
// bundles. This makes the javascript bundles ginormous and defeats caching so we will use the
|
||||
// file-loader instead to copy the files directly to the output directory.
|
||||
{
|
||||
test: /\.(woff2?|ttf|svg|eot)(\?v=\d+\.\d+\.\d+)?$/,
|
||||
loader: 'file-loader',
|
||||
},
|
||||
{
|
||||
test: /\.(jpe?g|png|gif|ico)(\?v=\d+\.\d+\.\d+)?$/,
|
||||
use: [
|
||||
'file-loader',
|
||||
{
|
||||
loader: 'image-webpack-loader',
|
||||
options: {
|
||||
optimizationlevel: 7,
|
||||
mozjpeg: {
|
||||
progressive: true,
|
||||
},
|
||||
gifsicle: {
|
||||
interlaced: false,
|
||||
},
|
||||
pngquant: {
|
||||
quality: '65-90',
|
||||
speed: 4,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
// New in Webpack 4. Replaces CommonChunksPlugin. Extract common modules among all chunks to one
|
||||
// common chunk and extract the Webpack runtime to a single runtime chunk.
|
||||
optimization: {
|
||||
runtimeChunk: 'single',
|
||||
splitChunks: {
|
||||
chunks: 'all',
|
||||
},
|
||||
},
|
||||
// Specify additional processing or side-effects done on the Webpack output bundles as a whole.
|
||||
plugins: [
|
||||
// Cleans the dist directory before each build
|
||||
new CleanWebpackPlugin(['dist'], {
|
||||
root: path.join(__dirname, '../'),
|
||||
}),
|
||||
// Writes the extracted CSS from each entry to a file in the output directory.
|
||||
new MiniCssExtractPlugin({
|
||||
filename: '[name].[chunkhash].css',
|
||||
}),
|
||||
new WebpackRTLPlugin({
|
||||
filename: '[name].[contenthash].rtl.css',
|
||||
}),
|
||||
// Generates an HTML file in the output directory.
|
||||
new HtmlWebpackPlugin({
|
||||
inject: true, // Appends script tags linking to the webpack bundles at the end of the body
|
||||
template: path.resolve(__dirname, '../public/index.html'),
|
||||
}),
|
||||
new webpack.EnvironmentPlugin({
|
||||
NODE_ENV: 'production',
|
||||
BASE_URL: null,
|
||||
LMS_BASE_URL: null,
|
||||
CREDENTIALS_BASE_URL: null,
|
||||
ECOMMERCE_BASE_URL: null,
|
||||
LOGIN_URL: null,
|
||||
LOGOUT_URL: null,
|
||||
CSRF_TOKEN_API_PATH: null,
|
||||
REFRESH_ACCESS_TOKEN_ENDPOINT: null,
|
||||
SEGMENT_KEY: null,
|
||||
ACCESS_TOKEN_COOKIE_NAME: null,
|
||||
USER_INFO_COOKIE_NAME: null,
|
||||
CSRF_COOKIE_NAME: 'csrftoken',
|
||||
LANGUAGE_PREFERENCE_COOKIE_NAME: null,
|
||||
SITE_NAME: null,
|
||||
MARKETING_SITE_BASE_URL: null,
|
||||
SUPPORT_URL: null,
|
||||
CONTACT_URL: null,
|
||||
OPEN_SOURCE_URL: null,
|
||||
TERMS_OF_SERVICE_URL: null,
|
||||
PRIVACY_POLICY_URL: null,
|
||||
FACEBOOK_URL: null,
|
||||
TWITTER_URL: null,
|
||||
YOU_TUBE_URL: null,
|
||||
LINKED_IN_URL: null,
|
||||
GOOGLE_PLUS_URL: null,
|
||||
REDDIT_URL: null,
|
||||
APPLE_APP_STORE_URL: null,
|
||||
GOOGLE_PLAY_URL: null,
|
||||
NEW_RELIC_ADMIN_KEY: null,
|
||||
NEW_RELIC_APP_ID: null,
|
||||
NEW_RELIC_LICENSE_KEY: null,
|
||||
}),
|
||||
new HtmlWebpackNewRelicPlugin({
|
||||
// This plugin fixes an issue where the newrelic script will break if
|
||||
// not added directly to the HTML.
|
||||
// We use non empty strings as defaults here to prevent errors for empty configs
|
||||
license: process.env.NEW_RELIC_LICENSE_KEY || 'fake_app',
|
||||
applicationID: process.env.NEW_RELIC_APP_ID || 'fake_license',
|
||||
}),
|
||||
],
|
||||
});
|
||||
Reference in New Issue
Block a user