import { Button, ButtonVariant, Form, FormGroup, Modal, ModalVariant, Text, TextContent, } from "@patternfly/react-core"; import { Controller, FormProvider, useForm, useWatch } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { SelectControl } from "@keycloak/keycloak-ui-shared"; import { FileUpload } from "../../components/json-file-upload/patternfly/FileUpload"; import { useServerInfo } from "../../context/server-info/ServerInfoProvider"; import { StoreSettings } from "./StoreSettings"; type ImportKeyDialogProps = { toggleDialog: () => void; save: (importFile: ImportFile) => void; }; export type ImportFile = { keystoreFormat: string; keyAlias: string; storePassword: string; file: { value?: string; filename: string }; }; export const ImportKeyDialog = ({ save, toggleDialog, }: ImportKeyDialogProps) => { const { t } = useTranslation(); const form = useForm(); const { control, handleSubmit } = form; const baseFormats = useServerInfo().cryptoInfo?.supportedKeystoreTypes ?? []; const formats = baseFormats.concat([ "Certificate PEM", "Public Key PEM", "JSON Web Key Set", ]); const format = useWatch({ control, name: "keystoreFormat", defaultValue: formats[0], }); return ( { handleSubmit((importFile) => { save(importFile); toggleDialog(); })(); }} > {t("import")} , , ]} > {t("generateKeysDescription")}
{baseFormats.includes(format) && } ( field.onChange({ value, filename }) } /> )} />
); };