foris 6.11.1 → 6.11.2-beta.187b6872

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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
2
+ * Copyright (C) 2019-2026 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.
@@ -9,7 +9,10 @@ import React from "react";
9
9
 
10
10
  import PropTypes from "prop-types";
11
11
 
12
- import { HELP_TEXTS, HTMODES, BANDS, ENCRYPTIONMODES } from "./constants";
12
+ import { HELP_TEXTS, HTMODES, BANDS } from "./constants";
13
+ import getEncryptionChoices, {
14
+ getSupportedEncryption,
15
+ } from "./encryptionHelpers";
13
16
  import WifiGuestForm from "./WiFiGuestForm";
14
17
  import WiFiQRCode from "./WiFiQRCode";
15
18
  import PasswordInput from "../../bootstrap/PasswordInput";
@@ -170,15 +173,27 @@ function DeviceForm({
170
173
  // Get the last item in the available HT modes for the selected band
171
174
  const bestHtmode =
172
175
  selectedBand.available_htmodes.slice(-1)[0];
176
+ // The band limits the encryption, both for the
177
+ // main and for the guest network
173
178
  const deviceUpdate = {
174
179
  band: { $set: value },
175
180
  channel: { $set: "0" },
176
181
  htmode: { $set: bestHtmode },
182
+ encryption: {
183
+ $set: getSupportedEncryption(
184
+ value,
185
+ formData.encryption
186
+ ),
187
+ },
188
+ guest_wifi: {
189
+ encryption: {
190
+ $set: getSupportedEncryption(
191
+ value,
192
+ formData.guest_wifi.encryption
193
+ ),
194
+ },
195
+ },
177
196
  };
178
- // The 6 GHz band supports only WPA3
179
- if (value === "6g") {
180
- deviceUpdate.encryption = { $set: "WPA3" };
181
- }
182
197
  return {
183
198
  devices: {
184
199
  [deviceIndex]: deviceUpdate,
@@ -215,7 +230,10 @@ function DeviceForm({
215
230
 
216
231
  <Select
217
232
  label={_("Encryption")}
218
- choices={getEncryptionChoices(formData)}
233
+ choices={getEncryptionChoices(
234
+ formData.band,
235
+ formData.encryption
236
+ )}
219
237
  helpText={HELP_TEXTS.wpa3}
220
238
  value={formData.encryption}
221
239
  onChange={setFormValue((value) => ({
@@ -255,6 +273,7 @@ function DeviceForm({
255
273
  ...formData.guest_wifi,
256
274
  }}
257
275
  formErrors={formErrors.guest_wifi || {}}
276
+ band={formData.band}
258
277
  setFormValue={setFormValue}
259
278
  {...props}
260
279
  />
@@ -306,15 +325,3 @@ function getBandChoices(device) {
306
325
  value: availableBand.band,
307
326
  }));
308
327
  }
309
-
310
- function getEncryptionChoices(device) {
311
- if (device.encryption === "custom") {
312
- ENCRYPTIONMODES.custom = _("Custom");
313
- }
314
- if (device.band === "6g") {
315
- return {
316
- WPA3: ENCRYPTIONMODES.WPA3,
317
- };
318
- }
319
- return ENCRYPTIONMODES;
320
- }
@@ -9,7 +9,8 @@ import React from "react";
9
9
 
10
10
  import PropTypes from "prop-types";
11
11
 
12
- import { HELP_TEXTS, ENCRYPTIONMODES } from "./constants";
12
+ import { HELP_TEXTS } from "./constants";
13
+ import getEncryptionChoices from "./encryptionHelpers";
13
14
  import WiFiQRCode from "./WiFiQRCode";
14
15
  import PasswordInput from "../../bootstrap/PasswordInput";
15
16
  import Select from "../../bootstrap/Select";
@@ -30,6 +31,8 @@ WifiGuestForm.propTypes = {
30
31
  }),
31
32
  setFormValue: PropTypes.func.isRequired,
32
33
  deviceIndex: PropTypes.string,
34
+ /** Band of the device the guest network shares the radio with. */
35
+ band: PropTypes.string,
33
36
  };
34
37
 
35
38
  export default function WifiGuestForm({
@@ -37,6 +40,7 @@ export default function WifiGuestForm({
37
40
  formErrors,
38
41
  setFormValue,
39
42
  deviceIndex,
43
+ band,
40
44
  ...props
41
45
  }) {
42
46
  return (
@@ -93,7 +97,10 @@ export default function WifiGuestForm({
93
97
  />
94
98
  <Select
95
99
  label={_("Encryption")}
96
- choices={ENCRYPTIONMODES}
100
+ choices={getEncryptionChoices(
101
+ band,
102
+ formData.encryption
103
+ )}
97
104
  helpText={HELP_TEXTS.wpa3}
98
105
  value={formData.encryption}
99
106
  onChange={setFormValue((value) => ({
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
2
+ * Copyright (C) 2019-2026 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.
@@ -9,6 +9,7 @@ import React from "react";
9
9
 
10
10
  import PropTypes from "prop-types";
11
11
 
12
+ import { getSupportedEncryption } from "./encryptionHelpers";
12
13
  import ResetWiFiSettings from "./ResetWiFiSettings";
13
14
  import WiFiForm from "./WiFiForm";
14
15
  import ForisForm from "../../form/components/ForisForm";
@@ -43,6 +44,20 @@ function WiFiSettings({ ws, endpoint, resetEndpoint, hasGuestNetwork }) {
43
44
  function prepData(formData) {
44
45
  formData.devices.forEach((device, idx) => {
45
46
  formData.devices[idx].channel = device.channel.toString();
47
+
48
+ // A device can be delivered by the API on a band which doesn't
49
+ // support its encryption (e.g. WPA2/3 on 6 GHz). Such a value is not
50
+ // among the choices of the select, so the select falls back to
51
+ // displaying its first choice while the form keeps (and submits) the
52
+ // unsupported one.
53
+ formData.devices[idx].encryption = getSupportedEncryption(
54
+ device.band,
55
+ device.encryption
56
+ );
57
+ formData.devices[idx].guest_wifi.encryption = getSupportedEncryption(
58
+ device.band,
59
+ device.guest_wifi.encryption
60
+ );
46
61
  });
47
62
  return formData;
48
63
  }
@@ -58,8 +73,20 @@ function prepDataToSubmit(formData) {
58
73
  return;
59
74
  }
60
75
 
61
- if (!device.guest_wifi.enabled)
76
+ if (!device.guest_wifi.enabled) {
62
77
  formData.devices[idx].guest_wifi = { enabled: false };
78
+ } else {
79
+ formData.devices[idx].guest_wifi.encryption =
80
+ getSupportedEncryption(
81
+ device.band,
82
+ device.guest_wifi.encryption
83
+ );
84
+ }
85
+
86
+ formData.devices[idx].encryption = getSupportedEncryption(
87
+ device.band,
88
+ device.encryption
89
+ );
63
90
 
64
91
  if (device.encryption === "WPA2") {
65
92
  delete formData.devices[idx].ieee80211w_disabled;
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Copyright (C) 2019-2026 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 { ENCRYPTIONMODES } from "./constants";
9
+
10
+ // Both the main and the guest network run on the same radio, so the band
11
+ // limits the encryption choices of both of them. A custom encryption comes
12
+ // from a hand-made configuration, it's offered on any band to keep the form
13
+ // from rewriting it.
14
+ export default function getEncryptionChoices(band, encryption) {
15
+ const customChoice = encryption === "custom" ? { custom: _("Custom") } : {};
16
+ if (band === "6g") {
17
+ return { WPA3: ENCRYPTIONMODES.WPA3, ...customChoice };
18
+ }
19
+ return { ...ENCRYPTIONMODES, ...customChoice };
20
+ }
21
+
22
+ // Encryption the band actually supports. Filtering the choices only hides the
23
+ // unsupported ones from the select, the value itself has to follow the band as
24
+ // well, otherwise the select displays its single WPA3 choice while the form
25
+ // still holds (and submits) e.g. WPA2/3.
26
+ export function getSupportedEncryption(band, encryption) {
27
+ if (band === "6g" && encryption !== "custom") {
28
+ return "WPA3";
29
+ }
30
+ return encryption;
31
+ }
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foris",
3
- "version": "6.11.1",
3
+ "version": "6.11.2-beta.187b6872",
4
4
  "description": "Foris JS library is a set of components and utils for reForis application and plugins.",
5
5
  "author": "CZ.NIC, z.s.p.o.",
6
6
  "repository": {
package/foris-6.11.1.tgz DELETED
Binary file