From 3e46810b37160d643a0f82b014781bf41966aecd Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Wed, 6 Mar 2024 10:26:25 +0100 Subject: [PATCH] Port regex client authorization policy to new form controls (#27569) Signed-off-by: Jon Koops --- .../e2e/client_authorization_test.spec.ts | 2 +- .../clients/authorization/policy/Regex.tsx | 87 ++++--------------- 2 files changed, 18 insertions(+), 71 deletions(-) diff --git a/js/apps/admin-ui/cypress/e2e/client_authorization_test.spec.ts b/js/apps/admin-ui/cypress/e2e/client_authorization_test.spec.ts index abb28fba5e..f7dfadf2d8 100644 --- a/js/apps/admin-ui/cypress/e2e/client_authorization_test.spec.ts +++ b/js/apps/admin-ui/cypress/e2e/client_authorization_test.spec.ts @@ -117,7 +117,7 @@ describe("Client authentication subtab", () => { name: "Regex policy", description: "Policy for regex", targetClaim: "I don't know", - regexPattern: ".*?", + pattern: ".*?", }) .formUtils() .save(); diff --git a/js/apps/admin-ui/src/clients/authorization/policy/Regex.tsx b/js/apps/admin-ui/src/clients/authorization/policy/Regex.tsx index 365f5efe48..94a8036a21 100644 --- a/js/apps/admin-ui/src/clients/authorization/policy/Regex.tsx +++ b/js/apps/admin-ui/src/clients/authorization/policy/Regex.tsx @@ -1,83 +1,30 @@ import { useTranslation } from "react-i18next"; -import { Controller, useFormContext } from "react-hook-form"; -import { Checkbox, FormGroup } from "@patternfly/react-core"; - -import { HelpItem } from "ui-shared"; -import { KeycloakTextInput } from "../../../components/keycloak-text-input/KeycloakTextInput"; +import { SwitchControl, TextControl } from "ui-shared"; export const Regex = () => { const { t } = useTranslation(); - const { - control, - register, - formState: { errors }, - } = useFormContext(); return ( <> - - } - > - - - + - } - isRequired - validated={errors.pattern ? "error" : "default"} - helperTextInvalid={t("required")} - > - - - + - } - > - ( - - )} - /> - + labelIcon={t("targetContextAttributesHelp")} + labelOn={t("yes")} + labelOff={t("no")} + /> ); };