mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2025-06-16 13:46:16 +02:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
74410b374b |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "foris",
|
"name": "foris",
|
||||||
"version": "5.1.4",
|
"version": "5.1.2",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "foris",
|
"name": "foris",
|
||||||
"version": "5.1.4",
|
"version": "5.1.2",
|
||||||
"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": {
|
||||||
|
@ -37,11 +37,7 @@ Alert.defaultProps = {
|
|||||||
|
|
||||||
export function Alert({ type, onDismiss, children }) {
|
export function Alert({ type, onDismiss, children }) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div className={`alert alert-dismissible alert-${type}`}>
|
||||||
className={`alert ${
|
|
||||||
onDismiss ? "alert-dismissible" : ""
|
|
||||||
} alert-${type}`}
|
|
||||||
>
|
|
||||||
{onDismiss ? (
|
{onDismiss ? (
|
||||||
<button type="button" className="close" onClick={onDismiss}>
|
<button type="button" className="close" onClick={onDismiss}>
|
||||||
×
|
×
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
* Copyright (C) 2019 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, useEffect } from "react";
|
import React, { useRef } from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
import { Portal } from "../utils/Portal";
|
import { Portal } from "../utils/Portal";
|
||||||
@ -31,19 +31,6 @@ export function Modal({ shown, setShown, scrollable, children }) {
|
|||||||
|
|
||||||
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]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Portal containerId="modal-container">
|
<Portal containerId="modal-container">
|
||||||
<div className={`modal fade ${shown ? "show" : ""}`} role="dialog">
|
<div className={`modal fade ${shown ? "show" : ""}`} role="dialog">
|
||||||
|
@ -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={_("Warning!")} />
|
<ModalHeader setShown={setShown} title={_("Reboot confirmation")} />
|
||||||
<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>
|
||||||
|
@ -105,7 +105,6 @@ 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: {
|
||||||
@ -157,7 +156,6 @@ 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]: {
|
||||||
|
@ -57,7 +57,6 @@ 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]: {
|
||||||
|
@ -63,12 +63,6 @@ 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 {};
|
||||||
@ -77,8 +71,6 @@ 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");
|
||||||
@ -90,8 +82,6 @@ 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 = _(
|
||||||
|
@ -19,7 +19,7 @@ import {
|
|||||||
twoDevices,
|
twoDevices,
|
||||||
threeDevices,
|
threeDevices,
|
||||||
} from "./__fixtures__/wifiSettings";
|
} from "./__fixtures__/wifiSettings";
|
||||||
import { WiFiSettings, validator, byteCount } from "../WiFiSettings";
|
import { WiFiSettings, validator } from "../WiFiSettings";
|
||||||
|
|
||||||
describe("<WiFiSettings/>", () => {
|
describe("<WiFiSettings/>", () => {
|
||||||
let firstRender;
|
let firstRender;
|
||||||
@ -213,8 +213,4 @@ describe("<WiFiSettings/>", () => {
|
|||||||
];
|
];
|
||||||
expect(validator(threeDevices)).toEqual(threeDevicesFormErrors);
|
expect(validator(threeDevices)).toEqual(threeDevicesFormErrors);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("ByteCount function", () => {
|
|
||||||
expect(byteCount("abc")).toEqual(3);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -5,7 +5,7 @@ exports[`<WiFiSettings/> Snapshot 2.4 GHz 1`] = `
|
|||||||
- First value
|
- First value
|
||||||
+ Second value
|
+ Second value
|
||||||
|
|
||||||
@@ -250,207 +250,95 @@
|
@@ -245,207 +245,95 @@
|
||||||
value=\\"0\\"
|
value=\\"0\\"
|
||||||
>
|
>
|
||||||
auto
|
auto
|
||||||
@ -336,7 +336,7 @@ exports[`<WiFiSettings/> Snapshot guest network. 1`] = `
|
|||||||
- First value
|
- First value
|
||||||
+ Second value
|
+ Second value
|
||||||
|
|
||||||
@@ -479,10 +479,94 @@
|
@@ -474,10 +474,89 @@
|
||||||
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,11 +375,6 @@ 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\\"
|
||||||
@ -431,7 +426,7 @@ exports[`<WiFiSettings/> Snapshot guest network. 1`] = `
|
|||||||
class=\\"form-group switch\\"
|
class=\\"form-group switch\\"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@@ -506,10 +590,11 @@
|
@@ -501,10 +580,11 @@
|
||||||
<div
|
<div
|
||||||
class=\\"text-right\\"
|
class=\\"text-right\\"
|
||||||
>
|
>
|
||||||
@ -450,7 +445,7 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
|
|||||||
- First value
|
- First value
|
||||||
+ Second value
|
+ Second value
|
||||||
|
|
||||||
@@ -22,10 +22,467 @@
|
@@ -22,10 +22,462 @@
|
||||||
Wi-Fi 1
|
Wi-Fi 1
|
||||||
</h2>
|
</h2>
|
||||||
</label>
|
</label>
|
||||||
@ -490,11 +485,6 @@ 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\\"
|
||||||
@ -570,7 +560,7 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
|
|||||||
+ GHz
|
+ GHz
|
||||||
+ </label>
|
+ </label>
|
||||||
+ <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\\"
|
||||||
@ -587,7 +577,7 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
|
|||||||
+ </label>
|
+ </label>
|
||||||
+ </div>
|
+ </div>
|
||||||
+ <div
|
+ <div
|
||||||
+ class=\\"custom-control custom-radio custom-control-inline\\"
|
+ class=\\"custom-control custom-radio\\"
|
||||||
+ >
|
+ >
|
||||||
+ <input
|
+ <input
|
||||||
+ checked=\\"\\"
|
+ checked=\\"\\"
|
||||||
|
@ -19,9 +19,6 @@ 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.
|
||||||
`),
|
`),
|
||||||
|
@ -22,7 +22,7 @@ exports[`<RebootButton/> Render modal. 1`] = `
|
|||||||
<h5
|
<h5
|
||||||
class="modal-title"
|
class="modal-title"
|
||||||
>
|
>
|
||||||
Warning!
|
Reboot confirmation
|
||||||
</h5>
|
</h5>
|
||||||
<button
|
<button
|
||||||
class="close"
|
class="close"
|
||||||
|
Reference in New Issue
Block a user