added user in role for client tab (#987)
Co-authored-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
parent
a6d38096b7
commit
9ce3f2c53c
1 changed files with 15 additions and 6 deletions
|
@ -9,25 +9,34 @@ import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable
|
||||||
import { useAdminClient } from "../context/auth/AdminClient";
|
import { useAdminClient } from "../context/auth/AdminClient";
|
||||||
import { useRealm } from "../context/realm-context/RealmContext";
|
import { useRealm } from "../context/realm-context/RealmContext";
|
||||||
import { emptyFormatter, upperCaseFormatter } from "../util";
|
import { emptyFormatter, upperCaseFormatter } from "../util";
|
||||||
|
import type { ClientRoleParams } from "./routes/ClientRole";
|
||||||
|
|
||||||
export const UsersInRoleTab = () => {
|
export const UsersInRoleTab = () => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
|
|
||||||
const { t } = useTranslation("roles");
|
const { t } = useTranslation("roles");
|
||||||
|
const { id, clientId } = useParams<ClientRoleParams>();
|
||||||
const { id } = useParams<{ id: string }>();
|
|
||||||
|
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
|
|
||||||
const loader = async (first?: number, max?: number) => {
|
const loader = async (first?: number, max?: number) => {
|
||||||
const role = await adminClient.roles.findOneById({ id: id });
|
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!,
|
name: role.name!,
|
||||||
first: first!,
|
first,
|
||||||
max: max!,
|
max,
|
||||||
});
|
});
|
||||||
return usersWithRole || [];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const { enabled } = useHelp();
|
const { enabled } = useHelp();
|
||||||
|
|
Loading…
Reference in a new issue