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

Compare commits

...

56 Commits

Author SHA1 Message Date
8d75b5ec6e Bump v5.1.9
* Fix trailing space in Modal classes
* Change formFieldsSize of ResetWiFiSettings card
* Increase bottom margin of formFieldsSize
2021-01-20 11:42:24 +01:00
c1aa1948b4 Merge branch 'fix-wifi-layout' into 'dev'
Fix Wi-Fi layout

See merge request turris/reforis/foris-js!145
2021-01-19 16:42:17 +01:00
8c110ebf52 NPM audit fix 2021-01-18 23:31:43 +01:00
abb5be53aa Fix trailing space in Modal classes 2021-01-18 23:10:39 +01:00
af0fb80e45 Update Snapshots 2021-01-18 23:10:39 +01:00
688192504f Change formFieldsSize of ResetWiFiSettings card 2021-01-18 22:06:20 +01:00
b8e5dbec8d Increase bottom margin of formFieldsSize 2021-01-18 22:05:56 +01:00
fde751a25f Merge branch 'check-installed-plugins' into 'dev'
Add isPluginInstalled function

See merge request turris/reforis/foris-js!143
2020-12-20 18:47:06 +01:00
79006cfb99 Bump v5.1.8 2020-12-19 00:25:44 +01:00
de398901f3 Add isPluginInstalled function 2020-12-19 00:14:05 +01:00
56173d4959 Merge branch 'add-storage-link' into 'dev'
Add storage link

See merge request turris/reforis/foris-js!141
2020-11-27 17:09:55 +01:00
7c837d041e Bump v5.1.7 2020-11-27 15:37:07 +01:00
473c81f9a4 Add storage link 2020-11-27 15:37:02 +01:00
15567a7dde Merge branch 'release-516' into 'dev'
Bump v5.1.6

Closes #18

See merge request turris/reforis/foris-js!139
2020-11-27 12:30:39 +01:00
e2695d49a1 Bump v5.1.6
* NPM audit fix
* Add displayCard function to utils
* Add optional sizes to Modal
* Add information about optional sizes to docs
* Remove redundant merge.py
2020-11-25 23:29:42 +01:00
a87e6858bf Remove redundant merge.py 2020-11-25 23:29:31 +01:00
e864de5a24 Merge branch 'add-optional-sizes-modals' into 'dev'
Add optional sizes to Modals

See merge request turris/reforis/foris-js!138
2020-11-23 22:25:18 +01:00
5469e6ec80 Add displayCard function to utils 2020-11-22 23:45:27 +01:00
4898016388 Update Snapshots 2020-11-20 17:02:10 +01:00
e0fab75c69 NPM audit fix 2020-11-20 17:00:26 +01:00
6480a39cdb Add information about optional sizes to docs 2020-11-20 16:56:25 +01:00
6f05d5d136 Add optional sizes to Modal 2020-11-20 16:56:16 +01:00
0892a1534a Merge branch 'release-v5.1.5' into 'dev'
Release v5.1.5

See merge request turris/reforis/foris-js!136
2020-09-29 10:56:55 +02:00
1bac60e054 Bump v5.1.5 2020-09-25 19:27:58 +02:00
328e568ab3 NPM audit fix 2020-09-25 19:26:57 +02:00
c68389359e Update Snapshots 2020-09-25 18:52:25 +02:00
e03e0f44cc Fix extra empty space in Switch's classes 2020-09-25 18:50:04 +02:00
1e04d34645 Fix DateTime import 2020-09-25 18:50:04 +02:00
ed7cf34e76 Merge branch 'release-v5.1.4' into 'dev'
Release v5.1.4

See merge request turris/reforis/foris-js!133
2020-09-25 17:43:10 +02:00
aaf4087c96 Update Snapshots 2020-09-25 17:32:04 +02:00
240db88661 Bump v5.1.4 2020-09-25 17:27:47 +02:00
913a7d7b75 Add closing bootstrap modal using ESC 2020-09-25 17:27:47 +02:00
bdc8726791 Change reboot modal's heading to "Warning!" 2020-09-25 17:27:46 +02:00
1c986519f6 Fix Alert's dismissible class condition 2020-09-25 17:27:46 +02:00
defc363f01 Add inline option to Wi-Fi's RadioSet 2020-09-14 18:48:30 +02:00
69723f6b0b Merge branch 'new-bump' into 'dev'
Bump v5.1.3

See merge request turris/reforis/foris-js!130
2020-09-11 18:08:32 +02:00
c32137e29a Bump v5.1.3 2020-09-11 18:00:05 +02:00
be7349661f Merge branch 'ssid-validation' into 'dev'
Ssid validation

Closes reforis#218

See merge request turris/reforis/foris-js!128
2020-09-11 17:39:05 +02:00
5186385b9f Update snapshots 2020-09-11 17:32:46 +02:00
002786d073 Add test 2020-09-11 17:32:46 +02:00
4d246540c1 Add SSID validation for bytes count 2020-09-11 17:32:45 +02:00
35b97ec0fe Add validation for SSID with diacritic 2020-09-11 17:32:45 +02:00
e1d75d8328 Merge branch 'release-v5.1.2' into 'dev'
Bump v5.1.2

See merge request turris/reforis/foris-js!126
2020-09-08 18:36:28 +02:00
0f85713483 Bump v5.1.2 2020-09-08 18:26:15 +02:00
c3cdafce13 Merge branch 'fix-ws-loop' into 'dev'
Fix infinity loop caused by WebSockets

Closes #17

See merge request turris/reforis/foris-js!125
2020-09-08 18:11:05 +02:00
b96b434a3e Update Snapshots 2020-09-02 17:55:53 +02:00
0ea5f7de84 Decrease Switch's margin-bottom with headings 2020-09-02 17:55:44 +02:00
0c7997f6c0 Fix Reboot page URL in respective dropdown 2020-09-02 17:55:44 +02:00
90ce866869 Fix infinity loop caused by WebSockets 2020-09-02 17:55:25 +02:00
4ff814f0fd Merge branch 'small-fixes' into 'dev'
Add "inline" option to RadioSet

See merge request turris/reforis/foris-js!123
2020-08-31 18:19:12 +02:00
896277b62a Bump v5.1.1 2020-08-31 16:04:03 +02:00
b0365e3b06 NPM audit fix 2020-08-31 15:56:01 +02:00
8bd71a08af Update Snapshots 2020-08-31 15:56:01 +02:00
1903016f13 Add "inline" option to RadioSet 2020-08-31 15:56:00 +02:00
443f14d26c Add ability to select switch's form-group 2020-08-31 15:56:00 +02:00
61b349c6cc Merge branch 'fluid-aid' into 'dev'
Add auxiliary features in order to support Fluid Layout

See merge request turris/reforis/foris-js!121
2020-08-25 17:35:28 +02:00
25 changed files with 2022 additions and 2722 deletions

4485
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "foris", "name": "foris",
"version": "5.1.0", "version": "5.1.9",
"description": "Set of components and utils for Foris and its plugins.", "description": "Set of components and utils for Foris and its plugins.",
"author": "CZ.NIC, z.s.p.o.", "author": "CZ.NIC, z.s.p.o.",
"repository": { "repository": {
@ -14,11 +14,11 @@
"license": "GPL-3.0", "license": "GPL-3.0",
"main": "./src/index.js", "main": "./src/index.js",
"dependencies": { "dependencies": {
"axios": "^0.19.2", "axios": "^0.21.1",
"immutability-helper": "3.0.1", "immutability-helper": "3.0.1",
"moment": "^2.24.0", "moment": "^2.24.0",
"qrcode.react": "^0.9.3", "qrcode.react": "^0.9.3",
"react-datetime": "^2.16.3", "react-datetime": "^3.0.4",
"react-uid": "^2.2.0" "react-uid": "^2.2.0"
}, },
"peerDependencies": { "peerDependencies": {
@ -29,7 +29,7 @@
"react-router-dom": "^5.1.2" "react-router-dom": "^5.1.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.8.4", "@babel/cli": "^7.12.10",
"@babel/core": "^7.9.0", "@babel/core": "^7.9.0",
"@babel/plugin-transform-runtime": "^7.9.0", "@babel/plugin-transform-runtime": "^7.9.0",
"@babel/preset-env": "^7.9.0", "@babel/preset-env": "^7.9.0",
@ -53,10 +53,10 @@
"react": "16.9.0", "react": "16.9.0",
"react-dom": "16.9.0", "react-dom": "16.9.0",
"react-router-dom": "^5.1.2", "react-router-dom": "^5.1.2",
"react-styleguidist": "^10.6.2", "react-styleguidist": "^11.1.5",
"snapshot-diff": "^0.7.0", "snapshot-diff": "^0.7.0",
"style-loader": "^1.2.1", "style-loader": "^1.2.1",
"webpack": "^4.43.0" "webpack": "^5.15.0"
}, },
"scripts": { "scripts": {
"lint": "eslint src", "lint": "eslint src",

View File

@ -37,7 +37,11 @@ Alert.defaultProps = {
export function Alert({ type, onDismiss, children }) { export function Alert({ type, onDismiss, children }) {
return ( return (
<div className={`alert alert-dismissible alert-${type}`}> <div
className={`alert ${
onDismiss ? "alert-dismissible" : ""
} alert-${type}`}
>
{onDismiss ? ( {onDismiss ? (
<button type="button" className="close" onClick={onDismiss}> <button type="button" className="close" onClick={onDismiss}>
&times; &times;

View File

@ -7,7 +7,7 @@
import React from "react"; import React from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import Datetime from "react-datetime/DateTime"; import Datetime from "react-datetime";
import moment from "moment/moment"; import moment from "moment/moment";
import "react-datetime/css/react-datetime.css"; import "react-datetime/css/react-datetime.css";
import "./DataTimeInput.css"; import "./DataTimeInput.css";

View File

@ -1,11 +1,11 @@
/* /*
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/) * Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
* *
* This is free software, licensed under the GNU General Public License v3. * This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information. * See /LICENSE for more information.
*/ */
import React, { useRef } from "react"; import React, { useRef, useEffect } from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { Portal } from "../utils/Portal"; import { Portal } from "../utils/Portal";
@ -18,6 +18,7 @@ Modal.propTypes = {
/** Callback to manage modal visibility */ /** Callback to manage modal visibility */
setShown: PropTypes.func.isRequired, setShown: PropTypes.func.isRequired,
scrollable: PropTypes.bool, scrollable: PropTypes.bool,
size: PropTypes.string,
/** Modal content use following: `ModalHeader`, `ModalBody`, `ModalFooter` */ /** Modal content use following: `ModalHeader`, `ModalBody`, `ModalFooter` */
children: PropTypes.oneOfType([ children: PropTypes.oneOfType([
@ -26,19 +27,51 @@ Modal.propTypes = {
]).isRequired, ]).isRequired,
}; };
export function Modal({ shown, setShown, scrollable, children }) { export function Modal({ shown, setShown, scrollable, size, children }) {
const dialogRef = useRef(); const dialogRef = useRef();
let modalSize = "modal-";
useClickOutside(dialogRef, () => setShown(false)); useClickOutside(dialogRef, () => setShown(false));
useEffect(() => {
const handleEsc = (event) => {
if (event.keyCode === 27) {
setShown(false);
}
};
window.addEventListener("keydown", handleEsc);
return () => {
window.removeEventListener("keydown", handleEsc);
};
}, [setShown]);
switch (size) {
case "sm":
modalSize += "sm";
break;
case "lg":
modalSize += "lg";
break;
case "xl":
modalSize += "xl";
break;
default:
modalSize = "";
break;
}
return ( return (
<Portal containerId="modal-container"> <Portal containerId="modal-container">
<div className={`modal fade ${shown ? "show" : ""}`} role="dialog"> <div
className={`modal fade ${shown ? "show" : ""}`.trim()}
role="dialog"
>
<div <div
ref={dialogRef} ref={dialogRef}
className={`modal-dialog modal-dialog-centered${ className={`${modalSize.trim()} modal-dialog modal-dialog-centered ${
scrollable ? " modal-dialog-scrollable" : "" scrollable ? "modal-dialog-scrollable" : ""
}`} }`.trim()}
role="document" role="document"
> >
<div className="modal-content">{children}</div> <div className="modal-content">{children}</div>

View File

@ -1,8 +1,19 @@
Bootstrap modal component. Bootstrap modal component.
it's required to have an element `<div id={"modal-container"}/>` somewhere on It's required to have an element `<div id={"modal-container"}/>` somewhere on
the page since modals are rendered in portals. the page since modals are rendered in portals.
Modals also have three optional sizes, which can be defined through the `size`
prop:
- small - `sm`
- large - `lg`
- extra-large - `xl`
For more details please visit Bootstrap
<a href="https://getbootstrap.com/docs/4.5/components/modal/#optional-sizes" target="_blank">
documentation</a>.
```js ```js
<div id="modal-container" /> <div id="modal-container" />
``` ```
@ -14,7 +25,7 @@ import { useState } from "react";
const [shown, setShown] = useState(false); const [shown, setShown] = useState(false);
<> <>
<Modal setShown={setShown} shown={shown}> <Modal setShown={setShown} shown={shown} size="sm">
<ModalHeader setShown={setShown} title="Warning!" /> <ModalHeader setShown={setShown} title="Warning!" />
<ModalBody> <ModalBody>
<p>Bla bla bla...</p> <p>Bla bla bla...</p>

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/) * Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
* *
* This is free software, licensed under the GNU General Public License v3. * This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information. * See /LICENSE for more information.
@ -33,9 +33,18 @@ RadioSet.propTypes = {
value: PropTypes.string, value: PropTypes.string,
/** Help text message . */ /** Help text message . */
helpText: PropTypes.string, helpText: PropTypes.string,
inline: PropTypes.bool,
}; };
export function RadioSet({ name, label, choices, value, helpText, ...props }) { export function RadioSet({
name,
label,
choices,
value,
helpText,
inline,
...props
}) {
const uid = useUID(); const uid = useUID();
const radios = choices.map((choice, key) => { const radios = choices.map((choice, key) => {
const id = `${name}-${key}`; const id = `${name}-${key}`;
@ -48,6 +57,7 @@ export function RadioSet({ name, label, choices, value, helpText, ...props }) {
value={choice.value} value={choice.value}
helpText={choice.helpText} helpText={choice.helpText}
checked={choice.value === value} checked={choice.value === value}
inline={inline}
{...props} {...props}
/> />
); );
@ -76,15 +86,16 @@ Radio.propTypes = {
PropTypes.arrayOf(PropTypes.node), PropTypes.arrayOf(PropTypes.node),
]).isRequired, ]).isRequired,
id: PropTypes.string.isRequired, id: PropTypes.string.isRequired,
inline: PropTypes.bool,
helpText: PropTypes.string, helpText: PropTypes.string,
}; };
export function Radio({ label, id, helpText, ...props }) { export function Radio({ label, id, helpText, inline, ...props }) {
return ( return (
<> <>
<div <div
className={`custom-control custom-radio ${ className={`custom-control custom-radio ${
!helpText ? "custom-control-inline" : "" inline ? "custom-control-inline" : ""
}`.trim()} }`.trim()}
> >
<input <input

View File

@ -23,7 +23,7 @@ Switch.propTypes = {
export function Switch({ label, helpText, switchHeading, ...props }) { export function Switch({ label, helpText, switchHeading, ...props }) {
const uid = useUID(); const uid = useUID();
return ( return (
<div className="form-group"> <div className={`form-group ${switchHeading ? "switch" : ""}`.trim()}>
<div <div
className={`custom-control custom-switch ${ className={`custom-control custom-switch ${
!helpText ? "custom-control-inline" : "" !helpText ? "custom-control-inline" : ""

View File

@ -11,7 +11,7 @@ exports[`<RadioSet/> Render radio set 1`] = `
Radios set label Radios set label
</label> </label>
<div <div
class="custom-control custom-radio custom-control-inline" class="custom-control custom-radio"
> >
<input <input
checked="" checked=""
@ -29,7 +29,7 @@ exports[`<RadioSet/> Render radio set 1`] = `
</label> </label>
</div> </div>
<div <div
class="custom-control custom-radio custom-control-inline" class="custom-control custom-radio"
> >
<input <input
class="custom-control-input" class="custom-control-input"
@ -46,7 +46,7 @@ exports[`<RadioSet/> Render radio set 1`] = `
</label> </label>
</div> </div>
<div <div
class="custom-control custom-radio custom-control-inline" class="custom-control custom-radio"
> >
<input <input
class="custom-control-input" class="custom-control-input"

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/) * Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
* *
* This is free software, licensed under the GNU General Public License v3. * This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information. * See /LICENSE for more information.
@ -7,5 +7,5 @@
/** Bootstrap column size for form fields */ /** Bootstrap column size for form fields */
// eslint-disable-next-line import/prefer-default-export // eslint-disable-next-line import/prefer-default-export
export const formFieldsSize = "card p-4 col-sm-12 col-lg-12 p-0 mb-3"; export const formFieldsSize = "card p-4 col-sm-12 col-lg-12 p-0 mb-4";
export const buttonFormFieldsSize = "col-sm-12 col-lg-12 p-0 mb-3"; export const buttonFormFieldsSize = "col-sm-12 col-lg-12 p-0 mb-3";

View File

@ -63,7 +63,7 @@ RebootModal.propTypes = {
function RebootModal({ shown, setShown, onReboot }) { function RebootModal({ shown, setShown, onReboot }) {
return ( return (
<Modal shown={shown} setShown={setShown}> <Modal shown={shown} setShown={setShown}>
<ModalHeader setShown={setShown} title={_("Reboot confirmation")} /> <ModalHeader setShown={setShown} title={_("Warning!")} />
<ModalBody> <ModalBody>
<p>{_("Are you sure you want to restart the router?")}</p> <p>{_("Are you sure you want to restart the router?")}</p>
</ModalBody> </ModalBody>

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/) * Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
* *
* This is free software, licensed under the GNU General Public License v3. * This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information. * See /LICENSE for more information.
@ -13,7 +13,7 @@ import { useAlert } from "../../alertContext/AlertContext";
import { ALERT_TYPES } from "../../bootstrap/Alert"; import { ALERT_TYPES } from "../../bootstrap/Alert";
import { useAPIPost } from "../../api/hooks"; import { useAPIPost } from "../../api/hooks";
import { API_STATE } from "../../api/utils"; import { API_STATE } from "../../api/utils";
import { buttonFormFieldsSize } from "../../bootstrap/constants"; import { formFieldsSize } from "../../bootstrap/constants";
ResetWiFiSettings.propTypes = { ResetWiFiSettings.propTypes = {
ws: PropTypes.object.isRequired, ws: PropTypes.object.isRequired,
@ -51,7 +51,7 @@ export default function ResetWiFiSettings({ ws, endpoint }) {
} }
return ( return (
<> <div className={formFieldsSize}>
<h2>{_("Reset Wi-Fi Settings")}</h2> <h2>{_("Reset Wi-Fi Settings")}</h2>
<p> <p>
{_(` {_(`
@ -59,7 +59,7 @@ If a number of wireless cards doesn't match, you may try to reset the Wi-Fi sett
current Wi-Fi configuration and restore the default values. current Wi-Fi configuration and restore the default values.
`)} `)}
</p> </p>
<div className={`${buttonFormFieldsSize} text-right`}> <div className="text-right">
<Button <Button
className="btn-warning" className="btn-warning"
forisFormSize forisFormSize
@ -70,6 +70,6 @@ current Wi-Fi configuration and restore the default values.
{_("Reset Wi-Fi Settings")} {_("Reset Wi-Fi Settings")}
</Button> </Button>
</div> </div>
</> </div>
); );
} }

View File

@ -105,6 +105,7 @@ function DeviceForm({
label="SSID" label="SSID"
value={formData.SSID} value={formData.SSID}
error={formErrors.SSID || null} error={formErrors.SSID || null}
helpText={HELP_TEXTS.ssid}
required required
onChange={setFormValue((value) => ({ onChange={setFormValue((value) => ({
devices: { devices: {
@ -156,6 +157,7 @@ function DeviceForm({
choices={getHwmodeChoices(formData)} choices={getHwmodeChoices(formData)}
value={formData.hwmode} value={formData.hwmode}
helpText={HELP_TEXTS.hwmode} helpText={HELP_TEXTS.hwmode}
inline
onChange={setFormValue((value) => ({ onChange={setFormValue((value) => ({
devices: { devices: {
[deviceIndex]: { [deviceIndex]: {

View File

@ -57,6 +57,7 @@ export default function WifiGuestForm({
label="SSID" label="SSID"
value={formData.SSID} value={formData.SSID}
error={formErrors.SSID} error={formErrors.SSID}
helpText={HELP_TEXTS.ssid}
onChange={setFormValue((value) => ({ onChange={setFormValue((value) => ({
devices: { devices: {
[formData.id]: { [formData.id]: {

View File

@ -63,6 +63,12 @@ function prepDataToSubmit(formData) {
return formData; return formData;
} }
export function byteCount(string) {
const buffer = Buffer.from(string, "utf-8");
const count = buffer.byteLength;
return count;
}
export function validator(formData) { export function validator(formData) {
const formErrors = formData.devices.map((device) => { const formErrors = formData.devices.map((device) => {
if (!device.enabled) return {}; if (!device.enabled) return {};
@ -71,6 +77,8 @@ export function validator(formData) {
if (device.SSID.length > 32) if (device.SSID.length > 32)
errors.SSID = _("SSID can't be longer than 32 symbols"); errors.SSID = _("SSID can't be longer than 32 symbols");
if (device.SSID.length === 0) errors.SSID = _("SSID can't be empty"); if (device.SSID.length === 0) errors.SSID = _("SSID can't be empty");
if (byteCount(device.SSID) > 32)
errors.SSID = _("SSID can't be longer than 32 bytes");
if (device.password.length < 8) if (device.password.length < 8)
errors.password = _("Password must contain at least 8 symbols"); errors.password = _("Password must contain at least 8 symbols");
@ -82,6 +90,8 @@ export function validator(formData) {
guest_wifi_errors.SSID = _("SSID can't be longer than 32 symbols"); guest_wifi_errors.SSID = _("SSID can't be longer than 32 symbols");
if (device.guest_wifi.SSID.length === 0) if (device.guest_wifi.SSID.length === 0)
guest_wifi_errors.SSID = _("SSID can't be empty"); guest_wifi_errors.SSID = _("SSID can't be empty");
if (byteCount(device.guest_wifi.SSID) > 32)
guest_wifi_errors.SSID = _("SSID can't be longer than 32 bytes");
if (device.guest_wifi.password.length < 8) if (device.guest_wifi.password.length < 8)
guest_wifi_errors.password = _( guest_wifi_errors.password = _(

View File

@ -19,7 +19,7 @@ import {
twoDevices, twoDevices,
threeDevices, threeDevices,
} from "./__fixtures__/wifiSettings"; } from "./__fixtures__/wifiSettings";
import { WiFiSettings, validator } from "../WiFiSettings"; import { WiFiSettings, validator, byteCount } from "../WiFiSettings";
describe("<WiFiSettings/>", () => { describe("<WiFiSettings/>", () => {
let firstRender; let firstRender;
@ -213,4 +213,8 @@ describe("<WiFiSettings/>", () => {
]; ];
expect(validator(threeDevices)).toEqual(threeDevicesFormErrors); expect(validator(threeDevices)).toEqual(threeDevicesFormErrors);
}); });
it("ByteCount function", () => {
expect(byteCount("abc")).toEqual(3);
});
}); });

View File

@ -5,7 +5,7 @@ exports[`<WiFiSettings/> Snapshot 2.4 GHz 1`] = `
- First value - First value
+ Second value + Second value
@@ -245,207 +245,95 @@ @@ -250,207 +250,95 @@
value=\\"0\\" value=\\"0\\"
> >
auto auto
@ -251,11 +251,11 @@ exports[`<WiFiSettings/> Snapshot 2.4 GHz 1`] = `
exports[`<WiFiSettings/> Snapshot both modules disabled. 1`] = ` exports[`<WiFiSettings/> Snapshot both modules disabled. 1`] = `
<DocumentFragment> <DocumentFragment>
<div <div
class="card p-4 col-sm-12 col-lg-12 p-0 mb-3" class="card p-4 col-sm-12 col-lg-12 p-0 mb-4"
> >
<form> <form>
<div <div
class="form-group" class="form-group switch"
> >
<div <div
class="custom-control custom-switch custom-control-inline switch-heading" class="custom-control custom-switch custom-control-inline switch-heading"
@ -277,7 +277,7 @@ exports[`<WiFiSettings/> Snapshot both modules disabled. 1`] = `
</div> </div>
<hr /> <hr />
<div <div
class="form-group" class="form-group switch"
> >
<div <div
class="custom-control custom-switch custom-control-inline switch-heading" class="custom-control custom-switch custom-control-inline switch-heading"
@ -309,24 +309,28 @@ exports[`<WiFiSettings/> Snapshot both modules disabled. 1`] = `
</div> </div>
</form> </form>
</div> </div>
<h2> <div
Reset Wi-Fi Settings class="card p-4 col-sm-12 col-lg-12 p-0 mb-4"
</h2> >
<p> <h2>
Reset Wi-Fi Settings
</h2>
<p>
If a number of wireless cards doesn't match, you may try to reset the Wi-Fi settings. Note that this will remove the If a number of wireless cards doesn't match, you may try to reset the Wi-Fi settings. Note that this will remove the
current Wi-Fi configuration and restore the default values. current Wi-Fi configuration and restore the default values.
</p> </p>
<div <div
class="col-sm-12 col-lg-12 p-0 mb-3 text-right" class="text-right"
>
<button
class="btn btn-warning col-sm-12 col-md-3 col-lg-2"
type="button"
> >
Reset Wi-Fi Settings <button
</button> class="btn btn-warning col-sm-12 col-md-3 col-lg-2"
type="button"
>
Reset Wi-Fi Settings
</button>
</div>
</div> </div>
</DocumentFragment> </DocumentFragment>
`; `;
@ -336,7 +340,7 @@ exports[`<WiFiSettings/> Snapshot guest network. 1`] = `
- First value - First value
+ Second value + Second value
@@ -474,10 +474,89 @@ @@ -479,10 +479,94 @@
Parameters of the guest network can be set in the Guest network tab. Parameters of the guest network can be set in the Guest network tab.
</small> </small>
@ -375,6 +379,11 @@ exports[`<WiFiSettings/> Snapshot guest network. 1`] = `
+ </button> + </button>
+ </div> + </div>
+ </div> + </div>
+ <small
+ class=\\"form-text text-muted\\"
+ >
+ SSID which contains non-standard characters could cause problems on some devices.
+ </small>
+ </div> + </div>
+ <div + <div
+ class=\\"form-group\\" + class=\\"form-group\\"
@ -423,10 +432,10 @@ exports[`<WiFiSettings/> Snapshot guest network. 1`] = `
+ </div> + </div>
<hr /> <hr />
<div <div
class=\\"form-group\\" class=\\"form-group switch\\"
> >
<div <div
@@ -501,10 +580,11 @@ @@ -506,10 +590,11 @@
<div <div
class=\\"text-right\\" class=\\"text-right\\"
> >
@ -445,7 +454,7 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
- First value - First value
+ Second value + Second value
@@ -22,10 +22,462 @@ @@ -22,10 +22,467 @@
Wi-Fi 1 Wi-Fi 1
</h2> </h2>
</label> </label>
@ -485,6 +494,11 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
+ </button> + </button>
+ </div> + </div>
+ </div> + </div>
+ <small
+ class=\\"form-text text-muted\\"
+ >
+ SSID which contains non-standard characters could cause problems on some devices.
+ </small>
+ </div> + </div>
+ <div + <div
+ class=\\"form-group\\" + class=\\"form-group\\"
@ -905,7 +919,7 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
+ </div> + </div>
<hr /> <hr />
<div <div
class=\\"form-group\\" class=\\"form-group switch\\"
> >
<div" <div"
`; `;

View File

@ -19,6 +19,9 @@ export const HWMODES = {
"11a": "5", "11a": "5",
}; };
export const HELP_TEXTS = { export const HELP_TEXTS = {
ssid: _(
`SSID which contains non-standard characters could cause problems on some devices.`
),
password: _(` password: _(`
WPA2 pre-shared key, that is required to connect to the network. WPA2 pre-shared key, that is required to connect to the network.
`), `),

View File

@ -22,7 +22,7 @@ exports[`<RebootButton/> Render modal. 1`] = `
<h5 <h5
class="modal-title" class="modal-title"
> >
Reboot confirmation Warning!
</h5> </h5>
<button <button
class="close" class="close"

View File

@ -39,7 +39,6 @@ export { Modal, ModalBody, ModalFooter, ModalHeader } from "./bootstrap/Modal";
// Common // Common
export { RebootButton } from "./common/RebootButton"; export { RebootButton } from "./common/RebootButton";
export { WiFiSettings } from "./common/WiFiSettings/WiFiSettings"; export { WiFiSettings } from "./common/WiFiSettings/WiFiSettings";
// Form // Form
export { ForisForm } from "./form/components/ForisForm"; export { ForisForm } from "./form/components/ForisForm";
export { export {
@ -70,6 +69,8 @@ export {
export { ErrorMessage } from "./utils/ErrorMessage"; export { ErrorMessage } from "./utils/ErrorMessage";
export { useClickOutside } from "./utils/hooks"; export { useClickOutside } from "./utils/hooks";
export { toLocaleDateString } from "./utils/datetime"; export { toLocaleDateString } from "./utils/datetime";
export { displayCard } from "./utils/displayCard";
export { isPluginInstalled } from "./utils/isPluginInstalled";
// Foris URL // Foris URL
export { ForisURLs, REFORIS_URL_PREFIX } from "./utils/forisUrls"; export { ForisURLs, REFORIS_URL_PREFIX } from "./utils/forisUrls";

23
src/utils/displayCard.js Normal file
View File

@ -0,0 +1,23 @@
/*
* Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
*/
export function displayCard({ package_lists: packages }, cardName) {
const enabledPackagesNames = [];
packages
.filter((item) => item.enabled)
.map((item) => {
enabledPackagesNames.push(item.name);
item.options
.filter((option) => option.enabled)
.map((option) => {
enabledPackagesNames.push(option.name);
return null;
});
return null;
});
return enabledPackagesNames.includes(cardName);
}

View File

@ -20,6 +20,8 @@ export const ForisURLs = {
updates: `${REFORIS_URL_PREFIX}/package-management/updates`, updates: `${REFORIS_URL_PREFIX}/package-management/updates`,
}, },
storage: `${REFORIS_URL_PREFIX}/storage`,
// Notifications links are used with <Link/> inside Router, thus url subdir is not required. // Notifications links are used with <Link/> inside Router, thus url subdir is not required.
overview: "/overview", overview: "/overview",
notifications: "/overview#notifications", notifications: "/overview#notifications",
@ -27,7 +29,7 @@ export const ForisURLs = {
approveUpdates: "/package-management/updates", approveUpdates: "/package-management/updates",
languages: "/package-management/languages", languages: "/package-management/languages",
rebootPage: "/reforis/administration/reboot", rebootPage: "/administration/reboot",
luci: "/cgi-bin/luci", luci: "/cgi-bin/luci",
// API // API

View File

@ -0,0 +1,9 @@
/*
* Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
*/
export const isPluginInstalled = (pluginName) =>
ForisPlugins.some((plugin) => plugin.name === pluginName);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/) * Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
* *
* This is free software, licensed under the GNU General Public License v3. * This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information. * See /LICENSE for more information.
@ -12,7 +12,7 @@ import { ForisURLs } from "../utils/forisUrls";
const PROTOCOL = window.location.protocol === "http:" ? "ws" : "wss"; const PROTOCOL = window.location.protocol === "http:" ? "ws" : "wss";
const URL = process.env.LIGHTTPD const URL = process.env.LIGHTTPD
? `${PROTOCOL}://${window.location.hostname}/foris-ws` ? `${PROTOCOL}://${window.location.host}/foris-ws`
: `${PROTOCOL}://${window.location.hostname}:${9081}`; : `${PROTOCOL}://${window.location.hostname}:${9081}`;
const WAITING_FOR_CONNECTION_TIMEOUT = 500; const WAITING_FOR_CONNECTION_TIMEOUT = 500;

View File

@ -1,7 +0,0 @@
import os
for entry in os.scandir("."):
if entry.is_dir():
print(entry.name)
os.system(f"msgmerge /home/mcjlnrtwcz/Repositories/reforis/reforis/translations/{entry.name}/LC_MESSAGES/messages.po forisjs.pot -o {entry.name}/LC_MESSAGES/forisjs.po")