foris 5.6.1 → 6.0.0
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.
- package/api/hooks.js +11 -3
- package/bootstrap/Alert.js +14 -10
- package/bootstrap/Button.js +7 -10
- package/bootstrap/CheckBox.js +22 -20
- package/bootstrap/CopyInput.js +7 -3
- package/bootstrap/DataTimeInput.js +9 -6
- package/bootstrap/DownloadButton.js +5 -2
- package/bootstrap/EmailInput.js +7 -2
- package/bootstrap/FileInput.js +6 -3
- package/bootstrap/Input.js +20 -10
- package/bootstrap/Modal.js +6 -6
- package/bootstrap/NumberInput.js +28 -25
- package/bootstrap/PasswordInput.js +20 -21
- package/bootstrap/RadioSet.js +26 -33
- package/bootstrap/Select.js +15 -8
- package/bootstrap/Spinner.css +10 -4
- package/bootstrap/Spinner.js +2 -1
- package/bootstrap/Switch.js +26 -23
- package/bootstrap/TextInput.js +8 -3
- package/bootstrap/constants.js +5 -4
- package/common/RebootButton.js +9 -7
- package/common/WiFiSettings/ResetWiFiSettings.js +11 -8
- package/common/WiFiSettings/WiFiForm.js +16 -16
- package/common/WiFiSettings/WiFiGuestForm.js +6 -5
- package/common/WiFiSettings/WiFiQRCode.js +6 -5
- package/common/WiFiSettings/WiFiSettings.js +7 -4
- package/context/alertContext/AlertContext.js +10 -5
- package/context/customizationContext/CustomizationContext.js +24 -13
- package/foris-6.0.0.tgz +0 -0
- package/form/components/ForisForm.js +16 -14
- package/form/components/SubmitButton.js +2 -1
- package/form/hooks.js +3 -2
- package/index.js +27 -27
- package/package.json +25 -26
- package/utils/ErrorMessage.js +5 -2
- package/utils/Portal.js +10 -2
- package/utils/conditionalHOCs.js +14 -7
- package/utils/datetime.js +3 -4
- package/utils/displayCard.js +4 -2
- package/utils/hooks.js +1 -1
- package/utils/isPluginInstalled.js +4 -2
- package/utils/validations.js +6 -3
- package/webSockets/WebSockets.js +4 -4
- package/webSockets/hooks.js +5 -2
- package/foris-5.6.1.tgz +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2019-
|
|
2
|
+
* Copyright (C) 2019-2024 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, { useContext, useEffect } from "react";
|
|
8
|
+
import React, { useContext, useEffect, useMemo } from "react";
|
|
9
|
+
|
|
9
10
|
import PropTypes from "prop-types";
|
|
10
11
|
|
|
11
12
|
import { useAPIGet } from "../../api/hooks";
|
|
12
|
-
import { ForisURLs } from "../../utils/forisUrls";
|
|
13
|
-
|
|
14
13
|
import { Spinner } from "../../bootstrap/Spinner";
|
|
14
|
+
import { ForisURLs } from "../../utils/forisUrls";
|
|
15
15
|
|
|
16
16
|
CustomizationContextProvider.propTypes = {
|
|
17
17
|
children: PropTypes.oneOfType([
|
|
@@ -30,20 +30,31 @@ function CustomizationContextProvider({ children }) {
|
|
|
30
30
|
getCustomization();
|
|
31
31
|
}, [getCustomization]);
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const deviceDetails = useMemo(
|
|
34
|
+
() => getCustomizationResponse.data || {},
|
|
35
|
+
[getCustomizationResponse.data]
|
|
36
|
+
);
|
|
36
37
|
|
|
37
|
-
const
|
|
38
|
+
const isCustomized = useMemo(
|
|
39
|
+
() =>
|
|
40
|
+
!!(
|
|
41
|
+
deviceDetails.customization !== undefined &&
|
|
42
|
+
deviceDetails.customization === "shield"
|
|
43
|
+
),
|
|
44
|
+
[deviceDetails.customization]
|
|
45
|
+
);
|
|
38
46
|
|
|
39
|
-
const
|
|
40
|
-
deviceDetails
|
|
41
|
-
deviceDetails
|
|
42
|
-
deviceDetails.customization === "shield"
|
|
47
|
+
const contextValue = useMemo(
|
|
48
|
+
() => ({ deviceDetails, isCustomized }),
|
|
49
|
+
[deviceDetails, isCustomized]
|
|
43
50
|
);
|
|
44
51
|
|
|
52
|
+
if (getCustomizationResponse.state !== "success") {
|
|
53
|
+
return <Spinner fullScreen />;
|
|
54
|
+
}
|
|
55
|
+
|
|
45
56
|
return (
|
|
46
|
-
<CustomizationContext.Provider value={
|
|
57
|
+
<CustomizationContext.Provider value={contextValue}>
|
|
47
58
|
{children}
|
|
48
59
|
</CustomizationContext.Provider>
|
|
49
60
|
);
|
package/foris-6.0.0.tgz
ADDED
|
Binary file
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2019 CZ.NIC z.s.p.o. (
|
|
2
|
+
* Copyright (C) 2019-2024 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
8
|
import React, { useEffect } from "react";
|
|
9
|
+
|
|
9
10
|
import PropTypes from "prop-types";
|
|
10
11
|
import { Prompt } from "react-router-dom";
|
|
11
12
|
|
|
12
|
-
import {
|
|
13
|
+
import { STATES as SUBMIT_BUTTON_STATES, SubmitButton } from "./SubmitButton";
|
|
14
|
+
import { useAPIPost } from "../../api/hooks";
|
|
13
15
|
import { API_STATE } from "../../api/utils";
|
|
16
|
+
import { ALERT_TYPES } from "../../bootstrap/Alert";
|
|
14
17
|
import { formFieldsSize } from "../../bootstrap/constants";
|
|
15
18
|
import { Spinner } from "../../bootstrap/Spinner";
|
|
16
19
|
import { useAlert } from "../../context/alertContext/AlertContext";
|
|
17
|
-
import
|
|
18
|
-
|
|
20
|
+
import ErrorMessage from "../../utils/ErrorMessage";
|
|
19
21
|
import { useForisModule, useForm } from "../hooks";
|
|
20
|
-
import { STATES as SUBMIT_BUTTON_STATES, SubmitButton } from "./SubmitButton";
|
|
21
|
-
import { ErrorMessage } from "../../utils/ErrorMessage";
|
|
22
22
|
|
|
23
23
|
ForisForm.propTypes = {
|
|
24
24
|
/** Optional WebSocket object. See `scr/common/WebSockets.js`.
|
|
@@ -89,7 +89,7 @@ ForisForm.defaultProps = {
|
|
|
89
89
|
* use exposed `ReactRouterDOM` object from `react-router-dom` library which is exposed by reForis.
|
|
90
90
|
* See README for more information.
|
|
91
91
|
* */
|
|
92
|
-
|
|
92
|
+
function ForisForm({
|
|
93
93
|
ws,
|
|
94
94
|
forisConfig,
|
|
95
95
|
prepData,
|
|
@@ -131,16 +131,16 @@ export function ForisForm({
|
|
|
131
131
|
return <Spinner />;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
const onSubmitHandler = (event) => {
|
|
135
135
|
event.preventDefault();
|
|
136
136
|
resetFormData();
|
|
137
137
|
dismissAlert();
|
|
138
138
|
const copiedFormData = JSON.parse(JSON.stringify(formState.data));
|
|
139
139
|
const preparedData = prepDataToSubmit(copiedFormData);
|
|
140
140
|
post({ data: preparedData });
|
|
141
|
-
}
|
|
141
|
+
};
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
const getSubmitButtonState = () => {
|
|
144
144
|
if (postState.state === API_STATE.SENDING) {
|
|
145
145
|
return SUBMIT_BUTTON_STATES.SAVING;
|
|
146
146
|
}
|
|
@@ -148,7 +148,7 @@ export function ForisForm({
|
|
|
148
148
|
return SUBMIT_BUTTON_STATES.LOAD;
|
|
149
149
|
}
|
|
150
150
|
return SUBMIT_BUTTON_STATES.READY;
|
|
151
|
-
}
|
|
151
|
+
};
|
|
152
152
|
|
|
153
153
|
const formIsDisabled =
|
|
154
154
|
disabled ||
|
|
@@ -174,7 +174,7 @@ export function ForisForm({
|
|
|
174
174
|
)
|
|
175
175
|
: onSubmitHandler;
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
const getMessageOnLeavingPage = () => {
|
|
178
178
|
if (
|
|
179
179
|
JSON.stringify(formState.data) ===
|
|
180
180
|
JSON.stringify(formState.initialData)
|
|
@@ -183,14 +183,14 @@ export function ForisForm({
|
|
|
183
183
|
return _(
|
|
184
184
|
"Changes you made may not be saved. Are you sure you want to leave?"
|
|
185
185
|
);
|
|
186
|
-
}
|
|
186
|
+
};
|
|
187
187
|
|
|
188
188
|
return (
|
|
189
189
|
<div className={formFieldsSize}>
|
|
190
190
|
<Prompt message={getMessageOnLeavingPage} />
|
|
191
191
|
<form onSubmit={onSubmit} ref={formReference}>
|
|
192
192
|
{childrenWithFormProps}
|
|
193
|
-
<div className="text-
|
|
193
|
+
<div className="text-end">
|
|
194
194
|
<SubmitButton
|
|
195
195
|
state={getSubmitButtonState()}
|
|
196
196
|
disabled={submitButtonIsDisabled}
|
|
@@ -200,3 +200,5 @@ export function ForisForm({
|
|
|
200
200
|
</div>
|
|
201
201
|
);
|
|
202
202
|
}
|
|
203
|
+
|
|
204
|
+
export default ForisForm;
|
package/form/hooks.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2019 CZ.NIC z.s.p.o. (
|
|
2
|
+
* Copyright (C) 2019-2024 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
8
|
import { useCallback, useEffect, useReducer } from "react";
|
|
9
|
+
|
|
9
10
|
import update from "immutability-helper";
|
|
10
11
|
|
|
11
12
|
import { useAPIGet } from "../api/hooks";
|
|
12
|
-
import
|
|
13
|
+
import useWSForisModule from "../webSockets/hooks";
|
|
13
14
|
|
|
14
15
|
const FORM_ACTIONS = {
|
|
15
16
|
updateValue: 1,
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2019-
|
|
2
|
+
* Copyright (C) 2019-2024 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.
|
|
@@ -17,32 +17,32 @@ export {
|
|
|
17
17
|
export { API_STATE } from "./api/utils";
|
|
18
18
|
|
|
19
19
|
// Bootstrap
|
|
20
|
-
export { Alert, ALERT_TYPES } from "./bootstrap/Alert";
|
|
21
|
-
export { Button } from "./bootstrap/Button";
|
|
22
|
-
export { CheckBox } from "./bootstrap/CheckBox";
|
|
23
|
-
export { CopyInput } from "./bootstrap/CopyInput";
|
|
24
|
-
export { DownloadButton } from "./bootstrap/DownloadButton";
|
|
25
|
-
export { DataTimeInput } from "./bootstrap/DataTimeInput";
|
|
26
|
-
export { EmailInput } from "./bootstrap/EmailInput";
|
|
27
|
-
export { FileInput } from "./bootstrap/FileInput";
|
|
28
|
-
export { Input } from "./bootstrap/Input";
|
|
29
|
-
export { NumberInput } from "./bootstrap/NumberInput";
|
|
30
|
-
export { PasswordInput } from "./bootstrap/PasswordInput";
|
|
31
|
-
export {
|
|
32
|
-
export { Select } from "./bootstrap/Select";
|
|
33
|
-
export { TextInput } from "./bootstrap/TextInput";
|
|
20
|
+
export { default as Alert, ALERT_TYPES } from "./bootstrap/Alert";
|
|
21
|
+
export { default as Button } from "./bootstrap/Button";
|
|
22
|
+
export { default as CheckBox } from "./bootstrap/CheckBox";
|
|
23
|
+
export { default as CopyInput } from "./bootstrap/CopyInput";
|
|
24
|
+
export { default as DownloadButton } from "./bootstrap/DownloadButton";
|
|
25
|
+
export { default as DataTimeInput } from "./bootstrap/DataTimeInput";
|
|
26
|
+
export { default as EmailInput } from "./bootstrap/EmailInput";
|
|
27
|
+
export { default as FileInput } from "./bootstrap/FileInput";
|
|
28
|
+
export { default as Input } from "./bootstrap/Input";
|
|
29
|
+
export { default as NumberInput } from "./bootstrap/NumberInput";
|
|
30
|
+
export { default as PasswordInput } from "./bootstrap/PasswordInput";
|
|
31
|
+
export { default as RadioSet, Radio } from "./bootstrap/RadioSet";
|
|
32
|
+
export { default as Select } from "./bootstrap/Select";
|
|
33
|
+
export { default as TextInput } from "./bootstrap/TextInput";
|
|
34
34
|
export { formFieldsSize, buttonFormFieldsSize } from "./bootstrap/constants";
|
|
35
|
-
export { Switch } from "./bootstrap/Switch";
|
|
35
|
+
export { default as Switch } from "./bootstrap/Switch";
|
|
36
36
|
|
|
37
37
|
export { Spinner, SpinnerElement } from "./bootstrap/Spinner";
|
|
38
38
|
export { Modal, ModalBody, ModalFooter, ModalHeader } from "./bootstrap/Modal";
|
|
39
39
|
|
|
40
40
|
// Common
|
|
41
|
-
export { RebootButton } from "./common/RebootButton";
|
|
42
|
-
export { WiFiSettings } from "./common/WiFiSettings/WiFiSettings";
|
|
43
|
-
export { ResetWiFiSettings } from "./common/WiFiSettings/ResetWiFiSettings";
|
|
41
|
+
export { default as RebootButton } from "./common/RebootButton";
|
|
42
|
+
export { default as WiFiSettings } from "./common/WiFiSettings/WiFiSettings";
|
|
43
|
+
export { default as ResetWiFiSettings } from "./common/WiFiSettings/ResetWiFiSettings";
|
|
44
44
|
// Form
|
|
45
|
-
export { ForisForm } from "./form/components/ForisForm";
|
|
45
|
+
export { default as ForisForm } from "./form/components/ForisForm";
|
|
46
46
|
export {
|
|
47
47
|
SubmitButton,
|
|
48
48
|
STATES as SUBMIT_BUTTON_STATES,
|
|
@@ -50,11 +50,11 @@ export {
|
|
|
50
50
|
export { useForisModule, useForm } from "./form/hooks";
|
|
51
51
|
|
|
52
52
|
// WebSockets
|
|
53
|
-
export { useWSForisModule } from "./webSockets/hooks";
|
|
54
|
-
export { WebSockets } from "./webSockets/WebSockets";
|
|
53
|
+
export { default as useWSForisModule } from "./webSockets/hooks";
|
|
54
|
+
export { default as WebSockets } from "./webSockets/WebSockets";
|
|
55
55
|
|
|
56
56
|
// Utils
|
|
57
|
-
export { Portal } from "./utils/Portal";
|
|
57
|
+
export { default as Portal } from "./utils/Portal";
|
|
58
58
|
export {
|
|
59
59
|
undefinedIfEmpty,
|
|
60
60
|
withoutUndefinedKeys,
|
|
@@ -68,11 +68,11 @@ export {
|
|
|
68
68
|
withError,
|
|
69
69
|
withErrorMessage,
|
|
70
70
|
} from "./utils/conditionalHOCs";
|
|
71
|
-
export { ErrorMessage } from "./utils/ErrorMessage";
|
|
71
|
+
export { default as ErrorMessage } from "./utils/ErrorMessage";
|
|
72
72
|
export { useClickOutside } from "./utils/hooks";
|
|
73
|
-
export { toLocaleDateString } from "./utils/datetime";
|
|
74
|
-
export { displayCard } from "./utils/displayCard";
|
|
75
|
-
export { isPluginInstalled } from "./utils/isPluginInstalled";
|
|
73
|
+
export { default as toLocaleDateString } from "./utils/datetime";
|
|
74
|
+
export { default as displayCard } from "./utils/displayCard";
|
|
75
|
+
export { default as isPluginInstalled } from "./utils/isPluginInstalled";
|
|
76
76
|
|
|
77
77
|
// Foris URL
|
|
78
78
|
export { ForisURLs, REFORIS_URL_PREFIX } from "./utils/forisUrls";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foris",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
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": {
|
|
@@ -14,49 +14,48 @@
|
|
|
14
14
|
"license": "GPL-3.0",
|
|
15
15
|
"main": "./index.js",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"axios": "^
|
|
18
|
-
"immutability-helper": "3.
|
|
19
|
-
"moment": "^2.
|
|
20
|
-
"qrcode.react": "^1.0
|
|
21
|
-
"react-datetime": "^3.
|
|
22
|
-
"react-uid": "^2.
|
|
17
|
+
"axios": "^1.7.2",
|
|
18
|
+
"immutability-helper": "^3.1.1",
|
|
19
|
+
"moment": "^2.30.1",
|
|
20
|
+
"qrcode.react": "^3.1.0",
|
|
21
|
+
"react-datetime": "^3.2.0",
|
|
22
|
+
"react-uid": "^2.3.3"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"bootstrap": "^
|
|
25
|
+
"bootstrap": "^5.3.3",
|
|
26
26
|
"prop-types": "15.8.1",
|
|
27
27
|
"react": "16.9.0",
|
|
28
28
|
"react-dom": "16.9.0",
|
|
29
29
|
"react-router-dom": "^5.1.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@babel/cli": "^7.
|
|
33
|
-
"@babel/core": "^7.
|
|
34
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
35
|
-
"@babel/preset-env": "^7.
|
|
36
|
-
"@babel/preset-react": "^7.
|
|
37
|
-
"@fortawesome/fontawesome-free": "^5.
|
|
32
|
+
"@babel/cli": "^7.24.7",
|
|
33
|
+
"@babel/core": "^7.24.7",
|
|
34
|
+
"@babel/plugin-transform-runtime": "^7.24.7",
|
|
35
|
+
"@babel/preset-env": "^7.24.7",
|
|
36
|
+
"@babel/preset-react": "^7.24.7",
|
|
37
|
+
"@fortawesome/fontawesome-free": "^6.5.2",
|
|
38
38
|
"@testing-library/react": "^8.0.9",
|
|
39
39
|
"babel-loader": "^8.1.0",
|
|
40
40
|
"babel-polyfill": "^6.26.0",
|
|
41
|
-
"bootstrap": "^
|
|
41
|
+
"bootstrap": "^5.3.3",
|
|
42
42
|
"css-loader": "^5.2.4",
|
|
43
|
-
"eslint": "^
|
|
44
|
-
"eslint-config-
|
|
45
|
-
"eslint-config-reforis": "^1.0.0",
|
|
46
|
-
"eslint-plugin-prettier": "^3.1.4",
|
|
43
|
+
"eslint": "^8.57.0",
|
|
44
|
+
"eslint-config-reforis": "^2.1.1",
|
|
47
45
|
"file-loader": "^6.0.0",
|
|
48
|
-
"jest": "^
|
|
49
|
-
"jest-
|
|
50
|
-
"
|
|
51
|
-
"
|
|
46
|
+
"jest": "^29.7.0",
|
|
47
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
48
|
+
"jest-mock-axios": "^4.7.3",
|
|
49
|
+
"moment-timezone": "^0.5.45",
|
|
50
|
+
"prettier": "^3.3.1",
|
|
52
51
|
"prop-types": "15.8.1",
|
|
53
52
|
"react": "16.9.0",
|
|
54
53
|
"react-dom": "16.9.0",
|
|
55
54
|
"react-router-dom": "^5.1.2",
|
|
56
|
-
"react-styleguidist": "^
|
|
57
|
-
"snapshot-diff": "^0.
|
|
55
|
+
"react-styleguidist": "^12.0.1",
|
|
56
|
+
"snapshot-diff": "^0.10.0",
|
|
58
57
|
"style-loader": "^1.2.1",
|
|
59
|
-
"webpack": "^5.
|
|
58
|
+
"webpack": "^5.91.0"
|
|
60
59
|
},
|
|
61
60
|
"scripts": {
|
|
62
61
|
"lint": "eslint src",
|
package/utils/ErrorMessage.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2019 CZ.NIC z.s.p.o. (
|
|
2
|
+
* Copyright (C) 2019-2024 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
8
|
import React from "react";
|
|
9
|
+
|
|
9
10
|
import PropTypes from "prop-types";
|
|
10
11
|
|
|
11
12
|
ErrorMessage.propTypes = {
|
|
@@ -16,6 +17,8 @@ ErrorMessage.defaultProps = {
|
|
|
16
17
|
message: _("An error occurred while fetching data."),
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
function ErrorMessage({ message }) {
|
|
20
21
|
return <p className="text-center text-danger">{message}</p>;
|
|
21
22
|
}
|
|
23
|
+
|
|
24
|
+
export default ErrorMessage;
|
package/utils/Portal.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2019 CZ.NIC z.s.p.o. (
|
|
2
|
+
* Copyright (C) 2019-2024 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 PropTypes from "prop-types";
|
|
8
9
|
import ReactDOM from "react-dom";
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
Portal.propTypes = {
|
|
12
|
+
containerId: PropTypes.string.isRequired,
|
|
13
|
+
children: PropTypes.node.isRequired,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function Portal({ containerId, children }) {
|
|
11
17
|
const container = document.getElementById(containerId);
|
|
12
18
|
if (container) return ReactDOM.createPortal(children, container);
|
|
13
19
|
return null;
|
|
14
20
|
}
|
|
21
|
+
|
|
22
|
+
export default Portal;
|
package/utils/conditionalHOCs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2019 CZ.NIC z.s.p.o. (
|
|
2
|
+
* Copyright (C) 2019-2024 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.
|
|
@@ -7,16 +7,23 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import ErrorMessage from "./ErrorMessage";
|
|
11
11
|
import { API_STATE } from "../api/utils";
|
|
12
|
-
import {
|
|
12
|
+
import { Spinner } from "../bootstrap/Spinner";
|
|
13
13
|
|
|
14
14
|
function withEither(conditionalFn, Either) {
|
|
15
|
-
return (Component) =>
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
return (Component) => {
|
|
16
|
+
function WithEither(props) {
|
|
17
|
+
if (conditionalFn(props)) {
|
|
18
|
+
return <Either {...props} />;
|
|
19
|
+
}
|
|
20
|
+
return <Component {...props} />;
|
|
18
21
|
}
|
|
19
|
-
|
|
22
|
+
|
|
23
|
+
// Setting displayName for better debugging
|
|
24
|
+
WithEither.displayName = `WithEither(${Component.displayName || Component.name || "Component"})`;
|
|
25
|
+
|
|
26
|
+
return WithEither;
|
|
20
27
|
};
|
|
21
28
|
}
|
|
22
29
|
|
package/utils/datetime.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import moment from "moment";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
date,
|
|
5
|
-
{ inputFormat, outputFormat = "LLL" } = {}
|
|
6
|
-
) {
|
|
3
|
+
function toLocaleDateString(date, { inputFormat, outputFormat = "LLL" } = {}) {
|
|
7
4
|
const parsedDate = inputFormat ? moment(date, inputFormat) : moment(date);
|
|
8
5
|
return parsedDate.locale(ForisTranslations.locale).format(outputFormat);
|
|
9
6
|
}
|
|
7
|
+
|
|
8
|
+
export default toLocaleDateString;
|
package/utils/displayCard.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2020 CZ.NIC z.s.p.o. (
|
|
2
|
+
* Copyright (C) 2020-2024 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
|
-
|
|
8
|
+
function displayCard({ package_lists: packages }, cardName) {
|
|
9
9
|
const enabledPackagesNames = [];
|
|
10
10
|
packages
|
|
11
11
|
.filter((item) => item.enabled)
|
|
@@ -21,3 +21,5 @@ export function displayCard({ package_lists: packages }, cardName) {
|
|
|
21
21
|
});
|
|
22
22
|
return enabledPackagesNames.includes(cardName);
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
export default displayCard;
|
package/utils/hooks.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2020 CZ.NIC z.s.p.o. (
|
|
2
|
+
* Copyright (C) 2020-2024 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
|
-
|
|
8
|
+
const isPluginInstalled = (pluginName) =>
|
|
9
9
|
ForisPlugins.some((plugin) => plugin.name === pluginName);
|
|
10
|
+
|
|
11
|
+
export default isPluginInstalled;
|
package/utils/validations.js
CHANGED
|
@@ -23,12 +23,15 @@ export const ERROR_MESSAGES = {
|
|
|
23
23
|
const REs = {
|
|
24
24
|
IPv4: /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
|
|
25
25
|
IPv6: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,
|
|
26
|
-
IPv6Prefix:
|
|
26
|
+
IPv6Prefix:
|
|
27
|
+
/^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))$/,
|
|
27
28
|
domain: /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/,
|
|
28
|
-
hostname:
|
|
29
|
+
hostname:
|
|
30
|
+
/^[a-z\d]([a-z\d-]{0,61}[a-z\d])?(\.[a-z\d]([a-z\d-]{0,61}[a-z\d])?)*$/i,
|
|
29
31
|
DUID: /^([0-9a-fA-F]{2}){4}([0-9a-fA-F]{2})*$/,
|
|
30
32
|
MAC: /^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/,
|
|
31
|
-
MultipleEmails:
|
|
33
|
+
MultipleEmails:
|
|
34
|
+
/^([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+ *)( *, *[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+ *)*$/,
|
|
32
35
|
};
|
|
33
36
|
|
|
34
37
|
const createValidator = (fieldType) => (value) => {
|
package/webSockets/WebSockets.js
CHANGED
|
@@ -10,14 +10,12 @@
|
|
|
10
10
|
const PROTOCOL = window.location.protocol === "http:" ? "ws" : "wss";
|
|
11
11
|
|
|
12
12
|
const URL = process.env.LIGHTTPD
|
|
13
|
-
? `${PROTOCOL}://${window.location.host}/${
|
|
14
|
-
process.env.WSPATH || "foris-ws"
|
|
15
|
-
}`
|
|
13
|
+
? `${PROTOCOL}://${window.location.host}/${process.env.WSPATH || "foris-ws"}`
|
|
16
14
|
: `${PROTOCOL}://${window.location.hostname}:9081`;
|
|
17
15
|
|
|
18
16
|
const WAITING_FOR_CONNECTION_TIMEOUT = 500;
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
class WebSockets {
|
|
21
19
|
constructor() {
|
|
22
20
|
this.ws = new WebSocket(URL);
|
|
23
21
|
this.ws.onerror = (e) => {
|
|
@@ -122,3 +120,5 @@ export class WebSockets {
|
|
|
122
120
|
this.ws.close();
|
|
123
121
|
}
|
|
124
122
|
}
|
|
123
|
+
|
|
124
|
+
export default WebSockets;
|
package/webSockets/hooks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C) 2019 CZ.NIC z.s.p.o. (
|
|
2
|
+
* Copyright (C) 2019-2024 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.
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
import { useEffect, useState } from "react";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/* eslint-disable default-param-last */
|
|
11
|
+
function useWSForisModule(
|
|
11
12
|
ws,
|
|
12
13
|
module,
|
|
13
14
|
action = "update_settings",
|
|
@@ -41,3 +42,5 @@ export function useWSForisModule(
|
|
|
41
42
|
|
|
42
43
|
return [data];
|
|
43
44
|
}
|
|
45
|
+
|
|
46
|
+
export default useWSForisModule;
|
package/foris-5.6.1.tgz
DELETED
|
Binary file
|