From 75bfbb88ae5582349b6f7a5627d814aaf2a12a31 Mon Sep 17 00:00:00 2001 From: Maciej Lenartowicz Date: Tue, 14 Jan 2020 15:00:17 +0100 Subject: [PATCH] Prompt as an optional element of ForisForm. --- package-lock.json | 2 +- package.json | 2 +- src/common/WiFiSettings/WiFiSettings.js | 4 +++- src/form/components/ForisForm.js | 6 +++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 64c719c..64899fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "foris", - "version": "3.1.2", + "version": "3.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 682f730..1d40b81 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "foris", - "version": "3.1.2", + "version": "3.2.0", "description": "Set of components and utils for Foris and its plugins.", "author": "CZ.NIC, z.s.p.o.", "repository": { diff --git a/src/common/WiFiSettings/WiFiSettings.js b/src/common/WiFiSettings/WiFiSettings.js index ded5214..ef68e26 100644 --- a/src/common/WiFiSettings/WiFiSettings.js +++ b/src/common/WiFiSettings/WiFiSettings.js @@ -17,10 +17,11 @@ WiFiSettings.propTypes = { endpoint: PropTypes.string.isRequired, resetEndpoint: PropTypes.string.isRequired, hasGuestNetwork: PropTypes.bool, + hasPrompt: PropTypes.bool, }; export function WiFiSettings({ - ws, endpoint, resetEndpoint, hasGuestNetwork, + ws, endpoint, resetEndpoint, hasGuestNetwork, hasPrompt, }) { return ( <> @@ -33,6 +34,7 @@ export function WiFiSettings({ prepData={prepData} prepDataToSubmit={prepDataToSubmit} validator={validator} + hasPrompt={hasPrompt} > diff --git a/src/form/components/ForisForm.js b/src/form/components/ForisForm.js index c09edc5..2c86f9a 100644 --- a/src/form/components/ForisForm.js +++ b/src/form/components/ForisForm.js @@ -48,6 +48,8 @@ ForisForm.propTypes = { validator: PropTypes.func.isRequired, /** Disables form */ disabled: PropTypes.bool, + /** If true user will be prompted before leaving the page containing form. */ + hasPrompt: PropTypes.bool, /** reForis form components. */ children: PropTypes.node.isRequired, /** Optional override of form submit callback */ @@ -71,6 +73,7 @@ ForisForm.defaultProps = { postCallback: () => undefined, validator: () => undefined, disabled: false, + hasPrompt: true, }; /** Serves as HOC for all foris forms components. */ @@ -82,6 +85,7 @@ export function ForisForm({ postCallback, validator, disabled, + hasPrompt, onSubmitOverridden, children, }) { @@ -156,7 +160,7 @@ export function ForisForm({ return (
- + {hasPrompt && }
{childrenWithFormProps}