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

Compare commits

..

18 Commits

Author SHA1 Message Date
e27a23600f Bump version 1.3.3. 2019-11-22 16:30:25 +01:00
daf787e2df Merge branch 'translations' into 'master'
Translations

See merge request turris/reforis/foris-js!47
2019-11-22 15:19:01 +00:00
512c65c213 Translated using Weblate (Czech)
Currently translated at 100.0% (18 of 18 strings)

Translation: Turris/Foris JS
Translate-URL: https://hosted.weblate.org/projects/turris/foris-js/cs/
2019-11-21 18:04:38 +01:00
3925fb6439 Added translation using Weblate (Spanish) 2019-11-21 05:10:24 +01:00
21bbfb6d2e Merge branch 'dev' into 'master'
Dev

See merge request turris/reforis/foris-js!43
2019-11-20 10:22:05 +00:00
1dcba1dfa8 Merge branch 'api-polling-catch-error' into 'dev'
Catch error state in API polling.

See merge request turris/reforis/foris-js!44
2019-11-19 16:56:38 +00:00
fd8acd1ceb Catch error and sending state in API polling. 2019-11-19 16:56:38 +00:00
48d5cf0119 Merge branch 'clickable-checkbox-helptext' into 'dev'
Make checkBox help text clickabe.

See merge request turris/reforis/foris-js!45
2019-11-19 12:43:15 +00:00
1a82f8e225 Update checkbox snapshots. 2019-11-19 13:37:43 +01:00
638821d025 Make checkBox help text clickabe. 2019-11-19 13:36:49 +01:00
fbaa73e378 Merge branch 'global-alert-context' into 'dev'
Use global AlertContext

See merge request turris/reforis/foris-js!42
2019-11-18 12:51:43 +00:00
e54db2c577 Use global AlertContext 2019-11-18 12:51:43 +00:00
a6866a0673 Merge branch 'api-polling' into 'dev'
Add hook for API polling.

See merge request turris/reforis/foris-js!41
2019-11-15 15:59:44 +00:00
429814ebb5 Add until param to API polling hook. 2019-11-15 14:21:19 +01:00
73e213c467 Add default delay. 2019-11-15 14:20:14 +01:00
2e68e56e44 Add hook for API polling. 2019-11-15 14:20:07 +01:00
b3bb4de646 Merge branch 'with-either-props' into 'dev'
Fix for withEither

See merge request turris/reforis/foris-js!40
2019-11-15 08:55:24 +00:00
b30f9f59b4 Fix for withEither 2019-11-15 08:55:24 +00:00
12 changed files with 170 additions and 48 deletions

4
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "foris",
"version": "1.3.1",
"version": "1.3.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -6269,6 +6269,7 @@
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/immutability-helper/-/immutability-helper-3.0.1.tgz",
"integrity": "sha512-U92ROQQt7XkIwrdqCByUI118TQM1hXdKnRQpvKeA0HRyGSnJipu9IWHe4UD8zCN00O8UnQjQzPCgZ1CC3yBzHA==",
"dev": true,
"requires": {
"invariant": "^2.2.4"
}
@ -6402,6 +6403,7 @@
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz",
"integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==",
"dev": true,
"requires": {
"loose-envify": "^1.0.0"
}

View File

@ -1,6 +1,6 @@
{
"name": "foris",
"version": "1.3.1",
"version": "1.3.3",
"description": "Set of components and utils for Foris and its plugins.",
"author": "CZ.NIC, z.s.p.o.",
"repository": {
@ -15,7 +15,6 @@
"main": "index.js",
"dependencies": {
"axios": "^0.19.0",
"immutability-helper": "^3.0.0",
"jest-transform-css": "^2.0.0",
"moment": "^2.24.0",
"moment-timezone": "^0.5.25",
@ -25,8 +24,9 @@
"react-uid": "^2.2.0"
},
"peerDependencies": {
"react": "^16.9.0",
"react-dom": "^16.9.0"
"immutability-helper": "3.0.1",
"react": "16.9.0",
"react-dom": "16.9.0"
},
"devDependencies": {
"@babel/cli": "^7.4.4",
@ -49,12 +49,13 @@
"eslint": "^6.1.0",
"eslint-config-reforis": "^1.0.0",
"file-loader": "^4.2.0",
"immutability-helper": "3.0.1",
"jest": "^24.8.0",
"jest-mock-axios": "^3.0.0",
"moment": "^2.24.0",
"moment-timezone": "^0.5.25",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react": "16.9.0",
"react-dom": "16.9.0",
"react-styleguidist": "^9.1.16",
"snapshot-diff": "^0.5.1",
"style-loader": "^1.0.0",

View File

@ -11,8 +11,6 @@ import PropTypes from "prop-types";
import { Alert, ALERT_TYPES } from "bootstrap/Alert";
import { Portal } from "utils/Portal";
const AlertContext = React.createContext();
AlertContextProvider.propTypes = {
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
@ -21,6 +19,7 @@ AlertContextProvider.propTypes = {
};
function AlertContextProvider({ children }) {
const { AlertContext } = window;
const [alert, setAlert] = useState(null);
const setAlertWrapper = useCallback((message, type = ALERT_TYPES.DANGER) => {
@ -46,7 +45,8 @@ function AlertContextProvider({ children }) {
}
function useAlert() {
const { AlertContext } = window;
return useContext(AlertContext);
}
export { AlertContext, AlertContextProvider, useAlert };
export { AlertContextProvider, useAlert };

View File

@ -5,7 +5,9 @@
* See /LICENSE for more information.
*/
import { useCallback, useReducer } from "react";
import {
useCallback, useEffect, useReducer, useState,
} from "react";
import { ForisURLs } from "forisUrls";
import {
@ -90,3 +92,23 @@ const useAPIDelete = createAPIHook("DELETE");
export {
useAPIGet, useAPIPost, useAPIPatch, useAPIPut, useAPIDelete,
};
export function useAPIPolling(endpoint, delay = 1000, until) { // delay ms
const [state, setState] = useState({ state: API_STATE.INIT });
const [getResponse, get] = useAPIGet(endpoint);
useEffect(() => {
if (getResponse.state !== API_STATE.INIT) {
setState(getResponse);
}
}, [getResponse]);
useEffect(() => {
if (until) {
const interval = setInterval(get, delay);
return () => clearInterval(interval);
}
}, [until, delay, get]);
return [state];
}

View File

@ -42,8 +42,10 @@ export function CheckBox({
{...props}
/>
<label className="custom-control-label" htmlFor={uid}>{label}</label>
{helpText && <small className="form-text text-muted">{helpText}</small>}
<label className="custom-control-label" htmlFor={uid}>
{label}
{helpText && <small className="form-text text-muted">{helpText}</small>}
</label>
</div>
</div>
);

View File

@ -24,18 +24,18 @@ Spinner.defaultProps = {
};
export function Spinner({
fullScreen, children, className, ...props
fullScreen, children, className,
}) {
if (!fullScreen) {
return (
<div className={`spinner-wrapper ${className || "my-3 text-center"}`} {...props}>
<div className={`spinner-wrapper ${className || "my-3 text-center"}`}>
<SpinnerElement>{children}</SpinnerElement>
</div>
);
}
return (
<div className="spinner-fs-wrapper" {...props}>
<div className="spinner-fs-wrapper">
<div className="spinner-fs-background">
<SpinnerElement>{children}</SpinnerElement>
</div>

View File

@ -18,12 +18,12 @@ exports[`<Checkbox/> Render checkbox 1`] = `
for="1"
>
Test label
<small
class="form-text text-muted"
>
Some help text
</small>
</label>
<small
class="form-text text-muted"
>
Some help text
</small>
</div>
</div>
`;
@ -45,12 +45,12 @@ exports[`<Checkbox/> Render uncheked checkbox 1`] = `
for="1"
>
Test label
<small
class="form-text text-muted"
>
Some help text
</small>
</label>
<small
class="form-text text-muted"
>
Some help text
</small>
</div>
</div>
`;

View File

@ -7,7 +7,12 @@
// API
export {
useAPIGet, useAPIPost, useAPIPatch, useAPIPut, useAPIDelete,
useAPIGet,
useAPIPost,
useAPIPatch,
useAPIPut,
useAPIDelete,
useAPIPolling,
} from "api/hooks";
export { API_STATE } from "api/utils";
@ -70,4 +75,4 @@ export {
} from "validations";
// Alert context
export { AlertContext, AlertContextProvider, useAlert } from "alertContext/AlertContext";
export { AlertContextProvider, useAlert } from "alertContext/AlertContext";

View File

@ -7,11 +7,11 @@
import React from "react";
import { AlertContext } from "../alertContext/AlertContext";
const mockSetAlert = jest.fn();
const mockDismissAlert = jest.fn();
window.AlertContext = React.createContext();
function AlertContextMock({ children }) {
return (
<AlertContext.Provider value={[mockSetAlert, mockDismissAlert]}>

View File

@ -14,7 +14,7 @@ import { ErrorMessage } from "./ErrorMessage";
function withEither(conditionalFn, Either) {
return (Component) => (props) => {
if (conditionalFn(props)) {
return <Either />;
return <Either {...props} />;
}
return <Component {...props} />;
};

View File

@ -8,20 +8,21 @@ msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2019-11-14 11:13+0100\n"
"PO-Revision-Date: 2019-08-28 12:55+0000\n"
"Last-Translator: Stepan Henek <stepan+github@henek.name>\n"
"PO-Revision-Date: 2019-11-21 17:04+0000\n"
"Last-Translator: Pavel Borecki <pavel.borecki@gmail.com>\n"
"Language-Team: Czech <https://hosted.weblate.org/projects/turris/foris-js/cs/"
">\n"
"Language: cs\n"
"Language-Team: Czech <https://hosted.weblate.org/projects/turris/foris-"
"js/cs/>\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
"X-Generator: Weblate 3.10-dev\n"
"Generated-By: Babel 2.7.0\n"
#: src/validations.js:13
msgid "This is not a valid IPv4 address."
msgstr "Tohle není platná IPv4 adresa."
msgstr "Toto není platná IPv4 adresa."
#: src/validations.js:14
msgid "This is not a valid IPv6 address."
@ -29,11 +30,11 @@ msgstr "Tohle není platná IPv6 adresa."
#: src/validations.js:15
msgid "This is not a valid IPv6 prefix."
msgstr "Tohle není platný IPv6 prefix."
msgstr "Toto není platný IPv6 prefix."
#: src/validations.js:16
msgid "This is not a valid domain name."
msgstr "Tohle není platné doménové jméno."
msgstr "Toto není platné doménové jméno."
#: src/validations.js:17
msgid "This is not a valid DUID."
@ -41,7 +42,7 @@ msgstr "Tohle není platné DUID."
#: src/validations.js:18
msgid "This is not a valid MAC address."
msgstr "Tohle není platná MAC adresa."
msgstr "Toto není platná MAC adresa."
#: src/validations.js:19
msgid "Doesn't contain a list of emails separated by commas."
@ -49,27 +50,27 @@ msgstr "Neobsahuje seznam e-mailů oddělených čárkou."
#: src/api/utils.js:58
msgid "The session is expired. Please log in again."
msgstr ""
msgstr "Platnost relace skončila. Přihlaste se znovu."
#: src/api/utils.js:63
msgid "Timeout error occurred."
msgstr ""
msgstr "Došlo k chybě kvůli překročení časového limitu."
#: src/api/utils.js:66
msgid "No response received."
msgstr ""
msgstr "Neobdržena žádná odezva."
#: src/api/utils.js:70
msgid "An unknown error occurred. Check the console for more info."
msgstr ""
msgstr "Došlo k neznámé chybě. Další informace naleznete v konzoli."
#: src/api/utils.js:77
msgid "An unknown API error occurred."
msgstr ""
msgstr "Došlo k neznámé chybě v aplikačním programovém rozhraní."
#: src/form/components/ForisForm.js:88
msgid "Settings saved successfully"
msgstr ""
msgstr "Nastavení úspěšně uložena"
#: src/form/components/ForisForm.js:140
msgid "Changes you made may not be saved. Are you sure you want to leave?"
@ -91,11 +92,10 @@ msgstr "Uložit"
#: src/utils/ErrorMessage.js:13
msgid "An error occurred while fetching data."
msgstr ""
msgstr "Došlo k chybě při získávání dat."
#~ msgid "Settings were successfully saved."
#~ msgstr "Nastavení bylo úspěšně uloženo."
#~ msgid "Settings update was failed."
#~ msgstr "Ukládání nastavení selhalo."

View File

@ -0,0 +1,90 @@
# Translations template for PROJECT.
# Copyright (C) 2019 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2019.
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2019-11-14 11:13+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.7.0\n"
#: src/validations.js:13
msgid "This is not a valid IPv4 address."
msgstr ""
#: src/validations.js:14
msgid "This is not a valid IPv6 address."
msgstr ""
#: src/validations.js:15
msgid "This is not a valid IPv6 prefix."
msgstr ""
#: src/validations.js:16
msgid "This is not a valid domain name."
msgstr ""
#: src/validations.js:17
msgid "This is not a valid DUID."
msgstr ""
#: src/validations.js:18
msgid "This is not a valid MAC address."
msgstr ""
#: src/validations.js:19
msgid "Doesn't contain a list of emails separated by commas."
msgstr ""
#: src/api/utils.js:58
msgid "The session is expired. Please log in again."
msgstr ""
#: src/api/utils.js:63
msgid "Timeout error occurred."
msgstr ""
#: src/api/utils.js:66
msgid "No response received."
msgstr ""
#: src/api/utils.js:70
msgid "An unknown error occurred. Check the console for more info."
msgstr ""
#: src/api/utils.js:77
msgid "An unknown API error occurred."
msgstr ""
#: src/form/components/ForisForm.js:88
msgid "Settings saved successfully"
msgstr ""
#: src/form/components/ForisForm.js:140
msgid "Changes you made may not be saved. Are you sure you want to leave?"
msgstr ""
#: src/form/components/SubmitButton.js:32
msgid "Updating"
msgstr ""
#: src/form/components/SubmitButton.js:35
msgid "Load settings"
msgstr ""
#: src/form/components/SubmitButton.js:38
msgid "Save"
msgstr ""
#: src/utils/ErrorMessage.js:13
msgid "An error occurred while fetching data."
msgstr ""