import React, { useContext } from "react"; import { useHistory, useParams } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { Button, PageSection, Popover } from "@patternfly/react-core"; import { ListEmptyState } from "../components/list-empty-state/ListEmptyState"; import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable"; import { upperCaseFormatter, emptyFormatter } from "../util"; import { useAdminClient } from "../context/auth/AdminClient"; import { QuestionCircleIcon } from "@patternfly/react-icons"; import { useRealm } from "../context/realm-context/RealmContext"; import { HelpContext } from "../components/help-enabler/HelpHeader"; export const UsersInRoleTab = () => { const history = useHistory(); const { realm } = useRealm(); const { t } = useTranslation("roles"); const { id } = useParams<{ id: string }>(); const adminClient = useAdminClient(); const loader = async (first?: number, max?: number) => { const role = await adminClient.roles.findOneById({ id: id }); const usersWithRole = await adminClient.roles.findUsersWithRole({ name: role.name!, first: first!, max: max!, }); return usersWithRole; }; const { enabled } = useContext(HelpContext); return ( <> {t("roles:whoWillAppearPopoverText")} {t("or")} } footerContent={t("roles:whoWillAppearPopoverFooterText")} > ) } emptyState={ {t("noUsersEmptyStateDescription")} {t("or")} {t("noUsersEmptyStateDescriptionContinued")} } /> } columns={[ { name: "username", displayKey: "roles:userName", cellFormatters: [emptyFormatter()], }, { name: "email", displayKey: "roles:email", cellFormatters: [emptyFormatter()], }, { name: "lastName", displayKey: "roles:lastName", cellFormatters: [emptyFormatter()], }, { name: "firstName", displayKey: "roles:firstName", cellFormatters: [upperCaseFormatter(), emptyFormatter()], }, ]} /> ); };