enable save only on dirty

This commit is contained in:
mfrances 2021-03-04 11:02:33 -05:00
parent 42194dd779
commit 9dce57417c
2 changed files with 14 additions and 2 deletions

View file

@ -103,6 +103,7 @@ export const UserFederationKerberosSettings = () => {
}, []); }, []);
const setupForm = (component: ComponentRepresentation) => { const setupForm = (component: ComponentRepresentation) => {
form.reset();
Object.entries(component).map((entry) => { Object.entries(component).map((entry) => {
form.setValue( form.setValue(
"config.allowPasswordAuthentication", "config.allowPasswordAuthentication",
@ -177,7 +178,12 @@ export const UserFederationKerberosSettings = () => {
<SettingsCache form={form} showSectionHeading /> <SettingsCache form={form} showSectionHeading />
<Form onSubmit={form.handleSubmit(save)}> <Form onSubmit={form.handleSubmit(save)}>
<ActionGroup> <ActionGroup>
<Button variant="primary" type="submit" data-testid="kerberos-save"> <Button
isDisabled={!form.formState.isDirty}
variant="primary"
type="submit"
data-testid="kerberos-save"
>
{t("common:save")} {t("common:save")}
</Button> </Button>
<Button <Button

View file

@ -137,6 +137,7 @@ export const UserFederationLdapSettings = () => {
}, []); }, []);
const setupForm = (component: ComponentRepresentation) => { const setupForm = (component: ComponentRepresentation) => {
form.reset();
Object.entries(component).map((entry) => { Object.entries(component).map((entry) => {
if (entry[0] === "config") { if (entry[0] === "config") {
convertToFormValues(entry[1], "config", form.setValue); convertToFormValues(entry[1], "config", form.setValue);
@ -240,7 +241,12 @@ export const UserFederationLdapSettings = () => {
</ScrollForm> </ScrollForm>
<Form onSubmit={form.handleSubmit(save)}> <Form onSubmit={form.handleSubmit(save)}>
<ActionGroup> <ActionGroup>
<Button variant="primary" type="submit" data-testid="ldap-save"> <Button
isDisabled={!form.formState.isDirty}
variant="primary"
type="submit"
data-testid="ldap-save"
>
{t("common:save")} {t("common:save")}
</Button> </Button>
<Button <Button