1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2025-02-22 09:44:18 +01:00

Merge branch 'dev' into 'master'

Dev

See merge request turris/reforis/foris-js!271
This commit is contained in:
Aleksandr Gumroian 2025-02-20 12:56:13 +01:00
commit ede4fb0212
5 changed files with 266 additions and 268 deletions

View File

@ -8,427 +8,434 @@ and this project adheres to
## [Unreleased]
## [6.6.2] - 2025-02-20
### Changed
- Enhanced SubmitButton component to accept a custom label prop
- Refactored RichTable component to remove forwardRef and simplify data handling
## [6.6.1] - 2025-02-17
### Changed
- Refactored RichTable component to use forwardRef
- Refactored RichTable component to use forwardRef
## [6.6.0] - 2025-02-07
### Added
- Added & updated Weblate translations
- Added Wi-Fi and LAN settings URLs to ForisURLs
- Added Wi-Fi modes VHT/HE 80+80
- Added encryption selection to WiFiGuestForm
- Added optional close button to ModalHeader component
- Added & updated Weblate translations
- Added Wi-Fi and LAN settings URLs to ForisURLs
- Added Wi-Fi modes VHT/HE 80+80
- Added encryption selection to WiFiGuestForm
- Added optional close button to ModalHeader component
### Changed
- Updated Wi-Fi API
- Enhanced NumberInput component with keyboard & touch accessibility
- Refactored pagination condition in RichTable component
- Updated Wi-Fi API
- Enhanced NumberInput component with keyboard & touch accessibility
- Refactored pagination condition in RichTable component
## [6.5.0] - 2024-11-13
### Added
- Added & updated Weblate translations
- Added RichTable component with pagination and sorting
- Added @tanstack/react-table v8.20.5 to dependencies
- Added & updated Weblate translations
- Added RichTable component with pagination and sorting
- Added @tanstack/react-table v8.20.5 to dependencies
### Changed
- Updated documentation
- Replaced RebootButton with ActionButtonWithModal component
- Fixed import path for CustomizationContextMock in customTestRender.js
- Updated documentation
- Replaced RebootButton with ActionButtonWithModal component
- Fixed import path for CustomizationContextMock in customTestRender.js
## [6.4.0] - 2024-10-02
### Changed
- Refactored Alert component to include dismiss animation and timeout
- Refactored ThreeDotsMenu component to include additional props
- Refactored Alert component to include dismiss animation and timeout
- Refactored ThreeDotsMenu component to include additional props
## [6.3.0] - 2024-09-27
### Added
- Added ThreeDotsMenu component
- Added ThreeDotsMenu component
### Changed
- Refactored EmailInput description
- Refactored RadioSet & ignore Radio component
- Refactored npm package badge in introduction.md
- NPM audit fix
- Refactored EmailInput description
- Refactored RadioSet & ignore Radio component
- Refactored npm package badge in introduction.md
- NPM audit fix
## [6.2.1] - 2024-09-25
### Added
- Added & updated Weblate translations
- Added & updated Weblate translations
### Changed
- Refactored CopyInput component
- Refactored ForisURLs to include new URLs for Overview page
- Refactored CopyInput component
- Refactored ForisURLs to include new URLs for Overview page
## [6.2.0] - 2024-09-20
### Added
- Added useFocusTrap hook
- Added extendSession endpoint
- Added useFocusTrap hook
- Added extendSession endpoint
### Changed
- Refactored Spinner.css to use CSS variable for color
- Refactored Modal component to use useFocusTrap hook
- Refactored Alert component to use useFocusTrap hook
- Refactored Spinner.css to use CSS variable for color
- Refactored Modal component to use useFocusTrap hook
- Refactored Alert component to use useFocusTrap hook
## [6.1.1] - 2024-08-30
### Added
- Added & updated Weblate translations
- Added & updated Weblate translations
### Changed
- Updated icon color classes to use "text-secondary" instead of "text-dark"
- Updated Wi-Fi QRCodeModal component to use new styles & added close button
- Refactored WiFiGuestForm component to get rid of obsolete div element
- NPM audit fix
- Updated icon color classes to use "text-secondary" instead of "text-dark"
- Updated Wi-Fi QRCodeModal component to use new styles & added close button
- Refactored WiFiGuestForm component to get rid of obsolete div element
- NPM audit fix
## [6.1.0] - 2024-08-23
### Added
- Added & updated Weblate translations
- Added & updated Weblate translations
### Changed
- Migrated to Font Awesome v6
- NPM audit fix
- Migrated to Font Awesome v6
- NPM audit fix
## [6.0.3] - 2024-07-26
### Changed
- Updated WiFiQRCode component
- Updated WiFiQRCode component
## [6.0.2] - 2024-06-28
### Added
- Added className prop to CheckBox and Radio components
- Added className prop to CheckBox and Radio components
## [6.0.1] - 2024-06-26
### Added
- Added className prop to Switch component
- Added className prop to Switch component
### Changed
- Updated dependencies in package.json
- NPM audit fix
- Updated dependencies in package.json
- NPM audit fix
## [6.0.0] - 2024-06-11
### Added
- Added CHANGELOG.md
- Added JS_DIR variable to Makefile
- Added support for shared reForis ESLint configuration
- Added CHANGELOG.md
- Added JS_DIR variable to Makefile
- Added support for shared reForis ESLint configuration
### Changed
- Updated dependencies in package.json
- Updated Spinner.css styles for better positioning and responsiveness
- Migrated to Bootstrap 5
- NPM audit fix
- Other small improvements
- Updated dependencies in package.json
- Updated Spinner.css styles for better positioning and responsiveness
- Migrated to Bootstrap 5
- NPM audit fix
- Other small improvements
## [5.6.1] - 2024-01-19
- Added & updated Weblate translations
- Fixed loading state & button's layout
- Updated bootstrap library to version 4.6.2
- Used custom reforis-image in GitLab CI/CD
- NPM audit fix
- Added & updated Weblate translations
- Fixed loading state & button's layout
- Updated bootstrap library to version 4.6.2
- Used custom reforis-image in GitLab CI/CD
- NPM audit fix
## [5.6.0] - 2022-12-29
- Add & update Weblate translations
- Add CustomizationContext and custom hook
- Update caniuse-lite
- Remove testUtils from .gitignore
- Make ieee80211w_disabled as optional in WiFiForm
- Move contexts in a context folder
- NPM audit fix
- Add & update Weblate translations
- Add CustomizationContext and custom hook
- Update caniuse-lite
- Remove testUtils from .gitignore
- Make ieee80211w_disabled as optional in WiFiForm
- Move contexts in a context folder
- NPM audit fix
## [5.5.0] - 2022-12-02
- Add & update translations
- Add a switch to disable Management Frame Protection (802.11w)
- Improved Foris JS documentation
- NPM audit fix
- Add & update translations
- Add a switch to disable Management Frame Protection (802.11w)
- Improved Foris JS documentation
- NPM audit fix
## [5.4.1] - 2022-06-03
- Add Weblate translations
- Update PropType peer dependency
- NPM audit fix
- Add Weblate translations
- Update PropType peer dependency
- NPM audit fix
## [5.4.0] - 2022-05-20
- Add & update translations
- Add CopyInput bootstrap component
- Update WiFiForm labels and description for wifi ax
- Make WS path in lighttpd mode configurable
- Fix Wi-Fi password helptext string
- NPM audit fix
- Add & update translations
- Add CopyInput bootstrap component
- Update WiFiForm labels and description for wifi ax
- Make WS path in lighttpd mode configurable
- Fix Wi-Fi password helptext string
- NPM audit fix
## [5.3.0] - 2022-02-21
- Added & update translations
- Added rest of the props to DownloadButton component
- Added hostname validation
- Added wifi 802.11ax HE modes
- Set best Wi-Fi HT mode depending on the checked frequency
- Improved domain name RegEx pattern
- Removed customOrder prop in Select component
- Fixed Wi-Fi translation strings
- Fixed autocomplete attribute in PasswordInput
- Fixed WiFi password max length check
- Fixed documentation build
- Fixed access token in publish script
- Refined & restructure Makefile
- Updated GitLab CI image to Node.js v16
- NPM update (several dependencies)
- NPM audit fix
- Added & update translations
- Added rest of the props to DownloadButton component
- Added hostname validation
- Added wifi 802.11ax HE modes
- Set best Wi-Fi HT mode depending on the checked frequency
- Improved domain name RegEx pattern
- Removed customOrder prop in Select component
- Fixed Wi-Fi translation strings
- Fixed autocomplete attribute in PasswordInput
- Fixed WiFi password max length check
- Fixed documentation build
- Fixed access token in publish script
- Refined & restructure Makefile
- Updated GitLab CI image to Node.js v16
- NPM update (several dependencies)
- NPM audit fix
## [5.2.0] - 2021-12-15
- Remove login page
- NPM audit fix
- Remove login page
- NPM audit fix
## [5.1.16] - 2021-11-18
- Revert bad NPM audit fix
- NPM audit fix
- Revert bad NPM audit fix
- NPM audit fix
## [5.1.15] - 2021-11-03
- Add WPA3 option
- Add custom order ability of Select options
- NPM audit fix
- Add WPA3 option
- Add custom order ability of Select options
- NPM audit fix
## [5.1.14] - 2021-07-30
- Add & update translations
- Fix infinity redirect loop when WS error occurs
- NPM audit fix
- Add & update translations
- Fix infinity redirect loop when WS error occurs
- NPM audit fix
## [5.1.13] - 2021-06-30
- Add sentinelAgreement endpoint to forisUrls
- NPM audit fix
- Add sentinelAgreement endpoint to forisUrls
- NPM audit fix
## [5.1.12] - 2021-05-14
- Add & update translations
- Add & fix obsolete links
- Expend library with the ResetWifiSettings function
- Fix switching Wi-Fi modes depending on bands in WiFiForm
- Fix translation sources in WiFiForm
- NPM audit fix
- Other small improvements
- Add & update translations
- Add & fix obsolete links
- Expend library with the ResetWifiSettings function
- Fix switching Wi-Fi modes depending on bands in WiFiForm
- Fix translation sources in WiFiForm
- NPM audit fix
- Other small improvements
## [5.1.11] - 2021-01-04
- Remove duplicated file for Norwegian language
- Fix translations inconsistency
- Remove duplicated file for Norwegian language
- Fix translations inconsistency
## [5.1.10] - 2021-12-29
- Add and update translations
- Add and update translations
## [5.1.9] - 2021-12-20
- Increase bottom margin of formFieldsSize
- Change formFieldsSize of ResetWiFiSettings card
- Fix trailing space in Modal classes
- Increase bottom margin of formFieldsSize
- Change formFieldsSize of ResetWiFiSettings card
- Fix trailing space in Modal classes
## [5.1.8] - 2020-12-19
- Add isPluginInstalled function
- Add isPluginInstalled function
## [5.1.7] - 2020-11-27
## [5.1.6] - 2020-11-25
- NPM audit fix
- Add displayCard function to utils
- Add optional sizes to Modal
- Add information about optional sizes to docs
- Remove redundant merge.py
- NPM audit fix
- Add displayCard function to utils
- Add optional sizes to Modal
- Add information about optional sizes to docs
- Remove redundant merge.py
## [5.1.5] - 2020-09-25
- Fix DateTime import
- Fix extra empty space in Switch's classes
- Fix DateTime import
- Fix extra empty space in Switch's classes
## [5.1.4] - 2020-09-25
- Add inline option to Wi-Fi's RadioSet
- Fix Alert's dismissible class condition
- Add closing bootstrap modal using ESC
- Change reboot modal's heading to "Warning!"
- Add inline option to Wi-Fi's RadioSet
- Fix Alert's dismissible class condition
- Add closing bootstrap modal using ESC
- Change reboot modal's heading to "Warning!"
## [5.1.3] - 2020-09-11
- Add SSID validation for 32 bytes length
- Add helpText for SSID input
- Add SSID validation for 32 bytes length
- Add helpText for SSID input
## [5.1.2] - 2020-09-08
- Fix infinity loop caused by WebSockets
- Resolve small issues
- Fix infinity loop caused by WebSockets
- Resolve small issues
## [5.1.1] - 2020-08-31
- Add "inline" option to RadioSet
- NPM audit fix
- Add "inline" option to RadioSet
- NPM audit fix
## [5.1.0] - 2020-08-25
- Add new Switch component
- Swap checkboxes for switches on Wi-Fi page
- Decrease button width on different breakpoints
- Add integration of Prettier + ESLint + reForis Style Guide
- Add appropriate links to dropdown headers
- Add semantic & accessibility structure for headings
- NPM audit & Update packages
- GitLab CI: image update to node 10
- Add new Switch component
- Swap checkboxes for switches on Wi-Fi page
- Decrease button width on different breakpoints
- Add integration of Prettier + ESLint + reForis Style Guide
- Add appropriate links to dropdown headers
- Add semantic & accessibility structure for headings
- NPM audit & Update packages
- GitLab CI: image update to node 10
## [5.0.3] - 2020-09-23
- Fixes issue with WebSockets
- Fixes issue with WebSockets
## [5.0.2] - 2020-09-22
- Fix infinity loop caused by WebSockets
- Fix infinity loop caused by WebSockets
## [5.0.1] - 2020-07-21
- Fix Wi-Fi Form
- NPM audit fix & update of packages
- Fix Wi-Fi Form
- NPM audit fix & update of packages
## [5.0.0] - 2020-05-07
- I've realized that it should be major update due to broken API.
- I've realized that it should be major update due to broken API.
## [4.5.1] - 2020-05-07
- Add initialData to ForisForm children.
- Update translations .pot file.
- Add initialData to ForisForm children.
- Update translations .pot file.
## [4.5.0] - 2020-03-25
- Use exposed pdfmake.
- NPM audit fix & update of packages.
- Use exposed pdfmake.
- NPM audit fix & update of packages.
## [4.4.0] - 2020-03-13
- Update domain validation.
- Update domain validation.
## [4.3.1] - 2020-03-06
- Add logout link.
- Add logout link.
## [4.3.0] - 2020-02-26
- Allow RadioSet accept elements as children.
- Add option to make modal scrollable.
- Allow RadioSet accept elements as children.
- Add option to make modal scrollable.
## [4.2.0] - 2020-02-21
- Add translations.
- Improve datatime localization.
- Add translations.
- Improve datatime localization.
## [4.1.0] - 2020-02-20
- Added date and time utilities.
- Added date and time utilities.
## [4.0.0] - 2020-02-20
- Throw an error if unhandled exception happens during API request.
- Throw an error if unhandled exception happens during API request.
## [3.4.0] - 2020-02-17
- Display actual GET error response within the form.
- Added styles extracted from reForis.
- Added reference to form element (for programmatically submitting it).
- Display actual GET error response within the form.
- Added styles extracted from reForis.
- Added reference to form element (for programmatically submitting it).
## [3.2.0] - 2020-01-17
- Swapped react-router with react-router-dom. Prepared Foris JS for using
react-router-dom exposed by reForis.
- Added controller ID filter to WebSocket hook.
- Updated translation messages after moving WiFi form.
- Increased request timeout to 30.5 sec.
- Swapped react-router with react-router-dom. Prepared Foris JS for using
react-router-dom exposed by reForis.
- Added controller ID filter to WebSocket hook.
- Updated translation messages after moving WiFi form.
- Increased request timeout to 30.5 sec.
## [3.1.1] - 2020-01-10
- Fixed package dependencies related to exposing libraries via reForis
- Fixed package dependencies related to exposing libraries via reForis
## [3.1.0] - 2020-01-09
- Added Wi-Fi settings form
- Fixed path to index.js file in package.json
- Added Wi-Fi settings form
- Fixed path to index.js file in package.json
## [3.0.0] - 2020-01-07
- Removal of Babel compiler
- Fixed width of ForisForm, removed default sizing for form widgets (like
buttons)
- Removal of Babel compiler
- Fixed width of ForisForm, removed default sizing for form widgets (like
buttons)
## [2.1.1] - 2020-01-06
- Display date and time picker above input element
- Display date and time picker above input element
## [2.1.0] - 2019-12-19
- Set WebSocket logging to debug level
- Added hook that detects clicking outside of component
- Added Radio to list of publicly available components
- Fixed link to git repository in package.json
- Set WebSocket logging to debug level
- Added hook that detects clicking outside of component
- Added Radio to list of publicly available components
- Fixed link to git repository in package.json
## [2.0.0] - 2019-12-09
- Added dynamic suffix for API URLs (allowing to use one hook for different
resources with e.g. PUT)
- Added unsubscribe method to WebSocket client
- Added custom class to SpinnerElement
- Improved documentation
- Published README.md
- Added dynamic suffix for API URLs (allowing to use one hook for different
resources with e.g. PUT)
- Added unsubscribe method to WebSocket client
- Added custom class to SpinnerElement
- Improved documentation
- Published README.md
## [1.4.0] - 2019-11-29
- Add reboot button.
- Fix Foris URLs prefixes
- Add reboot button.
- Fix Foris URLs prefixes
## [1.3.3] - 2019-11-22
- Add translations from Weblate.
- Add translations from Weblate.
## [1.3.2] - 2019-11-20
- Expose only AlertContext.
- Add hook for API pooling.
- Expose only AlertContext.
- Add hook for API pooling.
## [1.3.1] - 2019-11-14
@ -441,7 +448,8 @@ and this project adheres to
## [0.0.7] - 2019-09-02
[unreleased]:
https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.6.1...dev
https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.6.2...dev
[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
[6.5.0]: https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.4.0...v6.5.0

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "foris",
"version": "6.6.1",
"version": "6.6.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "foris",
"version": "6.6.1",
"version": "6.6.2",
"license": "GPL-3.0",
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.6.0",

View File

@ -1,6 +1,6 @@
{
"name": "foris",
"version": "6.6.1",
"version": "6.6.2",
"description": "Foris JS library is a set of components and utils for reForis application and plugins.",
"author": "CZ.NIC, z.s.p.o.",
"repository": {

View File

@ -1,16 +1,11 @@
/*
* 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.
*/
import React, {
useMemo,
useState,
useImperativeHandle,
forwardRef,
} from "react";
import React, { useMemo, useState } from "react";
import {
flexRender,
@ -25,70 +20,62 @@ import RichTableBody from "./RichTableBody";
import RichTableHeader from "./RichTableHeader";
import RichTablePagination from "./RichTablePagination";
const fallbackData = [];
const RichTable = forwardRef(
({ columns, data, withPagination, pageSize = 5, pageIndex = 0 }, ref) => {
const tableColumns = useMemo(() => columns, [columns]);
const [tableData, setTableData] = useState(data ?? fallbackData);
const [sorting, setSorting] = useState([]);
const [pagination, setPagination] = useState({
pageIndex,
pageSize,
});
useImperativeHandle(ref, () => ({
setTableData,
}));
const table = useReactTable({
data: tableData,
columns: tableColumns,
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
getPaginationRowModel: getPaginationRowModel(),
onPaginationChange: setPagination,
onSortingChange: setSorting,
state: {
sorting,
pagination,
},
});
const paginationIsNeeded =
tableData.length > pageSize && withPagination;
return (
<div className="table-responsive">
<table className="table table-hover text-nowrap">
<RichTableHeader table={table} flexRender={flexRender} />
<RichTableBody table={table} flexRender={flexRender} />
</table>
{paginationIsNeeded && (
<RichTablePagination
table={table}
tablePageSize={pageSize}
allRows={tableData.length}
/>
)}
</div>
);
}
);
RichTable.propTypes = {
/** Columns to be displayed in the table */
columns: PropTypes.array.isRequired,
/** Data to be displayed in the table */
/** Data to be displayed in the table, must be passed as a stable reference, for example, useState */
data: PropTypes.array.isRequired,
/** Whether to display pagination */
withPagination: PropTypes.bool,
/** Number of rows per page */
/** Number of rows per page, the default is 5 */
pageSize: PropTypes.number,
/** Index of the current page */
pageIndex: PropTypes.number,
};
RichTable.displayName = "RichTable";
export default function RichTable({
columns,
data,
withPagination,
pageSize = 5,
pageIndex = 0,
}) {
const tableColumns = useMemo(() => columns, [columns]);
const [sorting, setSorting] = useState([]);
const [pagination, setPagination] = useState({
pageIndex,
pageSize,
});
export default RichTable;
const table = useReactTable({
data,
columns: tableColumns,
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
getPaginationRowModel: getPaginationRowModel(),
onPaginationChange: setPagination,
onSortingChange: setSorting,
state: {
sorting,
pagination,
},
});
const paginationIsNeeded = data.length > pageSize && withPagination;
return (
<div className="table-responsive">
<table className="table table-hover text-nowrap">
<RichTableHeader table={table} flexRender={flexRender} />
<RichTableBody table={table} flexRender={flexRender} />
</table>
{paginationIsNeeded && (
<RichTablePagination
table={table}
tablePageSize={pageSize}
allRows={data.length}
/>
)}
</div>
);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://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.
@ -20,22 +20,25 @@ export const STATES = {
SubmitButton.propTypes = {
disabled: PropTypes.bool,
state: PropTypes.oneOf(Object.keys(STATES).map((key) => STATES[key])),
label: PropTypes.string,
};
export function SubmitButton({ disabled, state, ...props }) {
export function SubmitButton({ disabled, state, label, ...props }) {
const disableSubmitButton = disabled || state !== STATES.READY;
const loadingSubmitButton = state !== STATES.READY;
let labelSubmitButton;
switch (state) {
case STATES.SAVING:
labelSubmitButton = _("Updating");
break;
case STATES.LOAD:
labelSubmitButton = _("Load settings");
break;
default:
labelSubmitButton = _("Save");
let labelSubmitButton = label;
if (!labelSubmitButton) {
switch (state) {
case STATES.SAVING:
labelSubmitButton = _("Updating");
break;
case STATES.LOAD:
labelSubmitButton = _("Load settings");
break;
default:
labelSubmitButton = _("Save");
}
}
return (