/* eslint-disable */ // @ts-nocheck import type PolicyProviderRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyProviderRepresentation"; import { SelectControl, TextControl } from "../../../shared/keycloak-ui-shared"; import { ActionGroup, Button, Dropdown, Form, MenuToggle, } from "../../../shared/@patternfly/react-core"; import { useEffect } from "react"; import { FormProvider, useForm } from "react-hook-form"; import { useTranslation } from "react-i18next"; import useToggle from "../../utils/useToggle"; import "./search-dropdown.css"; export type SearchForm = { name?: string; resource?: string; scope?: string; type?: string; uri?: string; owner?: string; }; type SearchDropdownProps = { types?: PolicyProviderRepresentation[] | PolicyProviderRepresentation[]; search: SearchForm; onSearch: (form: SearchForm) => void; type: "resource" | "policy" | "permission"; }; const defaultValues: SearchForm = { name: "", type: "", uri: "", owner: "", scope: "", resource: "", }; export const SearchDropdown = ({ types, search, onSearch, type, }: SearchDropdownProps) => { const { t } = useTranslation(); const form = useForm({ mode: "onChange", defaultValues }); const { reset, formState: { isDirty }, handleSubmit, } = form; const [open, toggle] = useToggle(); const submit = (form: SearchForm) => { toggle(); onSearch(form); }; useEffect(() => reset(search), [search, reset]); return ( ( {type === "resource" && t("searchClientAuthorizationResource")} {type === "policy" && t("searchClientAuthorizationPolicy")} {type === "permission" && t("searchClientAuthorizationPermission")} )} isOpen={open} >
{type === "resource" && ( <> )} {type !== "resource" && type !== "policy" && ( )} {type !== "policy" && } {type !== "resource" && ( ({ key: type!, value: name!, })), ]} /> )}
); };