From 96841f8d5bbf1806b95493f3cc2e72f5dea855ff Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Tue, 5 Mar 2024 18:02:07 +0100 Subject: [PATCH] Port client login settings to new form controls (#27414) Signed-off-by: Jon Koops --- .../cypress/e2e/clients_saml_test.spec.ts | 12 +- .../manage/clients/CreateClientPage.ts | 14 +- .../client_details/tabs/SettingsTab.ts | 6 +- .../src/clients/add/AccessSettings.tsx | 23 +--- .../src/clients/add/LoginSettings.tsx | 124 ++++-------------- 5 files changed, 50 insertions(+), 129 deletions(-) diff --git a/js/apps/admin-ui/cypress/e2e/clients_saml_test.spec.ts b/js/apps/admin-ui/cypress/e2e/clients_saml_test.spec.ts index 93130eda0f..4b29d96489 100644 --- a/js/apps/admin-ui/cypress/e2e/clients_saml_test.spec.ts +++ b/js/apps/admin-ui/cypress/e2e/clients_saml_test.spec.ts @@ -167,18 +167,18 @@ describe("Clients SAML tests", () => { const homeUrlError = "Client could not be updated: Base URL is not a valid URL"; - cy.get("#kc-root-url").type("Invalid URL"); + cy.findByTestId("rootUrl").type("Invalid URL"); settingsTab.clickSaveBtn(); masthead.checkNotificationMessage(rootUrlError); - cy.get("#kc-root-url").clear(); + cy.findByTestId("rootUrl").clear(); - cy.get("#kc-home-url").type("Invalid URL"); + cy.findByTestId("baseUrl").type("Invalid URL"); settingsTab.clickSaveBtn(); masthead.checkNotificationMessage(homeUrlError); - cy.get("#kc-home-url").clear(); + cy.findByTestId("baseUrl").clear(); - cy.get("#kc-root-url").type(validUrl); - cy.get("#kc-home-url").type(validUrl); + cy.findByTestId("rootUrl").type(validUrl); + cy.findByTestId("baseUrl").type(validUrl); settingsTab.clickSaveBtn(); masthead.checkNotificationMessage("Client successfully updated"); diff --git a/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/clients/CreateClientPage.ts b/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/clients/CreateClientPage.ts index 39e64bb5d0..4dabc0f0fb 100644 --- a/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/clients/CreateClientPage.ts +++ b/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/clients/CreateClientPage.ts @@ -25,11 +25,11 @@ export default class CreateClientPage extends CommonPage { #deviceAuthGrantChkBx = "#kc-oauth-device-authorization-grant"; #serviceAccountRolesChkBx = "#kc-flow-service-account"; - #rootUrlInput = "#kc-root-url"; - #homeUrlInput = "#kc-home-url"; + #rootUrlInput = "rootUrl"; + #homeUrlInput = "baseUrl"; #firstValidRedirectUrlInput = "redirectUris0"; #firstWebOriginsInput = "webOrigins0"; - #adminUrlInput = "#kc-admin-url"; + #adminUrlInput = "adminUrl"; #loginThemeDrpDwn = "#loginTheme"; #loginThemeList = 'ul[aria-label="Login theme"]'; @@ -227,12 +227,12 @@ export default class CreateClientPage extends CommonPage { } checkAccessSettingsElements() { - cy.get(this.#adminUrlInput).scrollIntoView(); - cy.get(this.#rootUrlInput).should("not.be.disabled"); - cy.get(this.#homeUrlInput).should("not.be.disabled"); + cy.findByTestId(this.#adminUrlInput).scrollIntoView(); + cy.findByTestId(this.#rootUrlInput).should("not.be.disabled"); + cy.findByTestId(this.#homeUrlInput).should("not.be.disabled"); cy.findByTestId(this.#firstValidRedirectUrlInput).should("not.be.disabled"); cy.findByTestId(this.#firstWebOriginsInput).should("not.be.disabled"); - cy.get(this.#adminUrlInput).should("not.be.disabled"); + cy.findByTestId(this.#adminUrlInput).should("not.be.disabled"); return this; } diff --git a/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/clients/client_details/tabs/SettingsTab.ts b/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/clients/client_details/tabs/SettingsTab.ts index 0331c6958c..c8c916ad67 100644 --- a/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/clients/client_details/tabs/SettingsTab.ts +++ b/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/clients/client_details/tabs/SettingsTab.ts @@ -35,9 +35,9 @@ export default class SettingsTab extends PageObject { #redirectUris = "redirectUris"; - #idpInitiatedSsoUrlName = "idpInitiatedSsoUrlName"; - #idpInitiatedSsoRelayState = "idpInitiatedSsoRelayState"; - #masterSamlProcessingUrl = "masterSamlProcessingUrl"; + #idpInitiatedSsoUrlName = "attributes.saml_idp_initiated_sso_url_name"; + #idpInitiatedSsoRelayState = "attributes.saml_idp_initiated_sso_relay_state"; + #masterSamlProcessingUrl = "adminUrl"; public clickSaveBtn() { cy.findByTestId(this.#saveBtn).click(); diff --git a/js/apps/admin-ui/src/clients/add/AccessSettings.tsx b/js/apps/admin-ui/src/clients/add/AccessSettings.tsx index fddfb6b455..53c3a5d508 100644 --- a/js/apps/admin-ui/src/clients/add/AccessSettings.tsx +++ b/js/apps/admin-ui/src/clients/add/AccessSettings.tsx @@ -1,11 +1,9 @@ -import { FormGroup } from "@patternfly/react-core"; import { useFormContext } from "react-hook-form"; import { useTranslation } from "react-i18next"; +import { TextControl } from "ui-shared"; -import { HelpItem } from "ui-shared"; import { FixedButtonsGroup } from "../../components/form/FixedButtonGroup"; import { FormAccess } from "../../components/form/FormAccess"; -import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput"; import { useAccess } from "../../context/access/Access"; import { FormFields } from "../ClientDetails"; import type { ClientSettingsProps } from "../ClientSettings"; @@ -17,7 +15,7 @@ export const AccessSettings = ({ reset, }: ClientSettingsProps) => { const { t } = useTranslation(); - const { register, watch } = useFormContext(); + const { watch } = useFormContext(); const { hasAccess } = useAccess(); const isManager = hasAccess("manage-clients") || client.access?.configure; @@ -32,19 +30,12 @@ export const AccessSettings = ({ > {!client.bearerOnly && } {protocol !== "saml" && ( - - } - > - - + labelIcon={t("adminURLHelp")} + /> )} {client.bearerOnly && ( { const { t } = useTranslation(); - const { register, watch } = useFormContext(); - const { realm } = useRealm(); - - const idpInitiatedSsoUrlName: string = watch( - "attributes.saml_idp_initiated_sso_url_name", - ); + const { watch } = useFormContext(); const standardFlowEnabled = watch("standardFlowEnabled"); + return ( <> - - } - > - - - + - } - > - - + labelIcon={t("homeURLHelp")} + /> {standardFlowEnabled && ( <> - {" "} + )} {protocol === "saml" && ( <> - - } - helperText={ - idpInitiatedSsoUrlName !== "" && - t("idpInitiatedSsoUrlNameHelp", { - url: `${environment.authServerUrl}/realms/${realm}/protocol/saml/clients/${idpInitiatedSsoUrlName}`, - }) - } - > - - - + - } - > - - - + - } - > - - + labelIcon={t("masterSamlProcessingUrlHelp")} + /> )} {protocol !== "saml" && standardFlowEnabled && ( @@ -179,7 +110,6 @@ export const LoginSettings = ({ name="webOrigins" aria-label={t("webOrigins")} addButtonLabel="addWebOrigins" - {...rest} /> )}