1
import { Button, PageSection, Popover } from "@patternfly/react-core";
2
import { QuestionCircleIcon } from "@patternfly/react-icons";
3
import { useTranslation } from "react-i18next";
4
import { useNavigate } from "react-router-dom";
5
import { useHelp } from "ui-shared";
7
import { adminClient } from "../admin-client";
8
import type { ClientRoleParams } from "../clients/routes/ClientRole";
9
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
10
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
11
import { useRealm } from "../context/realm-context/RealmContext";
12
import { emptyFormatter, upperCaseFormatter } from "../util";
13
import { useParams } from "../utils/useParams";
15
export const UsersInRoleTab = () => {
16
const navigate = useNavigate();
17
const { realm } = useRealm();
19
const { t } = useTranslation();
20
const { id, clientId } = useParams<ClientRoleParams>();
22
const loader = async (first?: number, max?: number) => {
23
const role = await adminClient.roles.findOneById({ id: id });
25
throw new Error(t("notFound"));
28
if (role.clientRole) {
29
return adminClient.clients.findUsersWithRole({
37
return adminClient.roles.findUsersWithRole({
44
const { enabled } = useHelp();
47
<PageSection data-testid="users-page" variant="light">
51
ariaLabelKey="roleList"
52
searchPlaceholderKey=""
53
data-testid="users-in-role-table"
57
aria-label="Basic popover"
61
{t("whoWillAppearPopoverTextRoles")}
63
className="kc-groups-link"
65
onClick={() => navigate(`/${realm}/groups`)}
71
className="kc-users-link"
73
onClick={() => navigate(`/${realm}/users`)}
79
footerContent={t("whoWillAppearPopoverFooterText")}
83
className="kc-who-will-appear-button"
84
key="who-will-appear-button"
85
icon={<QuestionCircleIcon />}
87
{t("whoWillAppearLinkTextRoles")}
95
message={t("noDirectUsers")}
98
{t("noUsersEmptyStateDescription")}
100
className="kc-groups-link-empty-state"
102
onClick={() => navigate(`/${realm}/groups`)}
108
className="kc-users-link-empty-state"
110
onClick={() => navigate(`/${realm}/users`)}
114
{t("noUsersEmptyStateDescriptionContinued")}
122
displayKey: "userName",
123
cellFormatters: [emptyFormatter()],
128
cellFormatters: [emptyFormatter()],
132
displayKey: "lastName",
133
cellFormatters: [emptyFormatter()],
137
displayKey: "firstName",
138
cellFormatters: [upperCaseFormatter(), emptyFormatter()],