diff --git a/apps/admin-ui/src/clients/keys/GenerateKeyDialog.tsx b/apps/admin-ui/src/clients/keys/GenerateKeyDialog.tsx index 72e65cf947..1853e33e6b 100644 --- a/apps/admin-ui/src/clients/keys/GenerateKeyDialog.tsx +++ b/apps/admin-ui/src/clients/keys/GenerateKeyDialog.tsx @@ -34,15 +34,23 @@ type GenerateKeyDialogProps = { type KeyFormProps = { useFile?: boolean; isSaml?: boolean; + hasPem?: boolean; }; -export const KeyForm = ({ isSaml = false, useFile = false }: KeyFormProps) => { +const CERT_PEM = "Certificate PEM" as const; + +export const KeyForm = ({ + isSaml = false, + hasPem = false, + useFile = false, +}: KeyFormProps) => { const { t } = useTranslation("clients"); const [filename, setFilename] = useState(); const [openArchiveFormat, setOpenArchiveFormat] = useState(false); - const { control } = useFormContext(); + const { control, watch } = useFormContext(); + const format = watch("format"); return (
@@ -73,13 +81,15 @@ export const KeyForm = ({ isSaml = false, useFile = false }: KeyFormProps) => { aria-label={t("archiveFormat")} isOpen={openArchiveFormat} > - {["JKS", "PKCS12"].map((option) => ( - - ))} + {["JKS", "PKCS12"] + .concat(hasPem ? CERT_PEM : []) + .map((option) => ( + + ))} )} /> @@ -114,7 +124,9 @@ export const KeyForm = ({ isSaml = false, useFile = false }: KeyFormProps) => { /> )} - + {format !== CERT_PEM && ( + + )} ); }; diff --git a/apps/admin-ui/src/clients/keys/SamlImportKeyDialog.tsx b/apps/admin-ui/src/clients/keys/SamlImportKeyDialog.tsx index e514d064de..250ab5badf 100644 --- a/apps/admin-ui/src/clients/keys/SamlImportKeyDialog.tsx +++ b/apps/admin-ui/src/clients/keys/SamlImportKeyDialog.tsx @@ -49,7 +49,7 @@ export const SamlImportKeyDialog = ({ }} > - + );