disable button after submit-method is triggered and rename state 'valid' to 'changed' as it does not check validity

This commit is contained in:
Maren Süwer
2019-01-11 08:31:00 +01:00
parent f96b16bda4
commit 7fc8c1a905

View File

@@ -24,7 +24,7 @@ type State = {
loginAttemptLimitTimeout: boolean,
loginAttemptLimit: boolean
},
valid: boolean
changed: boolean
};
class ConfigForm extends React.Component<Props, State> {
@@ -61,7 +61,7 @@ class ConfigForm extends React.Component<Props, State> {
loginAttemptLimitTimeout: false,
loginAttemptLimit: false
},
valid: false
changed: false
};
}
@@ -77,6 +77,9 @@ class ConfigForm extends React.Component<Props, State> {
submit = (event: Event) => {
event.preventDefault();
this.setState({
changed: false
});
this.props.submitForm(this.state.config);
};
@@ -158,7 +161,9 @@ class ConfigForm extends React.Component<Props, State> {
<SubmitButton
loading={loading}
label={t("config-form.submit")}
disabled={!configUpdatePermission || this.hasError() || !this.state.valid}
disabled={
!configUpdatePermission || this.hasError() || !this.state.changed
}
/>
</form>
);
@@ -175,7 +180,7 @@ class ConfigForm extends React.Component<Props, State> {
...this.state.error,
[name]: !isValid
},
valid: true
changed: true
});
};