diff --git a/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/identity_providers/CreateProviderPage.ts b/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/identity_providers/CreateProviderPage.ts index 266d2da3de..fd81a94f0c 100644 --- a/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/identity_providers/CreateProviderPage.ts +++ b/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/identity_providers/CreateProviderPage.ts @@ -5,7 +5,7 @@ export default class CreateProviderPage { #clientSecretField = "clientSecret"; #displayName = "displayName"; #discoveryEndpoint = "discoveryEndpoint"; - #authorizationUrl = "authorizationUrl"; + #authorizationUrl = "config.authorizationUrl"; #addButton = "createProvider"; #saveButton = "idp-details-save"; #ssoServiceUrl = "sso-service-url"; 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 b5aae37e1e..d70fdd615c 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 @@ -79,10 +79,10 @@ export default class ProviderBaseGeneralSettingsPage extends PageObject { #saveBtn = "idp-details-save"; #revertBtn = "idp-details-revert"; - #validateSignature = "#validateSignature"; - #jwksSwitch = "#useJwksUrl"; - #jwksUrl = "jwksUrl"; - #pkceSwitch = "#pkceEnabled"; + #validateSignature = "#config\\.validateSignature"; + #jwksSwitch = "#config\\.useJwksUrl"; + #jwksUrl = "config.jwksUrl"; + #pkceSwitch = "#config\\.pkceEnabled"; #pkceMethod = "#pkceMethod"; #clientAuth = "#clientAuthentication"; #clientAssertionSigningAlg = "#clientAssertionSigningAlg"; @@ -347,9 +347,8 @@ export default class ProviderBaseGeneralSettingsPage extends PageObject { public assertOIDCUrl(url: string) { cy.findByTestId("jump-link-openid-connect-settings").click(); - cy.findByTestId(url + "Url") - .clear() - .type("invalidUrl"); + cy.findByTestId(`config.${url}Url`).clear(); + cy.findByTestId(`config.${url}Url`).type("invalidUrl"); this.clickSaveBtn(); masthead.checkNotificationMessage( "Could not update the provider The url [" + url + "_url] is malformed", diff --git a/js/apps/admin-ui/src/identity-providers/add/DiscoverySettings.tsx b/js/apps/admin-ui/src/identity-providers/add/DiscoverySettings.tsx index 659da332aa..de8124e2e6 100644 --- a/js/apps/admin-ui/src/identity-providers/add/DiscoverySettings.tsx +++ b/js/apps/admin-ui/src/identity-providers/add/DiscoverySettings.tsx @@ -1,22 +1,10 @@ import IdentityProviderRepresentation from "@keycloak/keycloak-admin-client/lib/defs/identityProviderRepresentation"; -import { - ExpandableSection, - FormGroup, - Select, - SelectOption, - SelectVariant, - ValidatedOptions, -} from "@patternfly/react-core"; +import { ExpandableSection } from "@patternfly/react-core"; import { useState } from "react"; -import { Controller, useFormContext, useWatch } from "react-hook-form"; +import { useFormContext, useWatch } from "react-hook-form"; import { useTranslation } from "react-i18next"; - -import { HelpItem } from "ui-shared"; -import { KeycloakTextArea } from "../../components/keycloak-text-area/KeycloakTextArea"; -import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput"; -import { FormGroupField } from "../component/FormGroupField"; -import { SwitchField } from "../component/SwitchField"; -import { TextField } from "../component/TextField"; +import { SelectControl, TextAreaControl, TextControl } from "ui-shared"; +import { DefaultSwitchControl } from "../../components/SwitchControl"; import "./discovery-settings.css"; @@ -28,12 +16,7 @@ type DiscoverySettingsProps = { const Fields = ({ readOnly }: DiscoverySettingsProps) => { const { t } = useTranslation(); - const [pkceMethodOpen, setPkceMethodOpen] = useState(false); - const { - register, - control, - formState: { errors }, - } = useFormContext(); + const { control } = useFormContext(); const validateSignature = useWatch({ control, @@ -50,152 +33,93 @@ const Fields = ({ readOnly }: DiscoverySettingsProps) => { return (
- - - - - + - - - - - - + + {validateSignature === "true" && ( <> - {useJwks === "true" ? ( - ) : ( <> - - - - + )} )} - {isPkceEnabled === "true" && ( - - } - fieldId="pkceMethod" - > - ( - - )} - /> - + labelIcon={t("pkceMethodHelp")} + controller={{ + defaultValue: PKCE_METHODS[0], + }} + options={PKCE_METHODS.map((option) => ({ + key: option, + value: t(`${option}`), + }))} + /> )}
); diff --git a/js/apps/admin-ui/src/identity-providers/add/OIDCGeneralSettings.tsx b/js/apps/admin-ui/src/identity-providers/add/OIDCGeneralSettings.tsx index a77e1af828..917bbef64e 100644 --- a/js/apps/admin-ui/src/identity-providers/add/OIDCGeneralSettings.tsx +++ b/js/apps/admin-ui/src/identity-providers/add/OIDCGeneralSettings.tsx @@ -1,54 +1,33 @@ -import { FormGroup, ValidatedOptions } from "@patternfly/react-core"; -import { useWatch, useFormContext } from "react-hook-form"; +import { useFormContext, useWatch } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { useParams } from "react-router-dom"; - -import { HelpItem } from "ui-shared"; -import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput"; +import { TextControl } from "ui-shared"; import { DisplayOrder } from "../component/DisplayOrder"; import { RedirectUrl } from "../component/RedirectUrl"; -import { TextField } from "../component/TextField"; import type { IdentityProviderParams } from "../routes/IdentityProvider"; export const OIDCGeneralSettings = () => { const { t } = useTranslation(); const { tab } = useParams(); - const { - register, - control, - formState: { errors }, - } = useFormContext(); - + const { control } = useFormContext(); const alias = useWatch({ control, name: "alias" }); return ( <> - } - fieldId="alias" - isRequired - validated={ - errors.alias ? ValidatedOptions.error : ValidatedOptions.default - } - helperTextInvalid={t("required")} - > - - + labelIcon={t("aliasHelp")} + readOnly={tab === "settings"} + rules={{ + required: t("required"), + }} + /> - + ); diff --git a/js/apps/admin-ui/src/identity-providers/add/SamlConnectSettings.tsx b/js/apps/admin-ui/src/identity-providers/add/SamlConnectSettings.tsx index ad5541f185..3111906b03 100644 --- a/js/apps/admin-ui/src/identity-providers/add/SamlConnectSettings.tsx +++ b/js/apps/admin-ui/src/identity-providers/add/SamlConnectSettings.tsx @@ -3,11 +3,9 @@ import type IdentityProviderRepresentation from "@keycloak/keycloak-admin-client import { FormGroup, Title } from "@patternfly/react-core"; import { useFormContext } from "react-hook-form"; import { useTranslation } from "react-i18next"; -import { HelpItem } from "ui-shared"; - +import { HelpItem, TextControl } from "ui-shared"; import { adminClient } from "../../admin-client"; import { FileUploadForm } from "../../components/json-file-upload/FileUploadForm"; -import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput"; import { useRealm } from "../../context/realm-context/RealmContext"; import environment from "../../environment"; import { addTrailingSlash } from "../../util"; @@ -26,7 +24,6 @@ export const SamlConnectSettings = () => { const { realm } = useRealm(); const { setValue, - register, setError, clearErrors, formState: { errors }, @@ -81,27 +78,15 @@ export const SamlConnectSettings = () => { {t("samlSettings")} - - } - isRequired - helperTextInvalid={t("required")} - validated={errors.config?.entityId ? "error" : "default"} - > - - + labelIcon={t("serviceProviderEntityIdHelp")} + defaultValue={`${environment.authServerUrl}/realms/${realm}`} + rules={{ + required: t("required"), + }} + /> - } - fieldId="alias" - isRequired - validated={ - errors.alias ? ValidatedOptions.error : ValidatedOptions.default - } - helperTextInvalid={t("required")} - > - - - - + + - {isAliasReadonly ? ( + {isAliasReadonly && ( - ) : null} + )} ); }; diff --git a/js/libs/ui-shared/src/controls/SelectControl.tsx b/js/libs/ui-shared/src/controls/SelectControl.tsx index b900c35233..6d0671a615 100644 --- a/js/libs/ui-shared/src/controls/SelectControl.tsx +++ b/js/libs/ui-shared/src/controls/SelectControl.tsx @@ -44,7 +44,7 @@ export const SelectControl = < label, options, controller, - variant, + variant = SelectVariant.single, labelIcon, ...rest }: SelectControlProps) => { diff --git a/js/libs/ui-shared/src/controls/TextAreaControl.tsx b/js/libs/ui-shared/src/controls/TextAreaControl.tsx index 86955ef651..c42bf24ba2 100644 --- a/js/libs/ui-shared/src/controls/TextAreaControl.tsx +++ b/js/libs/ui-shared/src/controls/TextAreaControl.tsx @@ -1,4 +1,4 @@ -import { ValidatedOptions } from "@patternfly/react-core"; +import { TextAreaProps, ValidatedOptions } from "@patternfly/react-core"; import { FieldPath, FieldValues, @@ -13,11 +13,12 @@ import { KeycloakTextArea } from "./keycloak-text-area/KeycloakTextArea"; export type TextAreaControlProps< T extends FieldValues, P extends FieldPath = FieldPath, -> = UseControllerProps & { - label: string; - labelIcon?: string; - isDisabled?: boolean; -}; +> = UseControllerProps & + TextAreaProps & { + label: string; + labelIcon?: string; + isDisabled?: boolean; + }; export const TextAreaControl = < T extends FieldValues,