1
0
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 Message Date
74410b374b Bump v.5.1.2 2020-09-08 18:22:42 +02:00
12 changed files with 14 additions and 61 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "foris",
"version": "5.1.4",
"version": "5.1.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "foris",
"version": "5.1.4",
"version": "5.1.2",
"description": "Set of components and utils for Foris and its plugins.",
"author": "CZ.NIC, z.s.p.o.",
"repository": {

View File

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

View File

@ -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.
* See /LICENSE for more information.
*/
import React, { useRef, useEffect } from "react";
import React, { useRef } from "react";
import PropTypes from "prop-types";
import { Portal } from "../utils/Portal";
@ -31,19 +31,6 @@ export function Modal({ shown, setShown, scrollable, children }) {
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 (
<Portal containerId="modal-container">
<div className={`modal fade ${shown ? "show" : ""}`} role="dialog">

View File

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

View File

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

View File

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

View File

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

View File

@ -19,7 +19,7 @@ import {
twoDevices,
threeDevices,
} from "./__fixtures__/wifiSettings";
import { WiFiSettings, validator, byteCount } from "../WiFiSettings";
import { WiFiSettings, validator } from "../WiFiSettings";
describe("<WiFiSettings/>", () => {
let firstRender;
@ -213,8 +213,4 @@ describe("<WiFiSettings/>", () => {
];
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
+ Second value
@@ -250,207 +250,95 @@
@@ -245,207 +245,95 @@
value=\\"0\\"
>
auto
@ -336,7 +336,7 @@ exports[`<WiFiSettings/> Snapshot guest network. 1`] = `
- First value
+ Second value
@@ -479,10 +479,94 @@
@@ -474,10 +474,89 @@
Parameters of the guest network can be set in the Guest network tab.
</small>
@ -375,11 +375,6 @@ exports[`<WiFiSettings/> Snapshot guest network. 1`] = `
+ </button>
+ </div>
+ </div>
+ <small
+ class=\\"form-text text-muted\\"
+ >
+ SSID which contains non-standard characters could cause problems on some devices.
+ </small>
+ </div>
+ <div
+ class=\\"form-group\\"
@ -431,7 +426,7 @@ exports[`<WiFiSettings/> Snapshot guest network. 1`] = `
class=\\"form-group switch\\"
>
<div
@@ -506,10 +590,11 @@
@@ -501,10 +580,11 @@
<div
class=\\"text-right\\"
>
@ -450,7 +445,7 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
- First value
+ Second value
@@ -22,10 +22,467 @@
@@ -22,10 +22,462 @@
Wi-Fi 1
</h2>
</label>
@ -490,11 +485,6 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
+ </button>
+ </div>
+ </div>
+ <small
+ class=\\"form-text text-muted\\"
+ >
+ SSID which contains non-standard characters could cause problems on some devices.
+ </small>
+ </div>
+ <div
+ class=\\"form-group\\"
@ -570,7 +560,7 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
+ GHz
+ </label>
+ <div
+ class=\\"custom-control custom-radio custom-control-inline\\"
+ class=\\"custom-control custom-radio\\"
+ >
+ <input
+ class=\\"custom-control-input\\"
@ -587,7 +577,7 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
+ </label>
+ </div>
+ <div
+ class=\\"custom-control custom-radio custom-control-inline\\"
+ class=\\"custom-control custom-radio\\"
+ >
+ <input
+ checked=\\"\\"

View File

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

View File

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