import type ComponentRepresentation from "@keycloak/keycloak-admin-client/lib/defs/componentRepresentation"; import { Button, Form } from "@patternfly/react-core"; import { useFormContext } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { useNavigate } from "react-router-dom"; import { ScrollForm } from "../components/scroll-form/ScrollForm"; import { useRealm } from "../context/realm-context/RealmContext"; import useIsFeatureEnabled, { Feature } from "../utils/useIsFeatureEnabled"; import { LdapSettingsAdvanced } from "./ldap/LdapSettingsAdvanced"; import { LdapSettingsConnection } from "./ldap/LdapSettingsConnection"; import { LdapSettingsGeneral } from "./ldap/LdapSettingsGeneral"; import { LdapSettingsKerberosIntegration } from "./ldap/LdapSettingsKerberosIntegration"; import { LdapSettingsSearching } from "./ldap/LdapSettingsSearching"; import { LdapSettingsSynchronization } from "./ldap/LdapSettingsSynchronization"; import { toUserFederation } from "./routes/UserFederation"; import { SettingsCache } from "./shared/SettingsCache"; import { FixedButtonsGroup } from "../components/form/FixedButtonGroup"; export type LdapComponentRepresentation = ComponentRepresentation & { config?: { periodicChangedUsersSync?: boolean; periodicFullSync?: boolean; }; }; export type UserFederationLdapFormProps = { id?: string; onSubmit: (formData: LdapComponentRepresentation) => void; }; export const UserFederationLdapForm = ({ id, onSubmit, }: UserFederationLdapFormProps) => { const { t } = useTranslation(); const form = useFormContext(); const navigate = useNavigate(); const { realm } = useRealm(); const isFeatureEnabled = useIsFeatureEnabled(); return ( <> , }, { title: t("connectionAndAuthenticationSettings"), panel: , }, { title: t("ldapSearchingAndUpdatingSettings"), panel: , }, { title: t("synchronizationSettings"), panel: , }, { title: t("kerberosIntegration"), panel: , isHidden: !isFeatureEnabled(Feature.Kerberos), }, { title: t("cacheSettings"), panel: }, { title: t("advancedSettings"), panel: , }, ]} />
); }; export function serializeFormData( formData: LdapComponentRepresentation, ): LdapComponentRepresentation { const { config } = formData; if (config?.periodicChangedUsersSync !== undefined) { if (config.periodicChangedUsersSync === false) { config.changedSyncPeriod = ["-1"]; } delete config.periodicChangedUsersSync; } if (config?.periodicFullSync !== undefined) { if (config.periodicFullSync === false) { config.fullSyncPeriod = ["-1"]; } delete config.periodicFullSync; } return formData; }