From 9ce3f2c53c2aa7b2e4375210a9b1af6af0f71d88 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Wed, 11 Aug 2021 13:44:18 +0200 Subject: [PATCH] added user in role for client tab (#987) Co-authored-by: Jon Koops --- src/realm-roles/UsersInRoleTab.tsx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/realm-roles/UsersInRoleTab.tsx b/src/realm-roles/UsersInRoleTab.tsx index 707667c2ef..5021963dec 100644 --- a/src/realm-roles/UsersInRoleTab.tsx +++ b/src/realm-roles/UsersInRoleTab.tsx @@ -9,25 +9,34 @@ import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable import { useAdminClient } from "../context/auth/AdminClient"; import { useRealm } from "../context/realm-context/RealmContext"; import { emptyFormatter, upperCaseFormatter } from "../util"; +import type { ClientRoleParams } from "./routes/ClientRole"; export const UsersInRoleTab = () => { const history = useHistory(); const { realm } = useRealm(); const { t } = useTranslation("roles"); - - const { id } = useParams<{ id: string }>(); + const { id, clientId } = useParams(); const adminClient = useAdminClient(); const loader = async (first?: number, max?: number) => { const role = await adminClient.roles.findOneById({ id: id }); - const usersWithRole = await adminClient.roles.findUsersWithRole({ + + if (role.clientRole) { + return adminClient.clients.findUsersWithRole({ + roleName: role.name!, + id: clientId, + first, + max, + }); + } + + return adminClient.roles.findUsersWithRole({ name: role.name!, - first: first!, - max: max!, + first, + max, }); - return usersWithRole || []; }; const { enabled } = useHelp();