Skip to content

Commit

Permalink
added loading state so that attribute form only initializes once
Browse files Browse the repository at this point in the history
fixes: keycloak#35914
Signed-off-by: Erik Jan de Wit <[email protected]>
  • Loading branch information
edewit committed Dec 19, 2024
1 parent 69cf0e8 commit 83381bd
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import type ComponentRepresentation from "@keycloak/keycloak-admin-client/lib/defs/componentRepresentation";
import { TextControl, useAlerts, useFetch } from "@keycloak/keycloak-ui-shared";
import {
KeycloakSpinner,
TextControl,
useAlerts,
useFetch,
} from "@keycloak/keycloak-ui-shared";
import {
ActionGroup,
AlertVariant,
Expand All @@ -23,6 +28,7 @@ import { SettingsCache } from "../shared/SettingsCache";
import { SyncSettings } from "./SyncSettings";

import "./custom-provider-settings.css";
import { useState } from "react";

export default function CustomProviderSettings() {
const { adminClient } = useAdminClient();
Expand All @@ -42,6 +48,7 @@ export default function CustomProviderSettings() {

const { addAlert, addError } = useAlerts();
const { realm: realmName, realmRepresentation: realm } = useRealm();
const [loading, setLoading] = useState(true);

const provider = (
useServerInfo().componentTypes?.[
Expand All @@ -62,6 +69,7 @@ export default function CustomProviderSettings() {
} else if (id) {
throw new Error(t("notFound"));
}
setLoading(false);
},
[],
);
Expand Down Expand Up @@ -100,6 +108,8 @@ export default function CustomProviderSettings() {
}
};

if (loading) return <KeycloakSpinner />;

return (
<FormProvider {...form}>
<ExtendedHeader provider={providerId} save={() => handleSubmit(save)()} />
Expand Down

0 comments on commit 83381bd

Please sign in to comment.