diff --git a/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/identity_providers/ProviderBaseAdvancedSettingsPage.ts b/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/identity_providers/ProviderBaseAdvancedSettingsPage.ts index e3622fe1b8..0769455851 100644 --- a/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/identity_providers/ProviderBaseAdvancedSettingsPage.ts +++ b/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/identity_providers/ProviderBaseAdvancedSettingsPage.ts @@ -84,7 +84,7 @@ export default class ProviderBaseGeneralSettingsPage extends PageObject { #jwksUrl = "config.jwksUrl"; #pkceSwitch = "#config\\.pkceEnabled"; #pkceMethod = "#pkceMethod"; - #clientAuth = "#clientAuthentication"; + #clientAuth = "#clientAuthMethod"; #clientAssertionSigningAlg = "#clientAssertionSigningAlg"; #clientAssertionAudienceInput = "#clientAssertionAudience"; #jwtX509HeadersSwitch = "#jwtX509HeadersEnabled"; diff --git a/js/apps/admin-ui/src/authentication/components/EditFlow.tsx b/js/apps/admin-ui/src/authentication/components/EditFlow.tsx index 210884dedc..06d71f22c4 100644 --- a/js/apps/admin-ui/src/authentication/components/EditFlow.tsx +++ b/js/apps/admin-ui/src/authentication/components/EditFlow.tsx @@ -84,7 +84,7 @@ export const EditFlow = ({ execution, onRowChange }: EditFlowProps) => { name="displayName" label={t("name")} labelIcon={t("flowNameHelp")} - rules={{ required: { value: true, message: t("required") } }} + rules={{ required: t("required") }} /> { name="alias" label={t("name")} labelIcon={t("flowNameHelp")} - rules={{ required: { value: true, message: t("required") } }} + rules={{ required: t("required") }} /> { value: CIBA_EXPIRES_IN_MAX, message: t("lessThan", { value: CIBA_EXPIRES_IN_MAX }), }, - required: { - value: true, - message: t("required"), - }, + required: t("required"), }} /> { value: CIBA_INTERVAL_MAX, message: t("lessThan", { value: CIBA_INTERVAL_MAX }), }, - required: { - value: true, - message: t("required"), - }, + required: t("required"), }} /> { label={t("name")} labelIcon={t("scopeNameHelp")} rules={{ - required: { - value: true, - message: t("required"), - }, + required: t("required"), onChange: (e) => { if (isDynamicScopesEnabled) setDynamicRegex(e.target.validated, true); diff --git a/js/apps/admin-ui/src/clients/ClientDescription.tsx b/js/apps/admin-ui/src/clients/ClientDescription.tsx index 967f41c8c8..95722f9c7a 100644 --- a/js/apps/admin-ui/src/clients/ClientDescription.tsx +++ b/js/apps/admin-ui/src/clients/ClientDescription.tsx @@ -19,7 +19,7 @@ export const ClientDescription = ({ name="clientId" label={t("clientId")} labelIcon={t("clientIdHelp")} - rules={{ required: { value: true, message: t("required") } }} + rules={{ required: t("required") }} /> { const { t } = useTranslation(); const { control } = useFormContext(); - const [openClientAuth, setOpenClientAuth] = useState(false); - const [openClientAuthSigAlg, setOpenClientAuthSigAlg] = useState(false); const clientAuthMethod = useWatch({ control: control, @@ -35,96 +27,34 @@ export const OIDCAuthentication = ({ create = true }: { create?: boolean }) => { return ( <> - - } - fieldId="clientAuthentication" - > - ( - setOpenClientAuth(!openClientAuth)} - onSelect={(value) => { - field.onChange(value as string); - setOpenClientAuth(false); - }} - selections={field.value} - variant={SelectVariant.single} - aria-label={t("clientAuthentication")} - isOpen={openClientAuth} - > - {clientAuthentications.map((option) => ( - - {t(`clientAuthentications.${option}`)} - - ))} - - )} - /> - + labelIcon={t("clientAuthenticationHelp")} + options={clientAuthentications.map((auth) => ({ + key: auth, + value: t(`clientAuthentications.${auth}`), + }))} + controller={{ + defaultValue: clientAuthentications[0], + }} + /> - - } - fieldId="clientAssertionSigningAlg" - > - ( - setOpenClientAuthSigAlg(!openClientAuthSigAlg)} - onSelect={(value) => { - field.onChange(value.toString()); - setOpenClientAuthSigAlg(false); - }} - selections={field.value || t("algorithmNotSpecified")} - variant={SelectVariant.single} - aria-label={t("selectClientAssertionSigningAlg")} - isOpen={openClientAuthSigAlg} - > - {[ - - {t("algorithmNotSpecified")} - , - ...sortProviders(providers).map((option) => ( - - {option} - - )), - ]} - - )} - /> - + labelIcon={t("clientAssertionSigningAlgHelp")} + options={[ + { key: "", value: t("algorithmNotSpecified") }, + ...sortProviders(providers).map((p) => ({ key: p, value: p })), + ]} + controller={{ + defaultValue: "", + }} + /> {(clientAuthMethod === "private_key_jwt" || clientAuthMethod === "client_secret_jwt") && ( policies.some((policy) => policy.name === value) ? t("createClientProfileNameHelperText").toString() diff --git a/js/apps/admin-ui/src/realm-settings/user-profile/AttributesGroupForm.tsx b/js/apps/admin-ui/src/realm-settings/user-profile/AttributesGroupForm.tsx index 8c55e63d7e..220bc22a7e 100644 --- a/js/apps/admin-ui/src/realm-settings/user-profile/AttributesGroupForm.tsx +++ b/js/apps/admin-ui/src/realm-settings/user-profile/AttributesGroupForm.tsx @@ -467,10 +467,7 @@ export default function AttributesGroupForm() { labelIcon={t("nameHintHelp")} isDisabled={!!matchingGroup || editMode} rules={{ - required: { - value: true, - message: t("required"), - }, + required: t("required"), onChange: (event) => { handleAttributesGroupNameChange(event, event.target.value); }, diff --git a/js/apps/admin-ui/src/realm-settings/user-profile/attribute/AddTranslationsDialog.tsx b/js/apps/admin-ui/src/realm-settings/user-profile/attribute/AddTranslationsDialog.tsx index 872c62c6b9..5505be2e3c 100644 --- a/js/apps/admin-ui/src/realm-settings/user-profile/attribute/AddTranslationsDialog.tsx +++ b/js/apps/admin-ui/src/realm-settings/user-profile/attribute/AddTranslationsDialog.tsx @@ -332,10 +332,7 @@ export const AddTranslationsDialog = ({ label={t("translationValue")} data-testid={`translation-value-${rowIndex}`} rules={{ - required: { - value: true, - message: t("required"), - }, + required: t("required"), }} /> )} diff --git a/js/apps/admin-ui/src/user-federation/ldap/LdapSettingsSearching.tsx b/js/apps/admin-ui/src/user-federation/ldap/LdapSettingsSearching.tsx index 9498a0007e..6a39c230cd 100644 --- a/js/apps/admin-ui/src/user-federation/ldap/LdapSettingsSearching.tsx +++ b/js/apps/admin-ui/src/user-federation/ldap/LdapSettingsSearching.tsx @@ -41,7 +41,7 @@ export const LdapSettingsSearching = ({ controller={{ defaultValue: "", rules: { - required: { value: true, message: t("validateEditMode") }, + required: t("validateEditMode"), }, }} options={["", "READ_ONLY", "WRITABLE", "UNSYNCED"]} diff --git a/js/libs/ui-shared/src/controls/PasswordControl.tsx b/js/libs/ui-shared/src/controls/PasswordControl.tsx index 13c53ab64d..e866e4094d 100644 --- a/js/libs/ui-shared/src/controls/PasswordControl.tsx +++ b/js/libs/ui-shared/src/controls/PasswordControl.tsx @@ -11,6 +11,7 @@ import { UseControllerProps, useController, } from "react-hook-form"; +import { getRuleValue } from "../utils/getRuleValue"; import { FormLabel } from "./FormLabel"; import { PasswordInput, PasswordInputProps } from "./PasswordInput"; @@ -32,7 +33,7 @@ export const PasswordControl = < props: PasswordControlProps, ) => { const { labelIcon, ...rest } = props; - const required = !!props.rules?.required; + const required = !!getRuleValue(props.rules?.required); const defaultValue = props.defaultValue ?? ("" as PathValue); const { field, fieldState } = useController({ diff --git a/js/libs/ui-shared/src/controls/TextControl.tsx b/js/libs/ui-shared/src/controls/TextControl.tsx index 668ec2868b..5d4d9eede0 100644 --- a/js/libs/ui-shared/src/controls/TextControl.tsx +++ b/js/libs/ui-shared/src/controls/TextControl.tsx @@ -14,7 +14,7 @@ import { UseControllerProps, useController, } from "react-hook-form"; - +import { getRuleValue } from "../utils/getRuleValue"; import { FormLabel } from "./FormLabel"; export type TextControlProps< @@ -36,7 +36,7 @@ export const TextControl = < props: TextControlProps, ) => { const { labelIcon, helperText, ...rest } = props; - const required = !!props.rules?.required; + const required = !!getRuleValue(props.rules?.required); const defaultValue = props.defaultValue ?? ("" as PathValue); const { field, fieldState } = useController({