import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { Controller, FormProvider, useForm } from "react-hook-form"; import { ActionGroup, Button, ClipboardCopy, FormGroup, PageSection, Select, SelectOption, SelectVariant, Stack, StackItem, Switch, } from "@patternfly/react-core"; import type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation"; import { addTrailingSlash, convertAttributeNameToForm, convertToFormValues, } from "../util"; import useIsFeatureEnabled, { Feature } from "../utils/useIsFeatureEnabled"; import { useAdminClient } from "../context/auth/AdminClient"; import { useRealm } from "../context/realm-context/RealmContext"; import { FormAccess } from "../components/form-access/FormAccess"; import { HelpItem } from "../components/help-enabler/HelpItem"; import { FormattedLink } from "../components/external-link/FormattedLink"; import { KeycloakTextInput } from "../components/keycloak-text-input/KeycloakTextInput"; import { KeyValueInput } from "../components/key-value-form/KeyValueInput"; type RealmSettingsGeneralTabProps = { realm: RealmRepresentation; save: (realm: RealmRepresentation) => void; }; export const RealmSettingsGeneralTab = ({ realm, save, }: RealmSettingsGeneralTabProps) => { const { t } = useTranslation("realm-settings"); const { adminClient } = useAdminClient(); const { realm: realmName } = useRealm(); const form = useForm({ shouldUnregister: false }); const { register, control, handleSubmit, setValue, formState: { isDirty }, } = form; const isFeatureEnabled = useIsFeatureEnabled(); const [open, setOpen] = useState(false); const requireSslTypes = ["all", "external", "none"]; const setupForm = () => { convertToFormValues(realm, setValue); if (realm.attributes?.["acr.loa.map"]) { const result = Object.entries( JSON.parse(realm.attributes["acr.loa.map"]) ).flatMap(([key, value]) => ({ key, value })); result.concat({ key: "", value: "" }); setValue(convertAttributeNameToForm("attributes.acr.loa.map"), result); } }; useEffect(setupForm, []); return ( ( {value} )} /> } > } > ( )} /> } > } fieldId="kc-user-managed-access" > ( )} /> {isFeatureEnabled(Feature.DeclarativeUserProfile) && ( } fieldId="kc-user-profile-enabled" > ( onChange(value.toString())} /> )} /> )} } fieldId="kc-endpoints" > ); };