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-admin/lib/defs/componentRepresentation"; import { HelpItem } from "../components/help-enabler/HelpItem"; import { useServerInfo } from "../context/server-info/ServerInfoProvider"; 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 } = useAlerts(); const { handleSubmit, control } = useForm({}); const [isKeySizeDropdownOpen, setIsKeySizeDropdownOpen] = useState(false); const [isRSAalgDropdownOpen, setIsRSAalgDropdownOpen] = useState(false); const allComponentTypes = serverInfo.componentTypes?.["org.keycloak.keys.KeyProvider"] ?? []; const save = async (component: ComponentRepresentation) => { try { await adminClient.components.create({ ...component, parentId: component.parentId, providerId: providerType, providerType: "org.keycloak.keys.KeyProvider", }); handleModalToggle(); addAlert(t("saveProviderSuccess"), AlertVariant.success); refresh(); } catch (error) { addAlert( t("saveProviderError", { error: error.response?.data?.errorMessage || error, }), AlertVariant.danger ); } }; return ( {t("common:Add")} , , ]} >
} > ( { onChange(value); }} data-testid="display-name-input" > )} /> } > ( { onChange([value + ""]); }} /> )} /> } > ( { onChange([value + ""]); }} /> )} /> {providerType === "rsa-generated" && ( <> } > ( )} /> } > ( )} /> )}
); };