1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2025-06-15 13:36:35 +02:00

Compare commits

...

23 Commits

Author SHA1 Message Date
76652db0b6 Merge branch 'add-customization-context' into 'dev'
Draft: Add CustomizationContext and custom hook

See merge request turris/reforis/foris-js!183
2022-09-19 12:11:43 +02:00
a4fd74bf38 Merge branch 'improve-docs' into 'dev'
Improve Foris JS documentation

See merge request turris/reforis/foris-js!190
2022-09-16 16:19:00 +02:00
b0e2f62a41 Add Switch example to the docs 2022-09-16 16:10:44 +02:00
caf8af44d1 Improve docs development section 2022-09-16 16:10:44 +02:00
fd7cd49790 Add custom logo & favicon 2022-09-16 16:10:43 +02:00
d95fdf8517 Restructure styleguide configuration file
* Add version of the library
* Change colors
* Set tocMode  to "collapse"
2022-09-16 16:10:43 +02:00
68c560078b Improve docs introduction section 2022-09-16 16:10:42 +02:00
83caf505d9 Improve description in package.json 2022-09-16 16:10:42 +02:00
3fc1388a9f fixup! Add CustomizationContext and custom hook 2022-06-09 17:45:14 +02:00
2bbdda566c Makefile: Add test-js-watch command 2022-06-09 17:45:13 +02:00
f12de3205f Remove testUtils from .gitignore 2022-06-09 17:45:13 +02:00
a971e8ce1a Add info about CustomizationContext to the docs 2022-06-09 17:45:13 +02:00
1297d8446c Add tests for CustomizationContext 2022-06-09 17:45:12 +02:00
0791087d8f Add CustomizationContext and custom hook
As we want to share customization context between reForis & Plugins
2022-06-09 17:45:12 +02:00
ce3d439005 Add about endpoint to forisUrls 2022-06-09 17:45:11 +02:00
d588291f1c Merge branch 'update-peer-deps' into 'dev'
Bump v5.4.1

See merge request turris/reforis/foris-js!198
2022-06-02 18:31:05 +02:00
bc044df7a8 Bump v5.4.1
* Add Weblate translations
* Update PropType peer dependency
* NPM audit fix
2022-06-02 11:12:05 +02:00
b4c6a7fb70 NPM audit fix 2022-06-02 11:12:04 +02:00
d6563d2ffd Update PropTypes library to v15.8.1
As reForis had updated library, there was a conflict in npm
between different versions of the library.

```
npm ERR! While resolving: reforis_js@1.2.1
npm ERR! Found: prop-types@15.8.1
npm ERR! node_modules/prop-types
npm ERR!   prop-types@"^15.8.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer prop-types@"15.7.2" from foris@5.4.0
npm ERR! node_modules/foris
npm ERR!   foris@"5.4.0" from the root project
```
2022-06-02 11:08:02 +02:00
af90d8d09d Merge branch 'update-translations' into 'master'
Add Weblate translations

See merge request turris/reforis/foris-js!199
2022-05-31 15:32:51 +02:00
006d6ce8d9 Translated using Weblate (Slovak)
Currently translated at 100.0% (67 of 67 strings)

Translation: Turris/Foris JS
Translate-URL: https://hosted.weblate.org/projects/turris/foris-js/sk/
2022-05-30 08:14:50 +02:00
cee08f48ce Translated using Weblate (Russian)
Currently translated at 100.0% (67 of 67 strings)

Translation: Turris/Foris JS
Translate-URL: https://hosted.weblate.org/projects/turris/foris-js/ru/
2022-05-28 11:19:05 +02:00
2d0ca58057 Translated using Weblate (Norwegian Bokmål)
Currently translated at 68.6% (46 of 67 strings)

Translation: Turris/Foris JS
Translate-URL: https://hosted.weblate.org/projects/turris/foris-js/nb_NO/
2022-05-25 15:20:48 +02:00
23 changed files with 395 additions and 155 deletions

1
.gitignore vendored
View File

@ -51,4 +51,3 @@ coverage.xml
dist/
foris-*.tgz
styleguide/
testUtils

View File

@ -97,6 +97,8 @@ test-js-watch:
.PHONY: test-js-update-snapshots
test-js-update-snapshots:
npm test -- -u
test-js-watch:
npm test -- --watch
# Translations

36
docs/components/Logo.js Normal file
View File

@ -0,0 +1,36 @@
import React from "react";
import PropTypes from "prop-types";
import Styled from "rsg-components/Styled";
import logo from "./logo.svg";
const styles = ({ fontFamily }) => ({
logo: {
display: "flex",
alignItems: "center",
margin: 0,
fontFamily: fontFamily.base,
fontSize: 18,
fontWeight: "normal",
},
image: {
height: "1.3em",
marginLeft: "-0.2em",
marginRight: "0.2em",
},
});
export function LogoRenderer({ classes, children }) {
return (
<h1 className={classes.logo}>
<img className={classes.image} src={logo} alt="React logo" />
{children}
</h1>
);
}
LogoRenderer.propTypes = {
classes: PropTypes.object.isRequired,
children: PropTypes.node,
};
export default Styled(styles)(LogoRenderer);

3
docs/components/logo.svg Normal file
View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1000" height="1000">
<path d="M288.258 240.0394L717.5586-.44c.803 62.277-1.8207 124.502-1.4996 186.7266 1.8208 7.6343-7.2288 10.1966-12.102 13.4908L286.4375 432.1518l1.8206-192.1124zm2.284 277.645L711 278.3176l-.8416 192.7742L457.357 614.514l-1.842 289.03-167.7097 95.8926 2.7365-481.753z"/>
</svg>

After

Width:  |  Height:  |  Size: 349 B

View File

@ -1,15 +1,15 @@
Sooner or later you will face with situation when you want/need to make some
changes in the library. Then the most important tool for you it's
Sooner or later, you will face with situation when you want/need to make some
changes in the library. Then the most important tool for you it's the
[`npm link`](https://docs.npmjs.com/cli/link).
Please, notice that it will not work if you link library just from root of the
repo. It happens due to location of sources `./src`. You need to pack library
first `make pack` and then link it from `./dist` directory.
Please, notice that it will not work if you link the library just from the root
of the repo. It happens due to the location of sources `./src`. You need to pack
the library first, `make pack` and then link it from the `./dist` directory.
Yeah it's not such comfortable solution for development. But it can fixed by
writing small script similar as `make pack` but with linking every file and
directory from `./src` to the some directory and linking then from it. Notice
that you need to link `package.json` and `package-lock.json` as well.
Yeah, it's not such a comfortable solution for development. But it can be fixed
by writing a small script similar to making a pack but by linking every file and
directory from `./src` to the same directory and linking then from it. Notice
that you need to link a `package.json` and a `package-lock.json` as well.
So step by step:

4
docs/forisjs-npm.svg Normal file
View File

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="500" fill="white">
<path d="M49.5 171.722222222222h400v133.333333333333h-200v22.222222222223h-88.888888888889v-22.222222222223H49.5V171.722222222222zm22.222222222222 111.111111111111h44.444444444445v-66.666666666667h22.222222222222v66.666666666667h22.222222222222v-88.888888888889H71.722222222222v88.888888888889zm111.111111111111-88.888888888889v111.111111111111h44.444444444445v-22.222222222222h44.444444444444v-88.888888888889h-88.888888888889zm44.444444444445 22.222222222222H249.5v44.444444444445h-22.222222222222v-44.444444444445zm66.666666666666-22.222222222222v88.888888888889h44.444444444445v-66.666666666667h22.222222222222v66.666666666667h22.222222222222v-66.666666666667h22.222222222222v66.666666666667h22.222222222223v-88.888888888889H293.944444444444z" fill="#cb3837" />
<path d="M71.722222222222 282.833333333333h44.444444444444v-66.666666666667h22.222222222223v66.666666666667h22.222222222222v-88.888888888889H71.722222222222zm111.111111111111-88.888888888889v111.111111111111h44.444444444444v-22.222222222222h44.444444444445v-88.888888888889h-88.888888888889zM249.5 260.611111111111h-22.222222222223v-44.444444444445H249.5v44.444444444445zm44.444444444444-66.666666666667v88.888888888889h44.444444444444v-66.666666666667h22.222222222223v66.666666666667h22.222222222222v-66.666666666667h22.222222222222v66.666666666667h22.222222222222v-88.888888888889z" />
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -1,6 +0,0 @@
Foris JS library is set of components and utils for Foris JS application and
plugins.
Please notice that all of these components or utils are used in reForis and
plugins. If you like to study by example I would recommend to full-text search
these repos.

37
docs/introduction.md Normal file
View File

@ -0,0 +1,37 @@
Welcome! This is the official documentation for Foris JS.
## What Foris JS is
Foris JS library is a set of components and utils for reForis application and
plugins.
Please notice that all of these components or utils are used in reForis and
plugins. If you want to study them by example, I recommend you to full-text
search those repositories.
# Installation
## Prerequisites
Please make sure that [Node.js](https://nodejs.org/en/) is installed on your
system.
The current Long Term Support (LTS) release is an ideal starting point, see
[here](https://github.com/nodejs/Release#release-schedule).
## Installation
To install the latest release:
```plain
npm install foris
```
To install a specific version:
```plain
npm install foris@version
```
<a target="_blank" href="https://www.npmjs.com/package/foris">Check
on<img width="100px" src="./docs/forisjs-npm.svg"></a>

116
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "foris",
"version": "5.4.0",
"version": "5.4.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "foris",
"version": "5.4.0",
"version": "5.4.1",
"license": "GPL-3.0",
"dependencies": {
"axios": "^0.21.1",
@ -37,7 +37,7 @@
"jest-mock-axios": "^3.2.0",
"moment-timezone": "^0.5.34",
"prettier": "2.0.5",
"prop-types": "15.7.2",
"prop-types": "15.8.1",
"react": "16.9.0",
"react-dom": "16.9.0",
"react-router-dom": "^5.1.2",
@ -48,7 +48,7 @@
},
"peerDependencies": {
"bootstrap": "4.4.1",
"prop-types": "15.7.2",
"prop-types": "15.8.1",
"react": "16.9.0",
"react-dom": "16.9.0",
"react-router-dom": "^5.1.2"
@ -6901,15 +6901,12 @@
}
},
"node_modules/eventsource": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/eventsource/-/eventsource-1.1.0.tgz",
"integrity": "sha512-VSJjT5oCNrFvCS6igjzPAt5hBzQ2qPBFIbJ03zLI9SE0mxwZpMw6BfJrbFHm1a141AavMEB8JHmBhWAd66PfCg==",
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/eventsource/-/eventsource-2.0.2.tgz",
"integrity": "sha512-IzUmBGPR3+oUG9dUeXynyNmf91/3zUSJg1lCktzKw47OXuhco54U3r9B7O4XX+Rb1Itm9OZ2b0RkTs10bICOxA==",
"dev": true,
"dependencies": {
"original": "^1.0.0"
},
"engines": {
"node": ">=0.12.0"
"node": ">=12.0.0"
}
},
"node_modules/exec-sh": {
@ -11728,12 +11725,6 @@
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=",
"dev": true
},
"node_modules/json3": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/json3/-/json3-3.3.3.tgz",
"integrity": "sha512-c7/8mbUsKigAbLkD5B010BK4D9LZm7A1pNItkEwiUZRpIN66exu/e7YQWysGun+TRKaJp8MhemM+VkfWv42aCA==",
"dev": true
},
"node_modules/json5": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz",
@ -13318,15 +13309,6 @@
"node": ">=8"
}
},
"node_modules/original": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/original/-/original-1.0.2.tgz",
"integrity": "sha512-hyBVl6iqqUOJ8FqRe+l/gS8H+kKYjrEndd5Pm1MfBtsEKA038HkkdbAl/72EAXGyonD/PFsvmVG+EvcIpliMBg==",
"dev": true,
"dependencies": {
"url-parse": "^1.4.3"
}
},
"node_modules/os-tmpdir": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
@ -14025,13 +14007,13 @@
}
},
"node_modules/prop-types": {
"version": "15.7.2",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz",
"integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==",
"version": "15.8.1",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
"integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==",
"dependencies": {
"loose-envify": "^1.4.0",
"object-assign": "^4.1.1",
"react-is": "^16.8.1"
"react-is": "^16.13.1"
}
},
"node_modules/proxy-addr": {
@ -16501,17 +16483,22 @@
}
},
"node_modules/sockjs-client": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/sockjs-client/-/sockjs-client-1.5.2.tgz",
"integrity": "sha512-ZzRxPBISQE7RpzlH4tKJMQbHM9pabHluk0WBaxAQ+wm/UieeBVBou0p4wVnSQGN9QmpAZygQ0cDIypWuqOFmFQ==",
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/sockjs-client/-/sockjs-client-1.6.1.tgz",
"integrity": "sha512-2g0tjOR+fRs0amxENLi/q5TiJTqY+WXFOzb5UwXndlK6TO3U/mirZznpx6w34HVMoc3g7cY24yC/ZMIYnDlfkw==",
"dev": true,
"dependencies": {
"debug": "^3.2.6",
"eventsource": "^1.0.7",
"faye-websocket": "^0.11.3",
"debug": "^3.2.7",
"eventsource": "^2.0.2",
"faye-websocket": "^0.11.4",
"inherits": "^2.0.4",
"json3": "^3.3.3",
"url-parse": "^1.5.3"
"url-parse": "^1.5.10"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://tidelift.com/funding/github/npm/sockjs-client"
}
},
"node_modules/sockjs-client/node_modules/debug": {
@ -18534,7 +18521,7 @@
"node_modules/webpack-dev-server/node_modules/glob-parent": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz",
"integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=",
"integrity": "sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==",
"dev": true,
"dependencies": {
"is-glob": "^3.1.0",
@ -24455,13 +24442,10 @@
"dev": true
},
"eventsource": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/eventsource/-/eventsource-1.1.0.tgz",
"integrity": "sha512-VSJjT5oCNrFvCS6igjzPAt5hBzQ2qPBFIbJ03zLI9SE0mxwZpMw6BfJrbFHm1a141AavMEB8JHmBhWAd66PfCg==",
"dev": true,
"requires": {
"original": "^1.0.0"
}
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/eventsource/-/eventsource-2.0.2.tgz",
"integrity": "sha512-IzUmBGPR3+oUG9dUeXynyNmf91/3zUSJg1lCktzKw47OXuhco54U3r9B7O4XX+Rb1Itm9OZ2b0RkTs10bICOxA==",
"dev": true
},
"exec-sh": {
"version": "0.3.6",
@ -28141,12 +28125,6 @@
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=",
"dev": true
},
"json3": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/json3/-/json3-3.3.3.tgz",
"integrity": "sha512-c7/8mbUsKigAbLkD5B010BK4D9LZm7A1pNItkEwiUZRpIN66exu/e7YQWysGun+TRKaJp8MhemM+VkfWv42aCA==",
"dev": true
},
"json5": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz",
@ -29378,15 +29356,6 @@
}
}
},
"original": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/original/-/original-1.0.2.tgz",
"integrity": "sha512-hyBVl6iqqUOJ8FqRe+l/gS8H+kKYjrEndd5Pm1MfBtsEKA038HkkdbAl/72EAXGyonD/PFsvmVG+EvcIpliMBg==",
"dev": true,
"requires": {
"url-parse": "^1.4.3"
}
},
"os-tmpdir": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
@ -29906,13 +29875,13 @@
}
},
"prop-types": {
"version": "15.7.2",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz",
"integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==",
"version": "15.8.1",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
"integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==",
"requires": {
"loose-envify": "^1.4.0",
"object-assign": "^4.1.1",
"react-is": "^16.8.1"
"react-is": "^16.13.1"
}
},
"proxy-addr": {
@ -31827,17 +31796,16 @@
}
},
"sockjs-client": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/sockjs-client/-/sockjs-client-1.5.2.tgz",
"integrity": "sha512-ZzRxPBISQE7RpzlH4tKJMQbHM9pabHluk0WBaxAQ+wm/UieeBVBou0p4wVnSQGN9QmpAZygQ0cDIypWuqOFmFQ==",
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/sockjs-client/-/sockjs-client-1.6.1.tgz",
"integrity": "sha512-2g0tjOR+fRs0amxENLi/q5TiJTqY+WXFOzb5UwXndlK6TO3U/mirZznpx6w34HVMoc3g7cY24yC/ZMIYnDlfkw==",
"dev": true,
"requires": {
"debug": "^3.2.6",
"eventsource": "^1.0.7",
"faye-websocket": "^0.11.3",
"debug": "^3.2.7",
"eventsource": "^2.0.2",
"faye-websocket": "^0.11.4",
"inherits": "^2.0.4",
"json3": "^3.3.3",
"url-parse": "^1.5.3"
"url-parse": "^1.5.10"
},
"dependencies": {
"debug": {
@ -33442,7 +33410,7 @@
"glob-parent": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz",
"integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=",
"integrity": "sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==",
"dev": true,
"requires": {
"is-glob": "^3.1.0",

View File

@ -1,7 +1,7 @@
{
"name": "foris",
"version": "5.4.0",
"description": "Set of components and utils for Foris and its plugins.",
"version": "5.4.1",
"description": "Foris JS library is a set of components and utils for reForis application and plugins.",
"author": "CZ.NIC, z.s.p.o.",
"repository": {
"type": "git",
@ -23,7 +23,7 @@
},
"peerDependencies": {
"bootstrap": "4.4.1",
"prop-types": "15.7.2",
"prop-types": "15.8.1",
"react": "16.9.0",
"react-dom": "16.9.0",
"react-router-dom": "^5.1.2"
@ -49,7 +49,7 @@
"jest-mock-axios": "^3.2.0",
"moment-timezone": "^0.5.34",
"prettier": "2.0.5",
"prop-types": "15.7.2",
"prop-types": "15.8.1",
"react": "16.9.0",
"react-dom": "16.9.0",
"react-router-dom": "^5.1.2",

5
src/bootstrap/Switch.md Normal file
View File

@ -0,0 +1,5 @@
Switch example:
```js
<Switch label="Enable Switch" helpText="Toggle that switch!" />
```

View File

@ -0,0 +1,57 @@
/*
* Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
*/
import React, { useContext, useEffect } from "react";
import PropTypes from "prop-types";
import { useAPIGet } from "../api/hooks";
import { ForisURLs } from "../utils/forisUrls";
import { Spinner } from "../bootstrap/Spinner";
CustomizationContextProvider.propTypes = {
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node,
]),
};
function CustomizationContextProvider({ children }) {
const { CustomizationContext } = window;
const [getCustomizationResponse, getCustomization] = useAPIGet(
ForisURLs.about
);
useEffect(() => {
getCustomization();
}, [getCustomization]);
if (getCustomizationResponse.state !== "success") {
return <Spinner fullScreen />;
}
const deviceDetails = getCustomizationResponse.data || {};
const isCustomized = !!(
deviceDetails &&
deviceDetails.customization !== undefined &&
deviceDetails.customization === "shield"
);
return (
<CustomizationContext.Provider value={{ deviceDetails, isCustomized }}>
{children}
</CustomizationContext.Provider>
);
}
function useCustomizationContext() {
const { CustomizationContext } = window;
return useContext(CustomizationContext);
}
export { CustomizationContextProvider, useCustomizationContext };

View File

@ -0,0 +1,3 @@
It provides customization context to the children. `CustomizationContext` allows
using `useCustomizationContext` in components to check if the reForis UI is
customized or not for specific devices.

View File

@ -0,0 +1,57 @@
/*
* Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
*/
import React from "react";
import { render, wait } from "customTestRender";
import mockAxios from "jest-mock-axios";
import {
useCustomizationContext,
CustomizationContextProvider,
} from "../CustomizationContext";
const CUSTOM = "Description / component for customized reForis (Shield)";
const ORIGINAL = "Description / component for original reForis (other devices)";
function CustomizationTest() {
const isCustomized = useCustomizationContext();
return <p>{isCustomized ? CUSTOM : ORIGINAL}</p>;
}
describe("CustomizationContext", () => {
let componentContainer;
it("should render component without customization", async () => {
const { container, getByText } = render(
<CustomizationContextProvider>
<CustomizationTest />
</CustomizationContextProvider>
);
componentContainer = container;
mockAxios.mockResponse({ data: {} });
await wait(() => getByText(ORIGINAL));
expect(componentContainer).toMatchSnapshot();
});
it("should render customized component", async () => {
const { container, getByText } = render(
<CustomizationContextProvider>
<CustomizationTest />
</CustomizationContextProvider>
);
componentContainer = container;
mockAxios.mockResponse({ data: { customization: "shield" } });
await wait(() => getByText(CUSTOM));
expect(componentContainer).toMatchSnapshot();
});
});

View File

@ -0,0 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`CustomizationContext should render component without customization 1`] = `
<div>
<p>
Description / component for original reForis (other devices)
</p>
</div>
`;
exports[`CustomizationContext should render customized component 1`] = `
<div>
<p>
Description / component for customized reForis (Shield)
</p>
</div>
`;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
* Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
@ -91,3 +91,9 @@ export {
// Alert context
export { AlertContextProvider, useAlert } from "./alertContext/AlertContext";
// Customization context
export {
CustomizationContextProvider,
useCustomizationContext,
} from "./customizationContext/CustomizationContext";

View File

@ -14,6 +14,7 @@ import { render } from "@testing-library/react";
import PropTypes from "prop-types";
import { AlertContextMock } from "./alertContextMock";
import { CustomizationContextMock } from "./cutomizationContextMock";
Wrapper.propTypes = {
children: PropTypes.oneOfType([
@ -25,9 +26,11 @@ Wrapper.propTypes = {
function Wrapper({ children }) {
return (
<AlertContextMock>
<StaticRouter>
<UIDReset>{children}</UIDReset>
</StaticRouter>
<CustomizationContextMock>
<StaticRouter>
<UIDReset>{children}</UIDReset>
</StaticRouter>
</CustomizationContextMock>
</AlertContextMock>
);
}

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
*/
import React from "react";
window.CustomizationContext = React.createContext();
const isCustomized = jest.fn();
function CustomizationContextMock({ children }) {
return (
<CustomizationContext.Provider value={isCustomized}>
{children}
</CustomizationContext.Provider>
);
}
export { CustomizationContextMock };

View File

@ -36,5 +36,6 @@ export const ForisURLs = {
luci: "/cgi-bin/luci",
// API
about: `${REFORIS_API_URL_PREFIX}/about`,
reboot: `${REFORIS_API_URL_PREFIX}/reboot`,
};

View File

@ -1,36 +1,59 @@
/*
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
* Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
*/
const path = require("path");
const pjson = require("./package.json");
module.exports = {
title: "Foris JS docs",
title: "Foris JS Docs",
version: `v${pjson.version}`,
theme: {
color: {
link: "#0075a3",
linkHover: "#00a2e2",
},
},
tocMode: "collapse",
pagePerSection: true,
sections: [
{
name: "Foris JS",
content: "docs/intro.md",
name: "Introduction",
content: "docs/introduction.md",
},
{
name: "Development (Linking)",
name: "Development",
content: "docs/development.md",
},
{
name: "Foris forms",
components: [
"src/form/components/ForisForm.js",
"src/form/components/alerts.js",
"src/form/components/SubmitButton.js",
name: "Components",
description: "Set of main components.",
sections: [
{
name: "Foris forms",
components: [
"src/form/components/ForisForm.js",
"src/form/components/alerts.js",
"src/form/components/SubmitButton.js",
],
exampleMode: "expand",
usageMode: "expand",
},
{
name: "Alert Context",
components: ["src/alertContext/AlertContext.js"],
exampleMode: "expand",
usageMode: "expand",
},
],
exampleMode: "expand",
usageMode: "expand",
sectionDepth: 1,
},
{
name: "Alert Context",
components: ["src/alertContext/AlertContext.js"],
name: "Customization Context",
components: ["src/customizationContext/CustomizationContext.js"],
exampleMode: "expand",
usageMode: "expand",
},
@ -41,8 +64,12 @@ module.exports = {
exampleMode: "expand",
usageMode: "expand",
ignore: ["src/bootstrap/constants.js"],
sectionDepth: 0,
},
],
template: {
favicon: "/docs/components/logo.svg",
},
require: [
"babel-polyfill",
path.join(__dirname, "src/testUtils/mockGlobals"),
@ -55,6 +82,9 @@ module.exports = {
"node_modules/@fortawesome/fontawesome-free/css/all.min.css"
),
],
styleguideComponents: {
LogoRenderer: path.join(__dirname, "docs/components/Logo"),
},
webpackConfig: {
module: {
rules: [
@ -73,5 +103,8 @@ module.exports = {
},
],
},
devServer: {
publicPath: "/",
},
},
};

View File

@ -8,15 +8,16 @@ msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2022-05-20 15:42+0200\n"
"PO-Revision-Date: 2022-03-10 23:09+0000\n"
"PO-Revision-Date: 2022-05-25 13:20+0000\n"
"Last-Translator: Allan Nordhøy <epost@anotheragency.no>\n"
"Language-Team: Norwegian Bokmål <https://hosted.weblate.org/projects/turris/"
"foris-js/nb_NO/>\n"
"Language: nb_NO\n"
"Language-Team: Norwegian Bokmål "
"<https://hosted.weblate.org/projects/turris/foris-js/nb_NO/>\n"
"Plural-Forms: nplurals=2; plural=n != 1\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.13-dev\n"
"Generated-By: Babel 2.9.0\n"
#: src/api/utils.js:61
@ -38,11 +39,11 @@ msgstr "Ukjent API-feil."
#: src/bootstrap/CopyInput.js:55
msgid "Copied!"
msgstr ""
msgstr "Kopiert"
#: src/bootstrap/CopyInput.js:55
msgid "Copy"
msgstr ""
msgstr "Kopier"
#: src/common/RebootButton.js:27
#, fuzzy
@ -125,9 +126,8 @@ msgid "auto"
msgstr "automatisk"
#: src/common/WiFiSettings/WiFiForm.js:284
#, fuzzy
msgid "Custom"
msgstr "automatisk"
msgstr "Tilpasset"
#: src/common/WiFiSettings/WiFiGuestForm.js:42
#, fuzzy
@ -395,4 +395,3 @@ msgstr "Inneholder ikke en kommainndelt liste med e-postadresser."
#~ "\n"
#~ "gjeldende Wi-Fi-oppsett og tilbakestiller forvalgte verdier.\n"
#~ " "

View File

@ -8,16 +8,17 @@ msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2022-05-20 15:42+0200\n"
"PO-Revision-Date: 2022-03-12 06:58+0000\n"
"PO-Revision-Date: 2022-05-28 09:19+0000\n"
"Last-Translator: Алексей Леньшин <alenshin@gmail.com>\n"
"Language-Team: Russian <https://hosted.weblate.org/projects/turris/foris-js/"
"ru/>\n"
"Language: ru\n"
"Language-Team: Russian <https://hosted.weblate.org/projects/turris/foris-"
"js/ru/>\n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
"X-Generator: Weblate 4.13-dev\n"
"Generated-By: Babel 2.9.0\n"
#: src/api/utils.js:61
@ -38,11 +39,11 @@ msgstr "Неизвестная ошибка программного интер
#: src/bootstrap/CopyInput.js:55
msgid "Copied!"
msgstr ""
msgstr "Скопировано!"
#: src/bootstrap/CopyInput.js:55
msgid "Copy"
msgstr ""
msgstr "Копировать"
#: src/common/RebootButton.js:27
msgid "Reboot request failed."
@ -105,9 +106,8 @@ msgid "Hide SSID"
msgstr "Скрыть SSID"
#: src/common/WiFiSettings/WiFiForm.js:186
#, fuzzy
msgid "802.11n/ac/ax mode"
msgstr "Режим 802.11n/ac"
msgstr "Режим 802.11n/ac/ax"
#: src/common/WiFiSettings/WiFiForm.js:199
msgid "Channel"
@ -227,9 +227,8 @@ msgstr ""
"некоторых устройствах."
#: src/common/WiFiSettings/constants.js:34
#, fuzzy
msgid "WPA2/3 pre-shared key, that is required to connect to the network."
msgstr "Общий ключ WPA2, необходимый для подключения к сети."
msgstr "Общий ключ WPA2/3, необходимый для подключения к сети."
#: src/common/WiFiSettings/constants.js:37
msgid "If set, network is not visible when scanning for available networks."
@ -250,17 +249,16 @@ msgstr ""
"помещении сигнал проходит не так хорошо."
#: src/common/WiFiSettings/constants.js:43
#, fuzzy
msgid ""
"Change this to adjust 802.11n/ac/ax mode of operation. 802.11n with 40 "
"MHz wide channels can yield higher throughput but can cause more "
"interference in the network. If you don't know what to choose, use the "
"default option with 20 MHz wide channel."
msgstr ""
"Измените это, чтобы настроить режим работы 802.11n/ac. 802.11n с каналами"
" шириной 40 МГц обеспечивает более высокую пропускную способность, но "
"может вызывать больше помех в сети. Если вы не знаете, что выбрать, "
"используйте опцию по умолчанию с каналом шириной 20 МГц."
"Измените это, чтобы настроить режим работы 802.11n/ac/ax. 802.11n с каналами "
"шириной 40 МГц обеспечивает более высокую пропускную способность, но может "
"вызывать больше помех в сети. Если вы не знаете, что выбрать, используйте "
"опцию по умолчанию с каналом шириной 20 МГц."
#: src/common/WiFiSettings/constants.js:46
msgid ""
@ -374,4 +372,3 @@ msgstr "Не содержит списка электронных адресов
#~ "конфигурации Wi-Fi и восстановлению "
#~ "значений по умолчанию.\n"
#~ " "

View File

@ -8,15 +8,16 @@ msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2022-05-20 15:42+0200\n"
"PO-Revision-Date: 2022-03-17 17:58+0000\n"
"PO-Revision-Date: 2022-05-30 06:14+0000\n"
"Last-Translator: Atec <dr.atec@gmail.com>\n"
"Language-Team: Slovak <https://hosted.weblate.org/projects/turris/foris-js/"
"sk/>\n"
"Language: sk\n"
"Language-Team: Slovak <https://hosted.weblate.org/projects/turris/foris-"
"js/sk/>\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
"X-Generator: Weblate 4.13-dev\n"
"Generated-By: Babel 2.9.0\n"
#: src/api/utils.js:61
@ -37,11 +38,11 @@ msgstr "Nastala neznáma chyba v API."
#: src/bootstrap/CopyInput.js:55
msgid "Copied!"
msgstr ""
msgstr "Skopírované!"
#: src/bootstrap/CopyInput.js:55
msgid "Copy"
msgstr ""
msgstr "Kopírovať"
#: src/common/RebootButton.js:27
msgid "Reboot request failed."
@ -104,9 +105,8 @@ msgid "Hide SSID"
msgstr "Skryť SSID"
#: src/common/WiFiSettings/WiFiForm.js:186
#, fuzzy
msgid "802.11n/ac/ax mode"
msgstr "802.11 n/ac mód"
msgstr "802.11 n/ac/ax mód"
#: src/common/WiFiSettings/WiFiForm.js:199
msgid "Channel"
@ -226,9 +226,8 @@ msgstr ""
"problémy."
#: src/common/WiFiSettings/constants.js:34
#, fuzzy
msgid "WPA2/3 pre-shared key, that is required to connect to the network."
msgstr "WPA2 vopred zdieľaný kľúč, ktorý sa vyžaduje na pripojenie k sieti."
msgstr "WPA2/3 vopred zdieľaný kľúč, ktorý sa vyžaduje na pripojenie k sieti."
#: src/common/WiFiSettings/constants.js:37
msgid "If set, network is not visible when scanning for available networks."
@ -249,17 +248,16 @@ msgstr ""
"budov šíri horšie."
#: src/common/WiFiSettings/constants.js:43
#, fuzzy
msgid ""
"Change this to adjust 802.11n/ac/ax mode of operation. 802.11n with 40 "
"MHz wide channels can yield higher throughput but can cause more "
"interference in the network. If you don't know what to choose, use the "
"default option with 20 MHz wide channel."
msgstr ""
"Zmenou tejto položky sa nastavuje režim prevádzky 802.11n/ac. Štandard "
"802.11n so šírkou kanálov 40 MHz môže priniesť vyššiu priepustnosť, ale "
"môže spôsobiť väčšie rušenie. Ak si nie ste istí, použite predvolenú "
"možnosť so šírkou kanála 20 MHz."
"Zmenou tejto položky sa nastavuje režim prevádzky 802.11n/ac/ax. Štandard "
"802.11n so šírkou kanálov 40 MHz môže priniesť vyššiu priepustnosť, ale môže "
"spôsobiť väčšie rušenie. Ak si nie ste istí, použite predvolenú možnosť so "
"šírkou kanála 20 MHz."
#: src/common/WiFiSettings/constants.js:46
msgid ""
@ -370,4 +368,3 @@ msgstr "Neobsahuje zoznam e-mailov oddelených čiarkami."
#~ "že sa tým odstráni aktuálna konfigurácia"
#~ " a obnovia sa východiskové hodnoty.\n"
#~ " "