import React, { useEffect, useState } from "react"; import { useHistory } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { Button, PageSection } from "@patternfly/react-core"; import { RolesList } from "./RoleList"; import { useAdminClient } from "../context/auth/AdminClient"; import { PaginatingTableToolbar } from "../components/table-toolbar/PaginatingTableToolbar"; import { ViewHeader } from "../components/view-header/ViewHeader"; import RoleRepresentation from "keycloak-admin/lib/defs/roleRepresentation"; import { ListEmptyState } from "../components/list-empty-state/ListEmptyState"; export const RealmRolesSection = () => { const [max, setMax] = useState(10); const [first, setFirst] = useState(0); const { t } = useTranslation("roles"); const history = useHistory(); const adminClient = useAdminClient(); const [roles, setRoles] = useState(); const params: { [name: string]: string | number } = { first, max }; const loader = async () => setRoles(await adminClient.roles.find(params)); useEffect(() => { loader(); }, [first, max]); const goToCreate = () => history.push("/roles/add-role"); return ( <> {roles && roles.length > 0 ? ( { setFirst(first); setMax(max); }} toolbarItem={ <> } > ) : ( )} ); };