import { FormGroup, Switch, TextInput } from "@patternfly/react-core"; import { useTranslation } from "react-i18next"; import React, { useEffect } from "react"; import { HelpItem } from "../../components/help-enabler/HelpItem"; import { useForm, Controller } from "react-hook-form"; import { convertToFormValues } from "../../util"; import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation"; import { FormAccess } from "../../components/form-access/FormAccess"; import { useAdminClient, asyncStateFetch, } from "../../context/auth/AdminClient"; import { useParams } from "react-router-dom"; import { WizardSectionHeader } from "../../components/wizard-section-header/WizardSectionHeader"; export type LdapSettingsSynchronizationProps = { showSectionHeading?: boolean; showSectionDescription?: boolean; }; export const LdapSettingsSynchronization = ({ showSectionHeading = false, showSectionDescription = false, }: LdapSettingsSynchronizationProps) => { const { t } = useTranslation("user-federation"); const helpText = useTranslation("user-federation-help").t; const adminClient = useAdminClient(); const { register, control, setValue } = useForm(); const { id } = useParams<{ id: string }>(); const setupForm = (component: ComponentRepresentation) => { Object.entries(component).map((entry) => { if (entry[0] === "config") { convertToFormValues(entry[1], "config", setValue); } else { setValue(entry[0], entry[1]); } }); }; useEffect(() => { return asyncStateFetch( () => adminClient.components.findOne({ id }), (fetchedComponent) => setupForm(fetchedComponent) ); }, []); return ( <> {showSectionHeading && ( )} } fieldId="kc-import-users" > ( )} > } fieldId="kc-batch-size" > } fieldId="kc-periodic-full-sync" > } fieldId="kc-periodic-changed-users-sync" hasNoPaddingTop > ); };