import React, { useState } from "react"; import { AlertVariant, Button, ButtonVariant, Form, FormGroup, Modal, ModalVariant, Select, SelectOption, SelectVariant, Switch, TextInput, } from "@patternfly/react-core"; import { useTranslation } from "react-i18next"; import { Controller, useForm } from "react-hook-form"; import { useAdminClient } from "../context/auth/AdminClient"; import { useAlerts } from "../components/alert/Alerts"; import type ComponentRepresentation from "@keycloak/keycloak-admin-client/lib/defs/componentRepresentation"; import { HelpItem } from "../components/help-enabler/HelpItem"; import { useServerInfo } from "../context/server-info/ServerInfoProvider"; import { KEY_PROVIDER_TYPE } from "../util"; type RSAGeneratedModalProps = { providerType: string; handleModalToggle: () => void; refresh: () => void; open: boolean; }; export const RSAGeneratedModal = ({ providerType, handleModalToggle, open, refresh, }: RSAGeneratedModalProps) => { const { t } = useTranslation("realm-settings"); const serverInfo = useServerInfo(); const adminClient = useAdminClient(); const { addAlert, addError } = useAlerts(); const { handleSubmit, control } = useForm({}); const [isKeySizeDropdownOpen, setIsKeySizeDropdownOpen] = useState(false); const [isRSAalgDropdownOpen, setIsRSAalgDropdownOpen] = useState(false); const allComponentTypes = serverInfo.componentTypes?.[KEY_PROVIDER_TYPE] ?? []; const save = async (component: ComponentRepresentation) => { try { await adminClient.components.create({ ...component, parentId: component.parentId, providerId: providerType, providerType: KEY_PROVIDER_TYPE, config: { priority: ["0"] }, }); handleModalToggle(); addAlert(t("saveProviderSuccess"), AlertVariant.success); refresh(); } catch (error) { addError("realm-settings:saveProviderError", error); } }; return ( {t("common:Add")} , , ]} >
} > ( { onChange(value); }} data-testid="display-name-input" > )} /> } > ( { onChange([value + ""]); }} /> )} /> } > ( { onChange([value + ""]); }} /> )} /> {providerType === "rsa-generated" && ( <> } > ( )} /> } > ( )} /> )}
); };