From b4d001bd827aeb031bf789b48452d62ece92ba49 Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Wed, 7 Dec 2022 10:03:38 +0100 Subject: [PATCH] Use `react-hook-form` v7 for search dropdown form (#3955) --- .../clients/authorization/SearchDropdown.tsx | 46 ++++++++----------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/apps/admin-ui/src/clients/authorization/SearchDropdown.tsx b/apps/admin-ui/src/clients/authorization/SearchDropdown.tsx index b61df20a2d..a5ba5dd0fc 100644 --- a/apps/admin-ui/src/clients/authorization/SearchDropdown.tsx +++ b/apps/admin-ui/src/clients/authorization/SearchDropdown.tsx @@ -1,6 +1,4 @@ -import { useEffect } from "react"; -import { useTranslation } from "react-i18next"; -import { Controller, useForm } from "react-hook-form"; +import type PolicyProviderRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyProviderRepresentation"; import { ActionGroup, Button, @@ -12,10 +10,12 @@ import { SelectOption, SelectVariant, } from "@patternfly/react-core"; +import { useEffect } from "react"; +import { Controller, useForm } from "react-hook-form-v7"; +import { useTranslation } from "react-i18next"; -import type PolicyProviderRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyProviderRepresentation"; -import useToggle from "../../utils/useToggle"; import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput"; +import useToggle from "../../utils/useToggle"; import "./search-dropdown.css"; @@ -24,6 +24,8 @@ export type SearchForm = { resource?: string; scope?: string; type?: string; + uri?: string; + owner?: string; }; type SearchDropdownProps = { @@ -58,7 +60,7 @@ export const SearchDropdown = ({ useEffect(() => reset(search), [search]); - const typeOptions = (value: string) => [ + const typeOptions = (value?: string) => [ {t("allTypes")} , @@ -94,40 +96,32 @@ export const SearchDropdown = ({ > {isResource && ( <> @@ -135,21 +129,17 @@ export const SearchDropdown = ({ {!isResource && ( )} {!isResource && ( @@ -158,21 +148,21 @@ export const SearchDropdown = ({ name="type" defaultValue="" control={control} - render={({ onChange, value }) => ( + render={({ field }) => ( )} />