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

Compare commits

...

29 Commits

Author SHA1 Message Date
8d75b5ec6e Bump v5.1.9
* Fix trailing space in Modal classes
* Change formFieldsSize of ResetWiFiSettings card
* Increase bottom margin of formFieldsSize
2021-01-20 11:42:24 +01:00
c1aa1948b4 Merge branch 'fix-wifi-layout' into 'dev'
Fix Wi-Fi layout

See merge request turris/reforis/foris-js!145
2021-01-19 16:42:17 +01:00
8c110ebf52 NPM audit fix 2021-01-18 23:31:43 +01:00
abb5be53aa Fix trailing space in Modal classes 2021-01-18 23:10:39 +01:00
af0fb80e45 Update Snapshots 2021-01-18 23:10:39 +01:00
688192504f Change formFieldsSize of ResetWiFiSettings card 2021-01-18 22:06:20 +01:00
b8e5dbec8d Increase bottom margin of formFieldsSize 2021-01-18 22:05:56 +01:00
fde751a25f Merge branch 'check-installed-plugins' into 'dev'
Add isPluginInstalled function

See merge request turris/reforis/foris-js!143
2020-12-20 18:47:06 +01:00
79006cfb99 Bump v5.1.8 2020-12-19 00:25:44 +01:00
de398901f3 Add isPluginInstalled function 2020-12-19 00:14:05 +01:00
56173d4959 Merge branch 'add-storage-link' into 'dev'
Add storage link

See merge request turris/reforis/foris-js!141
2020-11-27 17:09:55 +01:00
7c837d041e Bump v5.1.7 2020-11-27 15:37:07 +01:00
473c81f9a4 Add storage link 2020-11-27 15:37:02 +01:00
15567a7dde Merge branch 'release-516' into 'dev'
Bump v5.1.6

Closes #18

See merge request turris/reforis/foris-js!139
2020-11-27 12:30:39 +01:00
e2695d49a1 Bump v5.1.6
* NPM audit fix
* Add displayCard function to utils
* Add optional sizes to Modal
* Add information about optional sizes to docs
* Remove redundant merge.py
2020-11-25 23:29:42 +01:00
a87e6858bf Remove redundant merge.py 2020-11-25 23:29:31 +01:00
e864de5a24 Merge branch 'add-optional-sizes-modals' into 'dev'
Add optional sizes to Modals

See merge request turris/reforis/foris-js!138
2020-11-23 22:25:18 +01:00
5469e6ec80 Add displayCard function to utils 2020-11-22 23:45:27 +01:00
4898016388 Update Snapshots 2020-11-20 17:02:10 +01:00
e0fab75c69 NPM audit fix 2020-11-20 17:00:26 +01:00
6480a39cdb Add information about optional sizes to docs 2020-11-20 16:56:25 +01:00
6f05d5d136 Add optional sizes to Modal 2020-11-20 16:56:16 +01:00
0892a1534a Merge branch 'release-v5.1.5' into 'dev'
Release v5.1.5

See merge request turris/reforis/foris-js!136
2020-09-29 10:56:55 +02:00
1bac60e054 Bump v5.1.5 2020-09-25 19:27:58 +02:00
328e568ab3 NPM audit fix 2020-09-25 19:26:57 +02:00
c68389359e Update Snapshots 2020-09-25 18:52:25 +02:00
e03e0f44cc Fix extra empty space in Switch's classes 2020-09-25 18:50:04 +02:00
1e04d34645 Fix DateTime import 2020-09-25 18:50:04 +02:00
ed7cf34e76 Merge branch 'release-v5.1.4' into 'dev'
Release v5.1.4

See merge request turris/reforis/foris-js!133
2020-09-25 17:43:10 +02:00
15 changed files with 1953 additions and 2717 deletions

4511
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "foris", "name": "foris",
"version": "5.1.4", "version": "5.1.9",
"description": "Set of components and utils for Foris and its plugins.", "description": "Set of components and utils for Foris and its plugins.",
"author": "CZ.NIC, z.s.p.o.", "author": "CZ.NIC, z.s.p.o.",
"repository": { "repository": {
@ -14,11 +14,11 @@
"license": "GPL-3.0", "license": "GPL-3.0",
"main": "./src/index.js", "main": "./src/index.js",
"dependencies": { "dependencies": {
"axios": "^0.19.2", "axios": "^0.21.1",
"immutability-helper": "3.0.1", "immutability-helper": "3.0.1",
"moment": "^2.24.0", "moment": "^2.24.0",
"qrcode.react": "^0.9.3", "qrcode.react": "^0.9.3",
"react-datetime": "^2.16.3", "react-datetime": "^3.0.4",
"react-uid": "^2.2.0" "react-uid": "^2.2.0"
}, },
"peerDependencies": { "peerDependencies": {
@ -29,7 +29,7 @@
"react-router-dom": "^5.1.2" "react-router-dom": "^5.1.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.8.4", "@babel/cli": "^7.12.10",
"@babel/core": "^7.9.0", "@babel/core": "^7.9.0",
"@babel/plugin-transform-runtime": "^7.9.0", "@babel/plugin-transform-runtime": "^7.9.0",
"@babel/preset-env": "^7.9.0", "@babel/preset-env": "^7.9.0",
@ -53,10 +53,10 @@
"react": "16.9.0", "react": "16.9.0",
"react-dom": "16.9.0", "react-dom": "16.9.0",
"react-router-dom": "^5.1.2", "react-router-dom": "^5.1.2",
"react-styleguidist": "^10.6.2", "react-styleguidist": "^11.1.5",
"snapshot-diff": "^0.7.0", "snapshot-diff": "^0.7.0",
"style-loader": "^1.2.1", "style-loader": "^1.2.1",
"webpack": "^4.43.0" "webpack": "^5.15.0"
}, },
"scripts": { "scripts": {
"lint": "eslint src", "lint": "eslint src",

View File

@ -7,7 +7,7 @@
import React from "react"; import React from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import Datetime from "react-datetime/DateTime"; import Datetime from "react-datetime";
import moment from "moment/moment"; import moment from "moment/moment";
import "react-datetime/css/react-datetime.css"; import "react-datetime/css/react-datetime.css";
import "./DataTimeInput.css"; import "./DataTimeInput.css";

View File

@ -18,6 +18,7 @@ Modal.propTypes = {
/** Callback to manage modal visibility */ /** Callback to manage modal visibility */
setShown: PropTypes.func.isRequired, setShown: PropTypes.func.isRequired,
scrollable: PropTypes.bool, scrollable: PropTypes.bool,
size: PropTypes.string,
/** Modal content use following: `ModalHeader`, `ModalBody`, `ModalFooter` */ /** Modal content use following: `ModalHeader`, `ModalBody`, `ModalFooter` */
children: PropTypes.oneOfType([ children: PropTypes.oneOfType([
@ -26,8 +27,9 @@ Modal.propTypes = {
]).isRequired, ]).isRequired,
}; };
export function Modal({ shown, setShown, scrollable, children }) { export function Modal({ shown, setShown, scrollable, size, children }) {
const dialogRef = useRef(); const dialogRef = useRef();
let modalSize = "modal-";
useClickOutside(dialogRef, () => setShown(false)); useClickOutside(dialogRef, () => setShown(false));
@ -44,14 +46,32 @@ export function Modal({ shown, setShown, scrollable, children }) {
}; };
}, [setShown]); }, [setShown]);
switch (size) {
case "sm":
modalSize += "sm";
break;
case "lg":
modalSize += "lg";
break;
case "xl":
modalSize += "xl";
break;
default:
modalSize = "";
break;
}
return ( return (
<Portal containerId="modal-container"> <Portal containerId="modal-container">
<div className={`modal fade ${shown ? "show" : ""}`} role="dialog"> <div
className={`modal fade ${shown ? "show" : ""}`.trim()}
role="dialog"
>
<div <div
ref={dialogRef} ref={dialogRef}
className={`modal-dialog modal-dialog-centered${ className={`${modalSize.trim()} modal-dialog modal-dialog-centered ${
scrollable ? " modal-dialog-scrollable" : "" scrollable ? "modal-dialog-scrollable" : ""
}`} }`.trim()}
role="document" role="document"
> >
<div className="modal-content">{children}</div> <div className="modal-content">{children}</div>

View File

@ -1,8 +1,19 @@
Bootstrap modal component. Bootstrap modal component.
it's required to have an element `<div id={"modal-container"}/>` somewhere on It's required to have an element `<div id={"modal-container"}/>` somewhere on
the page since modals are rendered in portals. the page since modals are rendered in portals.
Modals also have three optional sizes, which can be defined through the `size`
prop:
- small - `sm`
- large - `lg`
- extra-large - `xl`
For more details please visit Bootstrap
<a href="https://getbootstrap.com/docs/4.5/components/modal/#optional-sizes" target="_blank">
documentation</a>.
```js ```js
<div id="modal-container" /> <div id="modal-container" />
``` ```
@ -14,7 +25,7 @@ import { useState } from "react";
const [shown, setShown] = useState(false); const [shown, setShown] = useState(false);
<> <>
<Modal setShown={setShown} shown={shown}> <Modal setShown={setShown} shown={shown} size="sm">
<ModalHeader setShown={setShown} title="Warning!" /> <ModalHeader setShown={setShown} title="Warning!" />
<ModalBody> <ModalBody>
<p>Bla bla bla...</p> <p>Bla bla bla...</p>

View File

@ -23,7 +23,7 @@ Switch.propTypes = {
export function Switch({ label, helpText, switchHeading, ...props }) { export function Switch({ label, helpText, switchHeading, ...props }) {
const uid = useUID(); const uid = useUID();
return ( return (
<div className={`form-group ${switchHeading ? "switch" : ""}`}> <div className={`form-group ${switchHeading ? "switch" : ""}`.trim()}>
<div <div
className={`custom-control custom-switch ${ className={`custom-control custom-switch ${
!helpText ? "custom-control-inline" : "" !helpText ? "custom-control-inline" : ""

View File

@ -2,7 +2,7 @@
exports[`<Switch/> Render switch 1`] = ` exports[`<Switch/> Render switch 1`] = `
<div <div
class="form-group " class="form-group"
> >
<div <div
class="custom-control custom-switch" class="custom-control custom-switch"
@ -30,7 +30,7 @@ exports[`<Switch/> Render switch 1`] = `
exports[`<Switch/> Render uncheked switch 1`] = ` exports[`<Switch/> Render uncheked switch 1`] = `
<div <div
class="form-group " class="form-group"
> >
<div <div
class="custom-control custom-switch" class="custom-control custom-switch"

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/) * Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
* *
* This is free software, licensed under the GNU General Public License v3. * This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information. * See /LICENSE for more information.
@ -7,5 +7,5 @@
/** Bootstrap column size for form fields */ /** Bootstrap column size for form fields */
// eslint-disable-next-line import/prefer-default-export // eslint-disable-next-line import/prefer-default-export
export const formFieldsSize = "card p-4 col-sm-12 col-lg-12 p-0 mb-3"; export const formFieldsSize = "card p-4 col-sm-12 col-lg-12 p-0 mb-4";
export const buttonFormFieldsSize = "col-sm-12 col-lg-12 p-0 mb-3"; export const buttonFormFieldsSize = "col-sm-12 col-lg-12 p-0 mb-3";

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/) * Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
* *
* This is free software, licensed under the GNU General Public License v3. * This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information. * See /LICENSE for more information.
@ -13,7 +13,7 @@ import { useAlert } from "../../alertContext/AlertContext";
import { ALERT_TYPES } from "../../bootstrap/Alert"; import { ALERT_TYPES } from "../../bootstrap/Alert";
import { useAPIPost } from "../../api/hooks"; import { useAPIPost } from "../../api/hooks";
import { API_STATE } from "../../api/utils"; import { API_STATE } from "../../api/utils";
import { buttonFormFieldsSize } from "../../bootstrap/constants"; import { formFieldsSize } from "../../bootstrap/constants";
ResetWiFiSettings.propTypes = { ResetWiFiSettings.propTypes = {
ws: PropTypes.object.isRequired, ws: PropTypes.object.isRequired,
@ -51,7 +51,7 @@ export default function ResetWiFiSettings({ ws, endpoint }) {
} }
return ( return (
<> <div className={formFieldsSize}>
<h2>{_("Reset Wi-Fi Settings")}</h2> <h2>{_("Reset Wi-Fi Settings")}</h2>
<p> <p>
{_(` {_(`
@ -59,7 +59,7 @@ If a number of wireless cards doesn't match, you may try to reset the Wi-Fi sett
current Wi-Fi configuration and restore the default values. current Wi-Fi configuration and restore the default values.
`)} `)}
</p> </p>
<div className={`${buttonFormFieldsSize} text-right`}> <div className="text-right">
<Button <Button
className="btn-warning" className="btn-warning"
forisFormSize forisFormSize
@ -70,6 +70,6 @@ current Wi-Fi configuration and restore the default values.
{_("Reset Wi-Fi Settings")} {_("Reset Wi-Fi Settings")}
</Button> </Button>
</div> </div>
</> </div>
); );
} }

View File

@ -251,7 +251,7 @@ exports[`<WiFiSettings/> Snapshot 2.4 GHz 1`] = `
exports[`<WiFiSettings/> Snapshot both modules disabled. 1`] = ` exports[`<WiFiSettings/> Snapshot both modules disabled. 1`] = `
<DocumentFragment> <DocumentFragment>
<div <div
class="card p-4 col-sm-12 col-lg-12 p-0 mb-3" class="card p-4 col-sm-12 col-lg-12 p-0 mb-4"
> >
<form> <form>
<div <div
@ -309,24 +309,28 @@ exports[`<WiFiSettings/> Snapshot both modules disabled. 1`] = `
</div> </div>
</form> </form>
</div> </div>
<h2> <div
Reset Wi-Fi Settings class="card p-4 col-sm-12 col-lg-12 p-0 mb-4"
</h2> >
<p> <h2>
Reset Wi-Fi Settings
</h2>
<p>
If a number of wireless cards doesn't match, you may try to reset the Wi-Fi settings. Note that this will remove the 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. current Wi-Fi configuration and restore the default values.
</p> </p>
<div <div
class="col-sm-12 col-lg-12 p-0 mb-3 text-right" class="text-right"
>
<button
class="btn btn-warning col-sm-12 col-md-3 col-lg-2"
type="button"
> >
Reset Wi-Fi Settings <button
</button> class="btn btn-warning col-sm-12 col-md-3 col-lg-2"
type="button"
>
Reset Wi-Fi Settings
</button>
</div>
</div> </div>
</DocumentFragment> </DocumentFragment>
`; `;
@ -886,7 +890,7 @@ exports[`<WiFiSettings/> Snapshot one module enabled. 1`] = `
+ </select> + </select>
+ </div> + </div>
+ <div + <div
+ class=\\"form-group \\" + class=\\"form-group\\"
+ > + >
+ <div + <div
+ class=\\"custom-control custom-switch\\" + class=\\"custom-control custom-switch\\"

View File

@ -39,7 +39,6 @@ export { Modal, ModalBody, ModalFooter, ModalHeader } from "./bootstrap/Modal";
// Common // Common
export { RebootButton } from "./common/RebootButton"; export { RebootButton } from "./common/RebootButton";
export { WiFiSettings } from "./common/WiFiSettings/WiFiSettings"; export { WiFiSettings } from "./common/WiFiSettings/WiFiSettings";
// Form // Form
export { ForisForm } from "./form/components/ForisForm"; export { ForisForm } from "./form/components/ForisForm";
export { export {
@ -70,6 +69,8 @@ export {
export { ErrorMessage } from "./utils/ErrorMessage"; export { ErrorMessage } from "./utils/ErrorMessage";
export { useClickOutside } from "./utils/hooks"; export { useClickOutside } from "./utils/hooks";
export { toLocaleDateString } from "./utils/datetime"; export { toLocaleDateString } from "./utils/datetime";
export { displayCard } from "./utils/displayCard";
export { isPluginInstalled } from "./utils/isPluginInstalled";
// Foris URL // Foris URL
export { ForisURLs, REFORIS_URL_PREFIX } from "./utils/forisUrls"; export { ForisURLs, REFORIS_URL_PREFIX } from "./utils/forisUrls";

23
src/utils/displayCard.js Normal file
View File

@ -0,0 +1,23 @@
/*
* Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
*/
export function displayCard({ package_lists: packages }, cardName) {
const enabledPackagesNames = [];
packages
.filter((item) => item.enabled)
.map((item) => {
enabledPackagesNames.push(item.name);
item.options
.filter((option) => option.enabled)
.map((option) => {
enabledPackagesNames.push(option.name);
return null;
});
return null;
});
return enabledPackagesNames.includes(cardName);
}

View File

@ -20,6 +20,8 @@ export const ForisURLs = {
updates: `${REFORIS_URL_PREFIX}/package-management/updates`, updates: `${REFORIS_URL_PREFIX}/package-management/updates`,
}, },
storage: `${REFORIS_URL_PREFIX}/storage`,
// Notifications links are used with <Link/> inside Router, thus url subdir is not required. // Notifications links are used with <Link/> inside Router, thus url subdir is not required.
overview: "/overview", overview: "/overview",
notifications: "/overview#notifications", notifications: "/overview#notifications",

View File

@ -0,0 +1,9 @@
/*
* Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
*/
export const isPluginInstalled = (pluginName) =>
ForisPlugins.some((plugin) => plugin.name === pluginName);

View File

@ -1,7 +0,0 @@
import os
for entry in os.scandir("."):
if entry.is_dir():
print(entry.name)
os.system(f"msgmerge /home/mcjlnrtwcz/Repositories/reforis/reforis/translations/{entry.name}/LC_MESSAGES/messages.po forisjs.pot -o {entry.name}/LC_MESSAGES/forisjs.po")