Fall back to IdentityProvider component type if present (#21320)

Closes #15344
This commit is contained in:
Erik Jan de Wit 2023-07-11 14:41:52 +02:00 committed by GitHub
parent ac31c54fda
commit 982bac9db6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,13 +28,24 @@ export default function AddIdentityProvider() {
const { providerId } = useParams<IdentityProviderCreateParams>(); const { providerId } = useParams<IdentityProviderCreateParams>();
const form = useForm<IdentityProviderRepresentation>(); const form = useForm<IdentityProviderRepresentation>();
const serverInfo = useServerInfo(); const serverInfo = useServerInfo();
const providerInfo = useMemo(
() => const providerInfo = useMemo(() => {
serverInfo.componentTypes?.[ const namespaces = [
"org.keycloak.broker.social.SocialIdentityProvider" "org.keycloak.broker.social.SocialIdentityProvider",
]?.find((p) => p.id === providerId), "org.keycloak.broker.provider.IdentityProvider",
[serverInfo, providerId] ];
);
for (const namespace of namespaces) {
const social = serverInfo.componentTypes?.[namespace]?.find(
({ id }) => id === providerId
);
if (social) {
return social;
}
}
}, [serverInfo, providerId]);
const { const {
handleSubmit, handleSubmit,
formState: { isDirty }, formState: { isDirty },