mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2024-11-14 17:35:35 +01:00
Merge branch 'disable-form-prompt' into 'dev'
Prompt as an optional element of ForisForm. See merge request turris/reforis/foris-js!77
This commit is contained in:
commit
2d375b1690
|
@ -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}
|
||||
>
|
||||
<WiFiForm hasGuestNetwork={hasGuestNetwork} />
|
||||
</ForisForm>
|
||||
|
|
|
@ -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 (
|
||||
<div className={formFieldsSize}>
|
||||
<Prompt message={getMessageOnLeavingPage} />
|
||||
{hasPrompt && <Prompt message={getMessageOnLeavingPage} />}
|
||||
<form onSubmit={onSubmit}>
|
||||
{childrenWithFormProps}
|
||||
<div className="text-right">
|
||||
|
|
Loading…
Reference in New Issue
Block a user