foris 5.2.0-beta.dd383ef1 → 5.3.0-beta.92ed7f1e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/bootstrap/CopyInput.js +60 -0
  2. package/bootstrap/CopyInput.md +17 -0
  3. package/bootstrap/DownloadButton.js +7 -2
  4. package/bootstrap/Input.js +48 -40
  5. package/bootstrap/PasswordInput.js +6 -3
  6. package/bootstrap/Select.js +5 -11
  7. package/common/WiFiSettings/ResetWiFiSettings.js +4 -4
  8. package/common/WiFiSettings/WiFiForm.js +19 -12
  9. package/common/WiFiSettings/constants.js +18 -19
  10. package/foris-5.3.0.tgz +0 -0
  11. package/index.js +2 -0
  12. package/package.json +6 -6
  13. package/translations/cs/LC_MESSAGES/forisjs.po +116 -57
  14. package/translations/da/LC_MESSAGES/forisjs.po +152 -52
  15. package/translations/de/LC_MESSAGES/forisjs.po +131 -72
  16. package/translations/el/LC_MESSAGES/forisjs.po +152 -52
  17. package/translations/en/LC_MESSAGES/forisjs.po +152 -52
  18. package/translations/es/LC_MESSAGES/forisjs.po +153 -52
  19. package/translations/fi/LC_MESSAGES/forisjs.po +152 -52
  20. package/translations/fo/LC_MESSAGES/forisjs.po +152 -52
  21. package/translations/forisjs.pot +103 -54
  22. package/translations/fr/LC_MESSAGES/forisjs.po +168 -70
  23. package/translations/hr/LC_MESSAGES/forisjs.po +152 -52
  24. package/translations/hu/LC_MESSAGES/forisjs.po +153 -52
  25. package/translations/it/LC_MESSAGES/forisjs.po +152 -52
  26. package/translations/ja/LC_MESSAGES/forisjs.po +153 -52
  27. package/translations/ko/LC_MESSAGES/forisjs.po +152 -52
  28. package/translations/lt/LC_MESSAGES/forisjs.po +152 -52
  29. package/translations/nb_NO/LC_MESSAGES/forisjs.po +116 -57
  30. package/translations/nl/LC_MESSAGES/forisjs.po +154 -52
  31. package/translations/pl/LC_MESSAGES/forisjs.po +153 -52
  32. package/translations/pt_BR/LC_MESSAGES/forisjs.po +361 -0
  33. package/translations/ro/LC_MESSAGES/forisjs.po +152 -52
  34. package/translations/ru/LC_MESSAGES/forisjs.po +121 -58
  35. package/translations/sk/LC_MESSAGES/forisjs.po +123 -61
  36. package/translations/sv/LC_MESSAGES/forisjs.po +161 -54
  37. package/utils/validations.js +6 -2
  38. package/webSockets/WebSockets.js +5 -3
  39. package/foris-5.2.0.tgz +0 -0
@@ -0,0 +1,60 @@
1
+ /*
2
+ * Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
3
+ *
4
+ * This is free software, licensed under the GNU General Public License v3.
5
+ * See /LICENSE for more information.
6
+ */
7
+
8
+ import React, { useState, useRef } from "react";
9
+ import PropTypes from "prop-types";
10
+ import { Input } from "./Input";
11
+
12
+ CopyInput.propTypes = {
13
+ /** Field label. */
14
+ label: PropTypes.string.isRequired,
15
+ /** Field value. */
16
+ value: PropTypes.string,
17
+ /** Help text message. */
18
+ helpText: PropTypes.string,
19
+ /** Disable input field */
20
+ disabled: PropTypes.bool,
21
+ /** Readonly input field */
22
+ readOnly: PropTypes.bool,
23
+ };
24
+
25
+ export function CopyInput({ value, ...props }) {
26
+ const inputTextRef = useRef();
27
+ const [isCopied, setIsCopied] = useState(false);
28
+
29
+ const handleCopyClick = async () => {
30
+ // Clipboard API works only in a secure (HTTPS) context.
31
+ if (navigator.clipboard) {
32
+ await navigator.clipboard.writeText(value);
33
+ } else {
34
+ // Fallback to the "classic" copy to clipboard implementation.
35
+ inputTextRef.current.focus();
36
+ inputTextRef.current.select();
37
+ document.execCommand("copy");
38
+ inputTextRef.current.blur();
39
+ }
40
+
41
+ setIsCopied(true);
42
+ setTimeout(() => {
43
+ setIsCopied(false);
44
+ }, 1500);
45
+ };
46
+
47
+ return (
48
+ <Input type="text" value={value} ref={inputTextRef} {...props}>
49
+ <div className="input-group-append">
50
+ <button
51
+ className="btn btn-outline-secondary"
52
+ type="button"
53
+ onClick={handleCopyClick}
54
+ >
55
+ <span>{isCopied ? _("Copied!") : _("Copy")}</span>
56
+ </button>
57
+ </div>
58
+ </Input>
59
+ );
60
+ }
@@ -0,0 +1,17 @@
1
+ CopyInput Bootstrap component contains input with a label, predefined sizes, and
2
+ structure for use in ForisForm and the "Copy" button (copy to clipboard). It can
3
+ be used with `readOnly` and `disabled` parameters, please see an example.
4
+
5
+ All additional `props` are passed to the `<input type="text">` HTML component.
6
+
7
+ ```js
8
+ import React, { useState } from "react";
9
+ const [value, setValue] = useState("Text to appear in clipboard.");
10
+
11
+ <CopyInput
12
+ label="Copy me"
13
+ value={value}
14
+ helpText="Read the small text!"
15
+ readOnly
16
+ />;
17
+ ```
@@ -21,9 +21,14 @@ DownloadButton.defaultProps = {
21
21
  className: "btn-primary",
22
22
  };
23
23
 
24
- export function DownloadButton({ href, className, children }) {
24
+ export function DownloadButton({ href, className, children, ...props }) {
25
25
  return (
26
- <a href={href} className={`btn ${className}`.trim()} download>
26
+ <a
27
+ href={href}
28
+ className={`btn ${className}`.trim()}
29
+ {...props}
30
+ download
31
+ >
27
32
  {children}
28
33
  </a>
29
34
  );
@@ -1,14 +1,60 @@
1
1
  /*
2
- * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
2
+ * Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
3
3
  *
4
4
  * This is free software, licensed under the GNU General Public License v3.
5
5
  * See /LICENSE for more information.
6
6
  */
7
7
 
8
- import React from "react";
8
+ import React, { forwardRef } from "react";
9
9
  import { useUID } from "react-uid";
10
10
  import PropTypes from "prop-types";
11
11
 
12
+ /** Base bootstrap input component. */
13
+ export const Input = forwardRef(
14
+ (
15
+ {
16
+ type,
17
+ label,
18
+ helpText,
19
+ error,
20
+ className,
21
+ children,
22
+ labelClassName,
23
+ groupClassName,
24
+ ...props
25
+ },
26
+ ref
27
+ ) => {
28
+ const uid = useUID();
29
+
30
+ const inputClassName = `form-control ${className || ""} ${
31
+ error ? "is-invalid" : ""
32
+ }`.trim();
33
+
34
+ return (
35
+ <div className="form-group">
36
+ <label className={labelClassName} htmlFor={uid}>
37
+ {label}
38
+ </label>
39
+ <div className={`input-group ${groupClassName || ""}`.trim()}>
40
+ <input
41
+ className={inputClassName}
42
+ type={type}
43
+ id={uid}
44
+ ref={ref}
45
+ {...props}
46
+ />
47
+ {children}
48
+ </div>
49
+ {error ? <div className="invalid-feedback">{error}</div> : null}
50
+ {helpText ? (
51
+ <small className="form-text text-muted">{helpText}</small>
52
+ ) : null}
53
+ </div>
54
+ );
55
+ }
56
+ );
57
+
12
58
  Input.propTypes = {
13
59
  type: PropTypes.string.isRequired,
14
60
  label: PropTypes.string.isRequired,
@@ -22,41 +68,3 @@ Input.propTypes = {
22
68
  labelClassName: PropTypes.string,
23
69
  groupClassName: PropTypes.string,
24
70
  };
25
-
26
- /** Base bootstrap input component. */
27
- export function Input({
28
- type,
29
- label,
30
- helpText,
31
- error,
32
- className,
33
- children,
34
- labelClassName,
35
- groupClassName,
36
- ...props
37
- }) {
38
- const uid = useUID();
39
- const inputClassName = `form-control ${className || ""} ${
40
- error ? "is-invalid" : ""
41
- }`.trim();
42
- return (
43
- <div className="form-group">
44
- <label className={labelClassName} htmlFor={uid}>
45
- {label}
46
- </label>
47
- <div className={`input-group ${groupClassName || ""}`.trim()}>
48
- <input
49
- className={inputClassName}
50
- type={type}
51
- id={uid}
52
- {...props}
53
- />
54
- {children}
55
- </div>
56
- {error ? <div className="invalid-feedback">{error}</div> : null}
57
- {helpText ? (
58
- <small className="form-text text-muted">{helpText}</small>
59
- ) : null}
60
- </div>
61
- );
62
- }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
2
+ * Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
3
3
  *
4
4
  * This is free software, licensed under the GNU General Public License v3.
5
5
  * See /LICENSE for more information.
@@ -21,14 +21,17 @@ PasswordInput.propTypes = {
21
21
  helpText: PropTypes.string,
22
22
  /** Use show/hide password button. */
23
23
  withEye: PropTypes.bool,
24
+ /** Use new-password in autocomplete attribute. */
25
+ newPass: PropTypes.bool,
24
26
  };
25
27
 
26
- export function PasswordInput({ withEye, ...props }) {
28
+ export function PasswordInput({ withEye, newPass, ...props }) {
27
29
  const [isHidden, setHidden] = useState(true);
30
+
28
31
  return (
29
32
  <Input
30
33
  type={withEye && !isHidden ? "text" : "password"}
31
- autoComplete={isHidden ? "new-password" : null}
34
+ autoComplete={newPass ? "new-password" : "current-password"}
32
35
  {...props}
33
36
  >
34
37
  {withEye ? (
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
2
+ * Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
3
3
  *
4
4
  * This is free software, licensed under the GNU General Public License v3.
5
5
  * See /LICENSE for more information.
@@ -18,20 +18,14 @@ Select.propTypes = {
18
18
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
19
19
  /** Help text message. */
20
20
  helpText: PropTypes.string,
21
- /** Turns on/off alphabetical ordering of the Select options. */
22
- customOrder: PropTypes.bool,
23
21
  };
24
22
 
25
- export function Select({ label, choices, helpText, customOrder, ...props }) {
23
+ export function Select({ label, choices, helpText, ...props }) {
26
24
  const uid = useUID();
27
25
 
28
- const keys = Object.keys(choices);
29
- if (!customOrder) {
30
- keys.sort((a, b) => a - b || a.toString().localeCompare(b.toString()));
31
- }
32
- const options = keys.map((key) => (
33
- <option key={key} value={key}>
34
- {choices[key]}
26
+ const options = Object.keys(choices).map((choice) => (
27
+ <option key={choice} value={choice}>
28
+ {choices[choice]}
35
29
  </option>
36
30
  ));
37
31
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
2
+ * Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
3
3
  *
4
4
  * This is free software, licensed under the GNU General Public License v3.
5
5
  * See /LICENSE for more information.
@@ -54,9 +54,9 @@ export function ResetWiFiSettings({ ws, endpoint }) {
54
54
  <div className={formFieldsSize}>
55
55
  <h2>{_("Reset Wi-Fi Settings")}</h2>
56
56
  <p>
57
- {_(`If a number of wireless cards doesn't match, you may try \
58
- to reset the Wi-Fi settings. Note that this will remove the current Wi-Fi \
59
- configuration and restore the default values.`)}
57
+ {_(
58
+ "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."
59
+ )}
60
60
  </p>
61
61
  <div className="text-right">
62
62
  <Button
@@ -64,6 +64,7 @@ DeviceForm.propTypes = {
64
64
  channel: PropTypes.string.isRequired,
65
65
  guest_wifi: PropTypes.object.isRequired,
66
66
  encryption: PropTypes.string.isRequired,
67
+ available_bands: PropTypes.array.isRequired,
67
68
  }),
68
69
  formErrors: PropTypes.object.isRequired,
69
70
  setFormValue: PropTypes.func.isRequired,
@@ -87,6 +88,7 @@ function DeviceForm({
87
88
  ...props
88
89
  }) {
89
90
  const deviceID = formData.id;
91
+ const bnds = formData.available_bands;
90
92
  return (
91
93
  <>
92
94
  <Switch
@@ -159,23 +161,29 @@ function DeviceForm({
159
161
  value={formData.hwmode}
160
162
  helpText={HELP_TEXTS.hwmode}
161
163
  inline
162
- onChange={setFormValue((value) => ({
163
- devices: {
164
- [deviceIndex]: {
165
- hwmode: { $set: value },
166
- channel: { $set: "0" },
167
- htmode: {
168
- $set:
169
- value === "11a" ? "VHT80" : "HT20",
164
+ onChange={setFormValue((value) => {
165
+ // Get the last item in an array of available HT modes
166
+ const [best2] = bnds[0].available_htmodes.slice(-1);
167
+ const [best5] = bnds[1].available_htmodes.slice(-1);
168
+ return {
169
+ devices: {
170
+ [deviceIndex]: {
171
+ hwmode: { $set: value },
172
+ channel: { $set: "0" },
173
+ htmode: {
174
+ $set:
175
+ // Set HT mode depending on checked frequency
176
+ value === "11a" ? best5 : best2,
177
+ },
170
178
  },
171
179
  },
172
- },
173
- }))}
180
+ };
181
+ })}
174
182
  {...props}
175
183
  />
176
184
 
177
185
  <Select
178
- label={_("802.11n/ac mode")}
186
+ label={_("802.11n/ac/ax mode")}
179
187
  choices={getHtmodeChoices(formData)}
180
188
  value={formData.htmode}
181
189
  helpText={HELP_TEXTS.htmode}
@@ -209,7 +217,6 @@ function DeviceForm({
209
217
  [deviceIndex]: { encryption: { $set: value } },
210
218
  },
211
219
  }))}
212
- customOrder
213
220
  {...props}
214
221
  />
215
222
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
2
+ * Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
3
3
  *
4
4
  * This is free software, licensed under the GNU General Public License v3.
5
5
  * See /LICENSE for more information.
@@ -13,6 +13,10 @@ export const HTMODES = {
13
13
  VHT40: _("802.11ac - 40 MHz wide channel"),
14
14
  VHT80: _("802.11ac - 80 MHz wide channel"),
15
15
  VHT160: _("802.11ac - 160 MHz wide channel"),
16
+ HE20: _("802.11ax - 20 MHz wide channel"),
17
+ HE40: _("802.11ax - 40 MHz wide channel"),
18
+ HE80: _("802.11ax - 80 MHz wide channel"),
19
+ HE160: _("802.11ax - 160 MHz wide channel"),
16
20
  };
17
21
  export const HWMODES = {
18
22
  "11g": "2.4",
@@ -25,28 +29,23 @@ export const ENCRYPTIONMODES = {
25
29
  };
26
30
  export const HELP_TEXTS = {
27
31
  ssid: _(
28
- `SSID which contains non-standard characters could cause problems on some devices.`
32
+ "SSID which contains non-standard characters could cause problems on some devices."
33
+ ),
34
+ password: _(
35
+ "WPA2 pre-shared key, that is required to connect to the network."
29
36
  ),
30
- password: _(`
31
- WPA2 pre-shared key, that is required to connect to the network.
32
- `),
33
37
  hidden: _(
34
38
  "If set, network is not visible when scanning for available networks."
35
39
  ),
36
- hwmode: _(`
37
- The 2.4 GHz band is more widely supported by clients, but tends to have more interference. The 5 GHz band is a
38
- newer standard and may not be supported by all your devices. It usually has less interference, but the signal
39
- does not carry so well indoors.`),
40
- htmode: _(`
41
- Change this to adjust 802.11n/ac mode of operation. 802.11n with 40 MHz wide channels can yield higher
42
- throughput but can cause more interference in the network. If you don't know what to choose, use the default
43
- option with 20 MHz wide channel.
44
- `),
45
- guest_wifi_enabled: _(`
46
- Enables Wi-Fi for guests, which is separated from LAN network. Devices connected to this network are allowed to
47
- access the internet, but aren't allowed to access other devices and the configuration interface of the router.
48
- Parameters of the guest network can be set in the Guest network tab.
49
- `),
40
+ hwmode: _(
41
+ "The 2.4 GHz band is more widely supported by clients, but tends to have more interference. The 5 GHz band is a newer standard and may not be supported by all your devices. It usually has less interference, but the signal does not carry so well indoors."
42
+ ),
43
+ htmode: _(
44
+ "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."
45
+ ),
46
+ guest_wifi_enabled: _(
47
+ "Enables Wi-Fi for guests, which is separated from LAN network. Devices connected to this network are allowed to access the internet, but aren't allowed to access other devices and the configuration interface of the router. Parameters of the guest network can be set in the Guest network tab."
48
+ ),
50
49
  wpa3: _(
51
50
  "The WPA3 standard is the new most secure encryption method that is suggested to be used with any device that supports it. The older devices without WPA3 support require older WPA2. If you experience issues with connecting older devices, try to enable WPA2."
52
51
  ),
Binary file
package/index.js CHANGED
@@ -20,6 +20,7 @@ export { API_STATE } from "./api/utils";
20
20
  export { Alert, ALERT_TYPES } from "./bootstrap/Alert";
21
21
  export { Button } from "./bootstrap/Button";
22
22
  export { CheckBox } from "./bootstrap/CheckBox";
23
+ export { CopyInput } from "./bootstrap/CopyInput";
23
24
  export { DownloadButton } from "./bootstrap/DownloadButton";
24
25
  export { DataTimeInput } from "./bootstrap/DataTimeInput";
25
26
  export { EmailInput } from "./bootstrap/EmailInput";
@@ -82,6 +83,7 @@ export {
82
83
  validateIPv6Address,
83
84
  validateIPv6Prefix,
84
85
  validateDomain,
86
+ validateHostname,
85
87
  validateDUID,
86
88
  validateMAC,
87
89
  validateMultipleEmails,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foris",
3
- "version": "5.2.0-beta.dd383ef1",
3
+ "version": "5.3.0-beta.92ed7f1e",
4
4
  "description": "Set of components and utils for Foris and its plugins.",
5
5
  "author": "CZ.NIC, z.s.p.o.",
6
6
  "repository": {
@@ -17,8 +17,8 @@
17
17
  "axios": "^0.21.1",
18
18
  "immutability-helper": "3.0.1",
19
19
  "moment": "^2.24.0",
20
- "qrcode.react": "^0.9.3",
21
- "react-datetime": "^3.0.4",
20
+ "qrcode.react": "^1.0.1",
21
+ "react-datetime": "^3.1.1",
22
22
  "react-uid": "^2.2.0"
23
23
  },
24
24
  "peerDependencies": {
@@ -47,16 +47,16 @@
47
47
  "file-loader": "^6.0.0",
48
48
  "jest": "^25.2.0",
49
49
  "jest-mock-axios": "^3.2.0",
50
- "moment-timezone": "^0.5.28",
50
+ "moment-timezone": "^0.5.34",
51
51
  "prettier": "2.0.5",
52
52
  "prop-types": "15.7.2",
53
53
  "react": "16.9.0",
54
54
  "react-dom": "16.9.0",
55
55
  "react-router-dom": "^5.1.2",
56
- "react-styleguidist": "^7.3.11",
56
+ "react-styleguidist": "^11.2.0",
57
57
  "snapshot-diff": "^0.7.0",
58
58
  "style-loader": "^1.2.1",
59
- "webpack": "^5.15.0"
59
+ "webpack": "^5.68.0"
60
60
  },
61
61
  "scripts": {
62
62
  "lint": "eslint src",