Activate Save Button in Client Scopes on first modification (#30269)
Signed-off-by: Ahana Mallik <ahanamallik@gmail.com>
This commit is contained in:
parent
75925dcf6c
commit
51d80a42d5
1 changed files with 8 additions and 2 deletions
|
@ -33,6 +33,7 @@ export const ScopeForm = ({ clientScope, save }: ScopeFormProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const form = useForm<ClientScopeDefaultOptionalType>({ mode: "onChange" });
|
const form = useForm<ClientScopeDefaultOptionalType>({ mode: "onChange" });
|
||||||
const { control, handleSubmit, setValue, formState } = form;
|
const { control, handleSubmit, setValue, formState } = form;
|
||||||
|
const { isDirty, isValid } = formState;
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
|
|
||||||
const providers = useLoginProviders();
|
const providers = useLoginProviders();
|
||||||
|
@ -60,12 +61,12 @@ export const ScopeForm = ({ clientScope, save }: ScopeFormProps) => {
|
||||||
"attributes.dynamic.scope.regexp",
|
"attributes.dynamic.scope.regexp",
|
||||||
),
|
),
|
||||||
append ? `${value}:*` : value,
|
append ? `${value}:*` : value,
|
||||||
|
{ shouldDirty: true }, // Mark the field as dirty when we modify the field
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
convertToFormValues(clientScope ?? {}, setValue);
|
convertToFormValues(clientScope ?? {}, setValue);
|
||||||
}, [clientScope]);
|
}, [clientScope]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormAccess
|
<FormAccess
|
||||||
role="manage-clients"
|
role="manage-clients"
|
||||||
|
@ -187,7 +188,12 @@ export const ScopeForm = ({ clientScope, save }: ScopeFormProps) => {
|
||||||
min={0}
|
min={0}
|
||||||
/>
|
/>
|
||||||
<ActionGroup>
|
<ActionGroup>
|
||||||
<FormSubmitButton formState={formState}>{t("save")}</FormSubmitButton>
|
<FormSubmitButton
|
||||||
|
formState={formState}
|
||||||
|
disabled={!isDirty || !isValid}
|
||||||
|
>
|
||||||
|
{t("save")}
|
||||||
|
</FormSubmitButton>
|
||||||
<Button
|
<Button
|
||||||
variant="link"
|
variant="link"
|
||||||
component={(props) => (
|
component={(props) => (
|
||||||
|
|
Loading…
Reference in a new issue