Hide permissions tabs when ADMIN_FINE_GRAINED_AUTHZ is disabled. (#3779)
This commit is contained in:
parent
481fb0da48
commit
612a8444d1
4 changed files with 47 additions and 27 deletions
|
@ -31,6 +31,7 @@ import { GroupRoleMapping } from "./GroupRoleMapping";
|
|||
import helpUrls from "../help-urls";
|
||||
import { PermissionsTab } from "../components/permission-tab/PermissionTab";
|
||||
import { useAccess } from "../context/access/Access";
|
||||
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
|
||||
import { GroupTree } from "./components/GroupTree";
|
||||
import { DeleteGroup } from "./components/DeleteGroup";
|
||||
import useToggle from "../utils/useToggle";
|
||||
|
@ -42,6 +43,8 @@ export default function GroupsSection() {
|
|||
const { t } = useTranslation("groups");
|
||||
const [activeTab, setActiveTab] = useState(0);
|
||||
|
||||
const { profileInfo } = useServerInfo();
|
||||
|
||||
const { adminClient } = useAdminClient();
|
||||
const { subGroups, setSubGroups, currentGroup } = useSubGroups();
|
||||
const { realm } = useRealm();
|
||||
|
@ -57,11 +60,9 @@ export default function GroupsSection() {
|
|||
const refresh = () => setKey(key + 1);
|
||||
|
||||
const { hasAccess } = useAccess();
|
||||
const canViewPermissions = hasAccess(
|
||||
"manage-authorization",
|
||||
"manage-users",
|
||||
"manage-clients"
|
||||
);
|
||||
const canViewPermissions =
|
||||
!profileInfo?.disabledFeatures?.includes("ADMIN_FINE_GRAINED_AUTHZ") &&
|
||||
hasAccess("manage-authorization", "manage-users", "manage-clients");
|
||||
const canManageGroup =
|
||||
hasAccess("manage-users") || currentGroup()?.access?.manage;
|
||||
const canManageRoles = hasAccess("manage-users");
|
||||
|
|
|
@ -28,6 +28,7 @@ import { AdvancedSettings } from "./AdvancedSettings";
|
|||
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
|
||||
import { useAlerts } from "../../components/alert/Alerts";
|
||||
import { useRealm } from "../../context/realm-context/RealmContext";
|
||||
import { useServerInfo } from "../../context/server-info/ServerInfoProvider";
|
||||
import { KeycloakTabs } from "../../components/keycloak-tabs/KeycloakTabs";
|
||||
import { ExtendedNonDiscoverySettings } from "./ExtendedNonDiscoverySettings";
|
||||
import { DiscoverySettings } from "./DiscoverySettings";
|
||||
|
@ -120,6 +121,7 @@ export default function DetailSettings() {
|
|||
const navigate = useNavigate();
|
||||
const { realm } = useRealm();
|
||||
const [key, setKey] = useState(0);
|
||||
const { profileInfo } = useServerInfo();
|
||||
const refresh = () => setKey(key + 1);
|
||||
|
||||
const MapperLink = ({ name, mapperId }: IdPWithMapperAttributes) => (
|
||||
|
@ -444,6 +446,9 @@ export default function DetailSettings() {
|
|||
]}
|
||||
/>
|
||||
</Tab>
|
||||
{!profileInfo?.disabledFeatures?.includes(
|
||||
"ADMIN_FINE_GRAINED_AUTHZ"
|
||||
) && (
|
||||
<Tab
|
||||
id="permissions"
|
||||
data-testid="permissionsTab"
|
||||
|
@ -452,6 +457,7 @@ export default function DetailSettings() {
|
|||
>
|
||||
<PermissionsTab id={alias} type="identityProviders" />
|
||||
</Tab>
|
||||
)}
|
||||
</KeycloakTabs>
|
||||
</PageSection>
|
||||
</FormProvider>
|
||||
|
|
|
@ -15,6 +15,7 @@ import { omit } from "lodash-es";
|
|||
|
||||
import { useAlerts } from "../components/alert/Alerts";
|
||||
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
|
||||
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
|
||||
import type RoleRepresentation from "@keycloak/keycloak-admin-client/lib/defs/roleRepresentation";
|
||||
import {
|
||||
AttributesForm,
|
||||
|
@ -61,6 +62,8 @@ export default function RealmRoleTabs() {
|
|||
|
||||
const [key, setKey] = useState(0);
|
||||
|
||||
const { profileInfo } = useServerInfo();
|
||||
|
||||
const refresh = () => {
|
||||
setKey(key + 1);
|
||||
};
|
||||
|
@ -415,12 +418,16 @@ export default function RealmRoleTabs() {
|
|||
<UsersInRoleTab data-cy="users-in-role-tab" />
|
||||
</Tab>
|
||||
)}
|
||||
{!profileInfo?.disabledFeatures?.includes(
|
||||
"ADMIN_FINE_GRAINED_AUTHZ"
|
||||
) && (
|
||||
<Tab
|
||||
eventKey="permissions"
|
||||
title={<TabTitleText>{t("common:permissions")}</TabTitleText>}
|
||||
>
|
||||
<PermissionsTab id={role.id} type="roles" />
|
||||
</Tab>
|
||||
)}
|
||||
</KeycloakTabs>
|
||||
)}
|
||||
</PageSection>
|
||||
|
|
|
@ -34,6 +34,7 @@ import type { IRowData } from "@patternfly/react-table";
|
|||
import type ComponentRepresentation from "@keycloak/keycloak-admin-client/lib/defs/componentRepresentation";
|
||||
import type UserRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userRepresentation";
|
||||
import type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
|
||||
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
|
||||
import { useAlerts } from "../components/alert/Alerts";
|
||||
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
|
||||
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
|
||||
|
@ -69,6 +70,7 @@ export default function UsersSection() {
|
|||
const [realm, setRealm] = useState<RealmRepresentation | undefined>();
|
||||
const [kebabOpen, setKebabOpen] = useState(false);
|
||||
const [selectedRows, setSelectedRows] = useState<UserRepresentation[]>([]);
|
||||
const { profileInfo } = useServerInfo();
|
||||
|
||||
const [key, setKey] = useState(0);
|
||||
const refresh = () => setKey(key + 1);
|
||||
|
@ -411,6 +413,9 @@ export default function UsersSection() {
|
|||
]}
|
||||
/>
|
||||
</Tab>
|
||||
{!profileInfo?.disabledFeatures?.includes(
|
||||
"ADMIN_FINE_GRAINED_AUTHZ"
|
||||
) && (
|
||||
<Tab
|
||||
id="permissions"
|
||||
data-testid="permissionsTab"
|
||||
|
@ -419,6 +424,7 @@ export default function UsersSection() {
|
|||
>
|
||||
<PermissionsTab type="users" />
|
||||
</Tab>
|
||||
)}
|
||||
</RoutableTabs>
|
||||
</PageSection>
|
||||
</>
|
||||
|
|
Loading…
Reference in a new issue