import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { Control, Controller } from "react-hook-form"; import { ActionGroup, Button, FormGroup, Select, SelectOption, SelectVariant, } from "@patternfly/react-core"; import { FormAccess } from "../../components/form-access/FormAccess"; import { HelpItem } from "../../components/help-enabler/HelpItem"; import { useServerInfo } from "../../context/server-info/ServerInfoProvider"; import { sortProviders } from "../../util"; type FineGrainOpenIdConnectProps = { control: Control>; save: () => void; reset: () => void; }; export const FineGrainOpenIdConnect = ({ control, save, reset, }: FineGrainOpenIdConnectProps) => { const { t } = useTranslation("clients"); const providers = useServerInfo().providers; const clientSignatureProviders = providers?.clientSignature.providers; const contentEncryptionProviders = providers?.contentencryption.providers; const cekManagementProviders = providers?.cekmanagement.providers; const signatureProviders = providers?.signature.providers; const [accessTokenOpen, setAccessTokenOpen] = useState(false); const [idTokenOpen, setIdTokenOpen] = useState(false); const [idTokenKeyManagementOpen, setIdTokenKeyManagementOpen] = useState( false ); const [idTokenContentOpen, setIdTokenContentOpen] = useState(false); const [userInfoSignedResponseOpen, setUserInfoSignedResponseOpen] = useState( false ); const [requestObjectSignatureOpen, setRequestObjectSignatureOpen] = useState( false ); const [requestObjectRequiredOpen, setRequestObjectRequiredOpen] = useState( false ); const keyOptions = [ {t("common:choose")} , ...sortProviders(clientSignatureProviders!).map((p) => ( )), ]; const cekManagementOptions = [ {t("common:choose")} , ...sortProviders(cekManagementProviders!).map((p) => ( )), ]; const signatureOptions = [ {t("unsigned")} , ...sortProviders(signatureProviders!).map((p) => ( )), ]; const contentOptions = [ {t("common:choose")} , ...sortProviders(contentEncryptionProviders!).map((p) => ( )), ]; const requestObjectOptions = [ {t("any")} , {t("none")} , ...sortProviders(clientSignatureProviders!).map((p) => ( )), ]; const requestObjectRequiredOptions = [ "not required", "request or request_uri", "request only", "request_uri only", ].map((p) => ( {t(`requestObject.${p}`)} )); const selectOptionToString = (value: string, options: JSX.Element[]) => { const selectOption = options.find((s) => s.props.value === value); return selectOption?.props.children || selectOption?.props.value; }; return ( } > ( )} /> } > ( )} /> } > ( )} /> } > ( )} /> } > ( )} /> } > ( )} /> } > ( )} /> ); };