Fix for Network error attempting to view default realm roles without permissions (#31902)
* fix for issue #29211 Signed-off-by: Himanshi Gupta <higupta@redhat.com> * fix for issue #29211 Signed-off-by: Himanshi Gupta <higupta@redhat.com> --------- Signed-off-by: Himanshi Gupta <higupta@redhat.com>
This commit is contained in:
parent
1e9f6bbb8c
commit
7cf9946040
1 changed files with 12 additions and 4 deletions
|
@ -13,8 +13,8 @@ import { useAlerts } from "@keycloak/keycloak-ui-shared";
|
||||||
import { useConfirmDialog } from "../confirm-dialog/ConfirmDialog";
|
import { useConfirmDialog } from "../confirm-dialog/ConfirmDialog";
|
||||||
import { ListEmptyState } from "../list-empty-state/ListEmptyState";
|
import { ListEmptyState } from "../list-empty-state/ListEmptyState";
|
||||||
import { Action, KeycloakDataTable } from "../table-toolbar/KeycloakDataTable";
|
import { Action, KeycloakDataTable } from "../table-toolbar/KeycloakDataTable";
|
||||||
|
|
||||||
import "./RolesList.css";
|
import "./RolesList.css";
|
||||||
|
import { useAccess } from "../../context/access/Access";
|
||||||
|
|
||||||
type RoleDetailLinkProps = RoleRepresentation & {
|
type RoleDetailLinkProps = RoleRepresentation & {
|
||||||
defaultRoleName?: string;
|
defaultRoleName?: string;
|
||||||
|
@ -30,13 +30,21 @@ const RoleDetailLink = ({
|
||||||
}: RoleDetailLinkProps) => {
|
}: RoleDetailLinkProps) => {
|
||||||
const { t } = useTranslation(messageBundle);
|
const { t } = useTranslation(messageBundle);
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
|
const { hasAccess, hasSomeAccess } = useAccess();
|
||||||
|
const canViewUserRegistration =
|
||||||
|
hasAccess("view-realm") && hasSomeAccess("view-clients", "manage-clients");
|
||||||
|
|
||||||
return role.name !== defaultRoleName ? (
|
return role.name !== defaultRoleName ? (
|
||||||
<Link to={toDetail(role.id!)}>{role.name}</Link>
|
<Link to={toDetail(role.id!)}>{role.name}</Link>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Link to={toRealmSettings({ realm, tab: "user-registration" })}>
|
{canViewUserRegistration ? (
|
||||||
{role.name}{" "}
|
<Link to={toRealmSettings({ realm, tab: "user-registration" })}>
|
||||||
</Link>
|
{role.name}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<span>{role.name}</span>
|
||||||
|
)}
|
||||||
<HelpItem
|
<HelpItem
|
||||||
helpText={t(`${messageBundle}:defaultRole`)}
|
helpText={t(`${messageBundle}:defaultRole`)}
|
||||||
fieldLabelId="defaultRole"
|
fieldLabelId="defaultRole"
|
||||||
|
|
Loading…
Reference in a new issue