reset form when provider / mapperPype changes (#26971)

fixes: #26697

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
Erik Jan de Wit 2024-02-27 10:05:24 +01:00 committed by GitHub
parent 562decde35
commit dfd3fee95a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -24,7 +24,10 @@ import { HelpItem } from "ui-shared";
import { adminClient } from "../../../admin-client";
import { useAlerts } from "../../../components/alert/Alerts";
import { useConfirmDialog } from "../../../components/confirm-dialog/ConfirmDialog";
import { DynamicComponents } from "../../../components/dynamic/DynamicComponents";
import {
DynamicComponents,
convertToName,
} from "../../../components/dynamic/DynamicComponents";
import { FormAccess } from "../../../components/form/FormAccess";
import { KeycloakSpinner } from "../../../components/keycloak-spinner/KeycloakSpinner";
import { KeycloakTextInput } from "../../../components/keycloak-text-input/KeycloakTextInput";
@ -302,7 +305,18 @@ export default function LdapMapperDetails() {
}
isOpen={isMapperDropdownOpen}
onSelect={(_, value) => {
field.onChange(value as string);
setupForm({
providerId: value as string,
...Object.fromEntries(
components
.find((c) => c.id === value)
?.properties.filter((m) => m.type === "List")
.map((m) => [
convertToName(m.name!),
m.options?.[0],
]) || [],
),
});
setIsMapperDropdownOpen(false);
}}
selections={field.value}