From a1d612f40146bda6f1725f42122d58e45867fd94 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Thu, 14 Sep 2023 14:34:13 +0200 Subject: [PATCH 1/2] changed to validators fixes: #23180 --- js/apps/admin-ui/src/user/components/OptionsComponent.tsx | 2 +- js/apps/admin-ui/src/user/components/UserProfileGroup.tsx | 2 +- js/libs/keycloak-admin-client/src/defs/userProfileConfig.ts | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/js/apps/admin-ui/src/user/components/OptionsComponent.tsx b/js/apps/admin-ui/src/user/components/OptionsComponent.tsx index 8fce15ee239d..df003c492802 100644 --- a/js/apps/admin-ui/src/user/components/OptionsComponent.tsx +++ b/js/apps/admin-ui/src/user/components/OptionsComponent.tsx @@ -11,7 +11,7 @@ export const OptionComponent = (attr: UserProfileAttribute) => { const isMultiSelect = type.includes("multiselect"); const Component = isMultiSelect ? Checkbox : Radio; - const options = (attr.validations?.options as Options).options || []; + const options = (attr.validators?.options as Options).options || []; return ( diff --git a/js/apps/admin-ui/src/user/components/UserProfileGroup.tsx b/js/apps/admin-ui/src/user/components/UserProfileGroup.tsx index 7b40e6bf5a8d..dc65af354e5f 100644 --- a/js/apps/admin-ui/src/user/components/UserProfileGroup.tsx +++ b/js/apps/admin-ui/src/user/components/UserProfileGroup.tsx @@ -13,7 +13,7 @@ export type UserProfileFieldsProps = UserProfileAttribute & { const isRequired = (attribute: UserProfileAttribute) => Object.keys(attribute.required || {}).length !== 0 || - ((attribute.validations?.length?.min as number) || 0) > 0; + (((attribute.validators?.length as LengthValidator)?.min as number) || 0) > 0; export const UserProfileGroup = ({ children, diff --git a/js/libs/keycloak-admin-client/src/defs/userProfileConfig.ts b/js/libs/keycloak-admin-client/src/defs/userProfileConfig.ts index 1ba7c3b828ef..acee0007ccd6 100644 --- a/js/libs/keycloak-admin-client/src/defs/userProfileConfig.ts +++ b/js/libs/keycloak-admin-client/src/defs/userProfileConfig.ts @@ -8,6 +8,7 @@ export default interface UserProfileConfig { export interface UserProfileAttribute { name?: string; validations?: Record>; + validators?: Record; annotations?: Record; required?: UserProfileAttributeRequired; readOnly?: boolean; From 0011a1158d54a4bd863cbe26c85c65df5e5bcaae Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Mon, 2 Oct 2023 16:07:24 +0200 Subject: [PATCH 2/2] fixed merge error --- js/apps/admin-ui/src/user/components/UserProfileGroup.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/apps/admin-ui/src/user/components/UserProfileGroup.tsx b/js/apps/admin-ui/src/user/components/UserProfileGroup.tsx index dc65af354e5f..80e7541f55e2 100644 --- a/js/apps/admin-ui/src/user/components/UserProfileGroup.tsx +++ b/js/apps/admin-ui/src/user/components/UserProfileGroup.tsx @@ -11,6 +11,12 @@ export type UserProfileFieldsProps = UserProfileAttribute & { roles?: string[]; }; +type LengthValidator = + | { + min: number; + } + | undefined; + const isRequired = (attribute: UserProfileAttribute) => Object.keys(attribute.required || {}).length !== 0 || (((attribute.validators?.length as LengthValidator)?.min as number) || 0) > 0;