import React from "react"; import { useTranslation } from "react-i18next"; import { Controller, useForm } from "react-hook-form"; import { ActionGroup, Button, Dropdown, DropdownToggle, Form, FormGroup, Select, SelectOption, SelectVariant, TextInput, } from "@patternfly/react-core"; import type PolicyProviderRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyProviderRepresentation"; import useToggle from "../../utils/useToggle"; import "./search-dropdown.css"; export type SearchForm = { name?: string; resource?: string; scope?: string; type?: string; }; type SearchDropdownProps = { types?: PolicyProviderRepresentation[]; onSearch: (form: SearchForm) => void; }; export const SearchDropdown = ({ types, onSearch }: SearchDropdownProps) => { const { t } = useTranslation("clients"); const { register, control, formState: { isDirty }, handleSubmit, } = useForm({ mode: "onChange" }); const [open, toggle] = useToggle(); const [typeOpen, toggleType] = useToggle(); const submit = (form: SearchForm) => { toggle(); onSearch(form); }; const typeOptions = (value: string) => [ {t("allTypes")} , ...(types || []).map((type) => ( {type.name} )), ]; return ( {t("searchForPermission")} } isOpen={open} >
( )} />
); };