1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2025-06-15 13:36:35 +02:00

Compare commits

...

10 Commits

Author SHA1 Message Date
227a975e5f Merge branch 'dev' into 'master'
Dev

See merge request turris/reforis/foris-js!276
2025-03-11 15:40:15 +01:00
819e5a1dd2 Merge branch 'bump-version-670' into 'dev'
Bump v6.7.0

See merge request turris/reforis/foris-js!275
2025-03-11 15:33:28 +01:00
6432073d62 Bump v6.7.0
* Add encryption property to guest WiFi settings in tests
* Add global fuzzy search and columns visibility to RichTable
* Make thead of RichTable lighter
* Update dependencies in package.json to latest versions
* Enhance ActionButtonWithModal to support dynamic methods
* NPM audit fix
2025-03-11 15:28:06 +01:00
94f436008d Update several npm dependencies in package.json 2025-03-11 15:24:08 +01:00
6f9e44a7b1 NPM audit fix 2025-03-11 15:23:18 +01:00
13ca745412 Merge branch 'enhance-action-button-with-modal-dynamic-methods' into 'dev'
Enhance ActionButtonWithModal to support dynamic methods

See merge request turris/reforis/foris-js!274
2025-03-10 16:12:17 +01:00
a25133d786 Enhance ActionButtonWithModal to support dynamic methods 2025-03-10 15:01:45 +01:00
ede4fb0212 Merge branch 'dev' into 'master'
Dev

See merge request turris/reforis/foris-js!271
2025-02-20 12:56:13 +01:00
7197813cc9 Merge branch 'dev' into 'master'
Dev

See merge request turris/reforis/foris-js!268
2025-02-17 16:16:10 +01:00
2f249ce3dc Merge branch 'dev' into 'master'
Dev

See merge request turris/reforis/foris-js!265
2025-02-07 14:46:24 +01:00
4 changed files with 1219 additions and 906 deletions

View File

@ -8,6 +8,20 @@ and this project adheres to
## [Unreleased]
## [6.7.0] - 2025-03-11
### Added
- Added encryption property to guest WiFi settings in tests
- Added global fuzzy search and columns visibility to RichTable
### Changed
- Made thead of RichTable lighter
- Updated dependencies in package.json to latest versions
- Enhanced ActionButtonWithModal to support dynamic methods
- NPM audit fix
## [6.6.2] - 2025-02-20
### Changed
@ -448,7 +462,8 @@ and this project adheres to
## [0.0.7] - 2019-09-02
[unreleased]:
https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.6.2...dev
https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.7.0...dev
[6.7.0]: https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.6.2...v6.7.0
[6.6.2]: https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.6.1...v6.6.2
[6.6.1]: https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.6.0...v6.6.1
[6.6.0]: https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.5.0...v6.6.0

2064
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "foris",
"version": "6.6.2",
"version": "6.7.0",
"description": "Foris JS library is a set of components and utils for reForis application and plugins.",
"author": "CZ.NIC, z.s.p.o.",
"repository": {
@ -46,13 +46,13 @@
"bootstrap": "^5.3.3",
"css-loader": "^7.1.2",
"eslint": "^8.57.0",
"eslint-config-reforis": "^2.1.1",
"eslint-config-reforis": "^2.2.1",
"file-loader": "^6.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-mock-axios": "^4.8.0",
"moment-timezone": "^0.5.47",
"prettier": "^3.5.2",
"prettier": "^3.5.3",
"prop-types": "15.8.1",
"react": "16.9.0",
"react-dom": "16.9.0",
@ -71,4 +71,4 @@
"docs": "npx styleguidist build ",
"docs:watch": "styleguidist server"
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
* Copyright (C) 2019-2025 CZ.NIC z.s.p.o. (https://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
@ -9,7 +9,7 @@ import React, { useState, useEffect } from "react";
import PropTypes from "prop-types";
import { useAPIPost } from "../../api/hooks";
import { useAPIPost, useAPIPut } from "../../api/hooks";
import { API_STATE } from "../../api/utils";
import Button from "../../bootstrap/Button";
import {
@ -23,6 +23,8 @@ import { useAlert } from "../../context/alertContext/AlertContext";
ActionButtonWithModal.propTypes = {
/** Component that triggers the action. */
actionTrigger: PropTypes.elementType.isRequired,
/** Method to use for the action. */
actionMethod: PropTypes.string,
/** URL to send the action to. */
actionUrl: PropTypes.string.isRequired,
/** Title of the modal. */
@ -41,6 +43,7 @@ ActionButtonWithModal.propTypes = {
function ActionButtonWithModal({
actionTrigger: ActionTriggerComponent,
actionMethod = "POST",
actionUrl,
modalTitle,
modalMessage,
@ -51,24 +54,43 @@ function ActionButtonWithModal({
}) {
const [triggered, setTriggered] = useState(false);
const [modalShown, setModalShown] = useState(false);
const [triggerActionStatus, triggerAction] = useAPIPost(actionUrl);
const [triggerPostActionStatus, triggerPostAction] = useAPIPost(actionUrl);
const [triggerPutActionStatus, triggerPutAction] = useAPIPut(actionUrl);
const [setAlert] = useAlert();
useEffect(() => {
if (triggerActionStatus.state === API_STATE.SUCCESS) {
if (
triggerPostActionStatus.state === API_STATE.SUCCESS ||
triggerPutActionStatus.state === API_STATE.SUCCESS
) {
setAlert(
successMessage || _("Action successful."),
API_STATE.SUCCESS
);
setTriggered(false);
}
if (triggerActionStatus.state === API_STATE.ERROR) {
if (
triggerPostActionStatus.state === API_STATE.ERROR ||
triggerPutActionStatus.state === API_STATE.ERROR
) {
setAlert(errorMessage || _("Action failed."));
setTriggered(false);
}
}, [triggerActionStatus, setAlert, successMessage, errorMessage]);
}, [
triggerPostActionStatus,
triggerPutActionStatus,
setAlert,
successMessage,
errorMessage,
]);
const actionHandler = () => {
setTriggered(true);
triggerAction();
if (actionMethod === "POST") {
triggerPostAction();
} else {
triggerPutAction();
}
setModalShown(false);
};