import React from "react"; import { ActionGroup, Button, TextInput } from "@patternfly/react-core"; import { useFieldArray, UseFormMethods } from "react-hook-form"; import "./RealmRolesSection.css"; import RoleRepresentation from "keycloak-admin/lib/defs/roleRepresentation"; import { TableComposable, Tbody, Td, Th, Thead, Tr, } from "@patternfly/react-table"; import { MinusCircleIcon, PlusCircleIcon } from "@patternfly/react-icons"; import { useTranslation } from "react-i18next"; import { FormAccess } from "../components/form-access/FormAccess"; export type KeyValueType = { key: string; value: string }; type RoleAttributesProps = { form: UseFormMethods; save: (role: RoleRepresentation) => void; reset: () => void; }; export const RoleAttributes = ({ form, save, reset }: RoleAttributesProps) => { const { t } = useTranslation("roles"); const { fields, append, remove } = useFieldArray({ control: form.control, name: "attributes", }); const columns = ["Key", "Value"]; const onAdd = () => { append({ key: "", value: "" }); }; return ( <> {columns[0]} {columns[1]} {fields.map((attribute, rowIndex) => ( {rowIndex !== fields.length - 1 && fields.length - 1 !== 0 && ( )} {rowIndex === fields.length - 1 && ( ); };