import type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation"; import { ActionGroup, Button, ClipboardCopy, FormGroup, PageSection, Select, SelectOption, SelectVariant, Stack, StackItem, Switch, } from "@patternfly/react-core"; import { useEffect, useState } from "react"; import { Controller, FormProvider, useForm } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { HelpItem } from "ui-shared"; import { adminClient } from "../admin-client"; import { FormattedLink } from "../components/external-link/FormattedLink"; import { FormAccess } from "../components/form/FormAccess"; import { KeyValueInput } from "../components/key-value-form/KeyValueInput"; import { KeycloakTextInput } from "../components/keycloak-text-input/KeycloakTextInput"; import { useRealm } from "../context/realm-context/RealmContext"; import { addTrailingSlash, convertAttributeNameToForm, convertToFormValues, } from "../util"; import useIsFeatureEnabled, { Feature } from "../utils/useIsFeatureEnabled"; type RealmSettingsGeneralTabProps = { realm: RealmRepresentation; save: (realm: RealmRepresentation) => void; }; type FormFields = Omit; export const RealmSettingsGeneralTab = ({ realm, save, }: RealmSettingsGeneralTabProps) => { const { t } = useTranslation("realm-settings"); const { realm: realmName } = useRealm(); const form = useForm(); const { register, control, handleSubmit, setValue, formState: { isDirty, errors }, } = 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") as any, result ); } }; useEffect(setupForm, []); return ( ( {field.value} )} /> } > } > ( )} /> } > } fieldId="kc-user-managed-access" > ( )} /> {isFeatureEnabled(Feature.DeclarativeUserProfile) && ( } fieldId="kc-user-profile-enabled" > ( field.onChange(value.toString())} aria-label={t("userProfileEnabled")} /> )} /> )} } fieldId="kc-endpoints" > ); };