1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2024-07-05 20:53:12 +00:00

Prompt as an optional element of ForisForm.

This commit is contained in:
Maciej Lenartowicz 2020-01-14 15:00:17 +01:00
parent e5cbbc9019
commit 75bfbb88ae
No known key found for this signature in database
GPG Key ID: 1ABD2CB41B59B8E4
4 changed files with 10 additions and 4 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "foris", "name": "foris",
"version": "3.1.2", "version": "3.2.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "foris", "name": "foris",
"version": "3.1.2", "version": "3.2.0",
"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": {

View File

@ -17,10 +17,11 @@ WiFiSettings.propTypes = {
endpoint: PropTypes.string.isRequired, endpoint: PropTypes.string.isRequired,
resetEndpoint: PropTypes.string.isRequired, resetEndpoint: PropTypes.string.isRequired,
hasGuestNetwork: PropTypes.bool, hasGuestNetwork: PropTypes.bool,
hasPrompt: PropTypes.bool,
}; };
export function WiFiSettings({ export function WiFiSettings({
ws, endpoint, resetEndpoint, hasGuestNetwork, ws, endpoint, resetEndpoint, hasGuestNetwork, hasPrompt,
}) { }) {
return ( return (
<> <>
@ -33,6 +34,7 @@ export function WiFiSettings({
prepData={prepData} prepData={prepData}
prepDataToSubmit={prepDataToSubmit} prepDataToSubmit={prepDataToSubmit}
validator={validator} validator={validator}
hasPrompt={hasPrompt}
> >
<WiFiForm hasGuestNetwork={hasGuestNetwork} /> <WiFiForm hasGuestNetwork={hasGuestNetwork} />
</ForisForm> </ForisForm>

View File

@ -48,6 +48,8 @@ ForisForm.propTypes = {
validator: PropTypes.func.isRequired, validator: PropTypes.func.isRequired,
/** Disables form */ /** Disables form */
disabled: PropTypes.bool, disabled: PropTypes.bool,
/** If true user will be prompted before leaving the page containing form. */
hasPrompt: PropTypes.bool,
/** reForis form components. */ /** reForis form components. */
children: PropTypes.node.isRequired, children: PropTypes.node.isRequired,
/** Optional override of form submit callback */ /** Optional override of form submit callback */
@ -71,6 +73,7 @@ ForisForm.defaultProps = {
postCallback: () => undefined, postCallback: () => undefined,
validator: () => undefined, validator: () => undefined,
disabled: false, disabled: false,
hasPrompt: true,
}; };
/** Serves as HOC for all foris forms components. */ /** Serves as HOC for all foris forms components. */
@ -82,6 +85,7 @@ export function ForisForm({
postCallback, postCallback,
validator, validator,
disabled, disabled,
hasPrompt,
onSubmitOverridden, onSubmitOverridden,
children, children,
}) { }) {
@ -156,7 +160,7 @@ export function ForisForm({
return ( return (
<div className={formFieldsSize}> <div className={formFieldsSize}>
<Prompt message={getMessageOnLeavingPage} /> {hasPrompt && <Prompt message={getMessageOnLeavingPage} />}
<form onSubmit={onSubmit}> <form onSubmit={onSubmit}>
{childrenWithFormProps} {childrenWithFormProps}
<div className="text-right"> <div className="text-right">