Added labels for loa properties (#2411)

This commit is contained in:
Erik Jan de Wit 2022-04-20 16:38:29 +02:00 committed by GitHub
parent 324ebdaf11
commit cc594aa00c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 28 deletions

View file

@ -1,6 +1,6 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useForm } from "react-hook-form"; import { FormProvider, useForm } from "react-hook-form";
import { import {
ActionGroup, ActionGroup,
AlertVariant, AlertVariant,
@ -22,9 +22,11 @@ import type { ExpandableExecution } from "../execution-model";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient"; import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useAlerts } from "../../components/alert/Alerts"; import { useAlerts } from "../../components/alert/Alerts";
import { HelpItem } from "../../components/help-enabler/HelpItem"; import { HelpItem } from "../../components/help-enabler/HelpItem";
import { DynamicComponents } from "../../components/dynamic/DynamicComponents";
type ExecutionConfigModalForm = { type ExecutionConfigModalForm = {
[index: string]: string; alias: string;
config: { [index: string]: string };
}; };
type ExecutionConfigModalProps = { type ExecutionConfigModalProps = {
@ -43,12 +45,13 @@ export const ExecutionConfigModal = ({
const [configDescription, setConfigDescription] = const [configDescription, setConfigDescription] =
useState<AuthenticatorConfigInfoRepresentation>(); useState<AuthenticatorConfigInfoRepresentation>();
const form = useForm<ExecutionConfigModalForm>();
const { const {
register, register,
setValue, setValue,
handleSubmit, handleSubmit,
formState: { errors }, formState: { errors },
} = useForm<ExecutionConfigModalForm>(); } = form;
const setupForm = ( const setupForm = (
configDescription: AuthenticatorConfigInfoRepresentation, configDescription: AuthenticatorConfigInfoRepresentation,
@ -57,7 +60,7 @@ export const ExecutionConfigModal = ({
configDescription.properties!.map( configDescription.properties!.map(
(property: ConfigPropertyRepresentation) => { (property: ConfigPropertyRepresentation) => {
setValue( setValue(
property.name!, `config.${property.name}`,
config?.config?.[property.name!] || property.defaultValue || "" config?.config?.[property.name!] || property.defaultValue || ""
); );
} }
@ -98,20 +101,20 @@ export const ExecutionConfigModal = ({
if (config) { if (config) {
const newConfig = { const newConfig = {
...config, ...config,
config: changedConfig, config: changedConfig.config,
}; };
await adminClient.authenticationManagement.updateConfig(newConfig); await adminClient.authenticationManagement.updateConfig(newConfig);
setConfig(newConfig); setConfig({ ...newConfig.config });
} else { } else {
const newConfig = { const newConfig = {
id: execution.id!, id: execution.id!,
alias: changedConfig.alias, alias: changedConfig.alias,
config: changedConfig, config: changedConfig.config,
}; };
const { id } = await adminClient.authenticationManagement.createConfig( const { id } = await adminClient.authenticationManagement.createConfig(
newConfig newConfig
); );
setConfig({ ...newConfig, id }); setConfig({ ...newConfig.config, id, alias: newConfig.alias });
} }
addAlert(t("configSaveSuccess"), AlertVariant.success); addAlert(t("configSaveSuccess"), AlertVariant.success);
setShow(false); setShow(false);
@ -166,26 +169,11 @@ export const ExecutionConfigModal = ({
} }
/> />
</FormGroup> </FormGroup>
{configDescription.properties?.map((property) => ( <FormProvider {...form}>
<FormGroup <DynamicComponents
key={property.name} properties={configDescription.properties || []}
label={property.label}
fieldId={property.name!}
labelIcon={
<HelpItem
helpText={property.helpText}
fieldLabelId={property.name!}
/> />
} </FormProvider>
>
<TextInput
type="text"
id={property.name}
name={property.name}
ref={register}
/>
</FormGroup>
))}
<ActionGroup> <ActionGroup>
<Button data-testid="save" variant="primary" type="submit"> <Button data-testid="save" variant="primary" type="submit">
{t("common:save")} {t("common:save")}

View file

@ -7,6 +7,12 @@ export default {
roleGroup: "Use a realm role from:", roleGroup: "Use a realm role from:",
clientGroup: "Use a client role from:", clientGroup: "Use a client role from:",
selectGroup: "Select group", selectGroup: "Select group",
"loa-condition-level": "Level of Authentication (LoA)",
"loa-condition-level.tooltip":
"The number value, usually 1 or bigger, which specifies level of authentication. Condition evaluates to true if user does not yet have this authentication level and this level is requested. This level of authentication will be set to the session after the subflow, where this condition is configured, is successfully finished.",
"loa-max-age": "Max Age",
"loa-max-age.tooltip":
"Maximum age in seconds for which this level is considered valid after successful authentication. For example if this is set to 300 and user authenticated with this level and then tries to authenticate again in less than 300 second, then this level will be automatically considered as authenticated without need of user to re-authenticate. If it is set to 0, then the authenticated level is valid just for this authentication and next authentication will always need to re-authenticate. Default value is 10 hours, which is same as default SSO session timeout and it means that level is valid until end of SSO session and user doesn't need to re-authenticate.",
usermodel: { usermodel: {
prop: { prop: {
label: "Property", label: "Property",