From cc594aa00c90998d0c11fa27e78fa8a8062854db Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Wed, 20 Apr 2022 16:38:29 +0200 Subject: [PATCH] Added labels for loa properties (#2411) --- .../components/ExecutionConfigModal.tsx | 44 +++++++------------ src/components/dynamic/labels.ts | 6 +++ 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/authentication/components/ExecutionConfigModal.tsx b/src/authentication/components/ExecutionConfigModal.tsx index 8d3ccc78cb..a49aee2cca 100644 --- a/src/authentication/components/ExecutionConfigModal.tsx +++ b/src/authentication/components/ExecutionConfigModal.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; -import { useForm } from "react-hook-form"; +import { FormProvider, useForm } from "react-hook-form"; import { ActionGroup, AlertVariant, @@ -22,9 +22,11 @@ import type { ExpandableExecution } from "../execution-model"; import { useAdminClient, useFetch } from "../../context/auth/AdminClient"; import { useAlerts } from "../../components/alert/Alerts"; import { HelpItem } from "../../components/help-enabler/HelpItem"; +import { DynamicComponents } from "../../components/dynamic/DynamicComponents"; type ExecutionConfigModalForm = { - [index: string]: string; + alias: string; + config: { [index: string]: string }; }; type ExecutionConfigModalProps = { @@ -43,12 +45,13 @@ export const ExecutionConfigModal = ({ const [configDescription, setConfigDescription] = useState(); + const form = useForm(); const { register, setValue, handleSubmit, formState: { errors }, - } = useForm(); + } = form; const setupForm = ( configDescription: AuthenticatorConfigInfoRepresentation, @@ -57,7 +60,7 @@ export const ExecutionConfigModal = ({ configDescription.properties!.map( (property: ConfigPropertyRepresentation) => { setValue( - property.name!, + `config.${property.name}`, config?.config?.[property.name!] || property.defaultValue || "" ); } @@ -98,20 +101,20 @@ export const ExecutionConfigModal = ({ if (config) { const newConfig = { ...config, - config: changedConfig, + config: changedConfig.config, }; await adminClient.authenticationManagement.updateConfig(newConfig); - setConfig(newConfig); + setConfig({ ...newConfig.config }); } else { const newConfig = { id: execution.id!, alias: changedConfig.alias, - config: changedConfig, + config: changedConfig.config, }; const { id } = await adminClient.authenticationManagement.createConfig( newConfig ); - setConfig({ ...newConfig, id }); + setConfig({ ...newConfig.config, id, alias: newConfig.alias }); } addAlert(t("configSaveSuccess"), AlertVariant.success); setShow(false); @@ -166,26 +169,11 @@ export const ExecutionConfigModal = ({ } /> - {configDescription.properties?.map((property) => ( - - } - > - - - ))} + + +