From 78bdf2d2ecfd706cecbc4387afefc3197c73caa9 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Tue, 29 Mar 2022 09:49:43 +0200 Subject: [PATCH] don't test ldap when form isn't valid (#2294) * don't test ldap when form isn't valid fixes: #1776 * changed to PF way of showing errors * Update src/user-federation/kerberos/KerberosSettingsRequired.tsx Co-authored-by: Jenny <32821331+jenny-s51@users.noreply.github.com> * Update src/user-federation/kerberos/KerberosSettingsRequired.tsx Co-authored-by: Jenny <32821331+jenny-s51@users.noreply.github.com> * Update src/user-federation/kerberos/KerberosSettingsRequired.tsx Co-authored-by: Jenny <32821331+jenny-s51@users.noreply.github.com> Co-authored-by: Jenny <32821331+jenny-s51@users.noreply.github.com> --- .../attribute/AttributeGeneralSettings.tsx | 6 +- .../kerberos/KerberosSettingsRequired.tsx | 36 ++++---- .../ldap/LdapSettingsConnection.tsx | 23 +++-- .../ldap/LdapSettingsGeneral.tsx | 6 +- .../ldap/LdapSettingsKerberosIntegration.tsx | 36 ++++---- .../ldap/LdapSettingsSearching.tsx | 86 ++++++++++++------- src/user-federation/user-federation.css | 4 - 7 files changed, 118 insertions(+), 79 deletions(-) diff --git a/src/realm-settings/user-profile/attribute/AttributeGeneralSettings.tsx b/src/realm-settings/user-profile/attribute/AttributeGeneralSettings.tsx index fefb77d513..9b5b0423a1 100644 --- a/src/realm-settings/user-profile/attribute/AttributeGeneralSettings.tsx +++ b/src/realm-settings/user-profile/attribute/AttributeGeneralSettings.tsx @@ -65,6 +65,8 @@ export const AttributeGeneralSettings = () => { } fieldId="kc-attribute-name" isRequired + validated={form.errors.name ? "error" : "default"} + helperTextInvalid={form.errors.name?.message} > { }, })} data-testid="attribute-name" + validated={form.errors.name ? "error" : "default"} /> - {form.errors.name && ( -
{form.errors.name.message}
- )} {/* These hidden fields are required so data object written back matches data retrieved */} - {form.errors.name && ( -
{form.errors.name.message}
- )}
- {form.errors.config?.kerberosRealm?.[0] && ( -
- {form.errors.config.kerberosRealm[0].message} -
- )}
- {form.errors.config?.serverPrincipal?.[0] && ( -
- {form.errors.config.serverPrincipal[0].message} -
- )}
- {form.errors.config?.keyTab?.[0] && ( -
{form.errors.config.keyTab[0].message}
- )}
{ + if (!(await form.trigger())) return; try { const settings = convertFormToSettings(form); await adminClient.realms.testLDAPConnection( @@ -113,6 +114,10 @@ export const LdapSettingsConnection = ({ } fieldId="kc-console-connection-url" isRequired + validated={ + form.errors.config?.connectionUrl?.[0] ? "error" : "default" + } + helperTextInvalid={form.errors.config?.connectionUrl?.[0].message} > - {form.errors.config?.connectionUrl?.[0] && ( -
- {form.errors.config.connectionUrl[0].message} -
- )}
diff --git a/src/user-federation/ldap/LdapSettingsGeneral.tsx b/src/user-federation/ldap/LdapSettingsGeneral.tsx index 13c331b2f0..68a8726d55 100644 --- a/src/user-federation/ldap/LdapSettingsGeneral.tsx +++ b/src/user-federation/ldap/LdapSettingsGeneral.tsx @@ -113,6 +113,8 @@ export const LdapSettingsGeneral = ({ } fieldId="kc-console-display-name" isRequired + validated={form.errors.name ? "error" : "default"} + helperTextInvalid={form.errors.name?.message} > {/* These hidden fields are required so data object written back matches data retrieved */}