Revert "Revert "Always use useIsFeatureEnabled()
hook for feature detection (#19589)" (#19635)" (#19643)
This reverts commit bcaab0e603
.
This commit is contained in:
parent
0196c1e748
commit
25a1496e0d
9 changed files with 87 additions and 108 deletions
|
@ -38,16 +38,18 @@ import {
|
||||||
import { useAccess } from "../context/access/Access";
|
import { useAccess } from "../context/access/Access";
|
||||||
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
|
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
|
||||||
import { useRealm } from "../context/realm-context/RealmContext";
|
import { useRealm } from "../context/realm-context/RealmContext";
|
||||||
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
|
|
||||||
import {
|
import {
|
||||||
convertAttributeNameToForm,
|
convertAttributeNameToForm,
|
||||||
convertFormValuesToObject,
|
convertFormValuesToObject,
|
||||||
convertToFormValues,
|
convertToFormValues,
|
||||||
exportClient,
|
exportClient,
|
||||||
} from "../util";
|
} from "../util";
|
||||||
|
import useIsFeatureEnabled, { Feature } from "../utils/useIsFeatureEnabled";
|
||||||
import { useParams } from "../utils/useParams";
|
import { useParams } from "../utils/useParams";
|
||||||
import useToggle from "../utils/useToggle";
|
import useToggle from "../utils/useToggle";
|
||||||
import { AdvancedTab } from "./AdvancedTab";
|
import { AdvancedTab } from "./AdvancedTab";
|
||||||
|
import { ClientSessions } from "./ClientSessions";
|
||||||
|
import { ClientSettings } from "./ClientSettings";
|
||||||
import { AuthorizationEvaluate } from "./authorization/AuthorizationEvaluate";
|
import { AuthorizationEvaluate } from "./authorization/AuthorizationEvaluate";
|
||||||
import { AuthorizationExport } from "./authorization/AuthorizationExport";
|
import { AuthorizationExport } from "./authorization/AuthorizationExport";
|
||||||
import { AuthorizationPermissions } from "./authorization/Permissions";
|
import { AuthorizationPermissions } from "./authorization/Permissions";
|
||||||
|
@ -55,8 +57,6 @@ import { AuthorizationPolicies } from "./authorization/Policies";
|
||||||
import { AuthorizationResources } from "./authorization/Resources";
|
import { AuthorizationResources } from "./authorization/Resources";
|
||||||
import { AuthorizationScopes } from "./authorization/Scopes";
|
import { AuthorizationScopes } from "./authorization/Scopes";
|
||||||
import { AuthorizationSettings } from "./authorization/Settings";
|
import { AuthorizationSettings } from "./authorization/Settings";
|
||||||
import { ClientSessions } from "./ClientSessions";
|
|
||||||
import { ClientSettings } from "./ClientSettings";
|
|
||||||
import { Credentials } from "./credentials/Credentials";
|
import { Credentials } from "./credentials/Credentials";
|
||||||
import { Keys } from "./keys/Keys";
|
import { Keys } from "./keys/Keys";
|
||||||
import { SamlKeys } from "./keys/SamlKeys";
|
import { SamlKeys } from "./keys/SamlKeys";
|
||||||
|
@ -66,8 +66,8 @@ import {
|
||||||
} from "./routes/AuthenticationTab";
|
} from "./routes/AuthenticationTab";
|
||||||
import { ClientParams, ClientTab, toClient } from "./routes/Client";
|
import { ClientParams, ClientTab, toClient } from "./routes/Client";
|
||||||
import { toClientRole } from "./routes/ClientRole";
|
import { toClientRole } from "./routes/ClientRole";
|
||||||
import { toClients } from "./routes/Clients";
|
|
||||||
import { ClientScopesTab, toClientScopesTab } from "./routes/ClientScopeTab";
|
import { ClientScopesTab, toClientScopesTab } from "./routes/ClientScopeTab";
|
||||||
|
import { toClients } from "./routes/Clients";
|
||||||
import { toCreateRole } from "./routes/NewRole";
|
import { toCreateRole } from "./routes/NewRole";
|
||||||
import { ClientScopes } from "./scopes/ClientScopes";
|
import { ClientScopes } from "./scopes/ClientScopes";
|
||||||
import { EvaluateScopes } from "./scopes/EvaluateScopes";
|
import { EvaluateScopes } from "./scopes/EvaluateScopes";
|
||||||
|
@ -191,17 +191,16 @@ export default function ClientDetails() {
|
||||||
const { adminClient } = useAdminClient();
|
const { adminClient } = useAdminClient();
|
||||||
const { addAlert, addError } = useAlerts();
|
const { addAlert, addError } = useAlerts();
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
const { profileInfo } = useServerInfo();
|
|
||||||
|
|
||||||
const { hasAccess } = useAccess();
|
const { hasAccess } = useAccess();
|
||||||
|
const isFeatureEnabled = useIsFeatureEnabled();
|
||||||
|
|
||||||
const hasManageAuthorization = hasAccess("manage-authorization");
|
const hasManageAuthorization = hasAccess("manage-authorization");
|
||||||
const permissionsEnabled =
|
|
||||||
!profileInfo?.disabledFeatures?.includes("ADMIN_FINE_GRAINED_AUTHZ") &&
|
|
||||||
hasManageAuthorization;
|
|
||||||
const hasManageClients = hasAccess("manage-clients");
|
const hasManageClients = hasAccess("manage-clients");
|
||||||
const hasViewClients = hasAccess("view-clients");
|
const hasViewClients = hasAccess("view-clients");
|
||||||
const hasViewUsers = hasAccess("view-users");
|
const hasViewUsers = hasAccess("view-users");
|
||||||
const hasQueryUsers = hasAccess("query-users");
|
const hasQueryUsers = hasAccess("query-users");
|
||||||
|
const permissionsEnabled =
|
||||||
|
isFeatureEnabled(Feature.AdminFineGrainedAuthz) && hasManageAuthorization;
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
|
|
@ -1,41 +1,40 @@
|
||||||
import { useState } from "react";
|
import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation";
|
||||||
import { useLocation, useNavigate } from "react-router-dom";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import {
|
import {
|
||||||
|
Drawer,
|
||||||
|
DrawerContent,
|
||||||
|
DrawerContentBody,
|
||||||
|
DrawerHead,
|
||||||
|
DrawerPanelContent,
|
||||||
DropdownItem,
|
DropdownItem,
|
||||||
PageSection,
|
PageSection,
|
||||||
PageSectionVariants,
|
PageSectionVariants,
|
||||||
Tab,
|
Tab,
|
||||||
TabTitleText,
|
TabTitleText,
|
||||||
Tabs,
|
Tabs,
|
||||||
Drawer,
|
|
||||||
DrawerContent,
|
|
||||||
DrawerContentBody,
|
|
||||||
DrawerPanelContent,
|
|
||||||
DrawerHead,
|
|
||||||
} from "@patternfly/react-core";
|
} from "@patternfly/react-core";
|
||||||
import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation";
|
import { useState } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { useLocation, useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import { ViewHeader } from "../components/view-header/ViewHeader";
|
|
||||||
import { useFetch, useAdminClient } from "../context/auth/AdminClient";
|
|
||||||
import { useRealm } from "../context/realm-context/RealmContext";
|
|
||||||
|
|
||||||
import { useSubGroups } from "./SubGroupsContext";
|
|
||||||
import { GroupTable } from "./GroupTable";
|
|
||||||
import { getId, getLastId } from "./groupIdUtils";
|
|
||||||
import { Members } from "./Members";
|
|
||||||
import { GroupAttributes } from "./GroupAttributes";
|
|
||||||
import { GroupsModal } from "./GroupsModal";
|
|
||||||
import { toGroups } from "./routes/Groups";
|
|
||||||
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";
|
|
||||||
import { GroupBreadCrumbs } from "../components/bread-crumb/GroupBreadCrumbs";
|
import { GroupBreadCrumbs } from "../components/bread-crumb/GroupBreadCrumbs";
|
||||||
|
import { PermissionsTab } from "../components/permission-tab/PermissionTab";
|
||||||
|
import { ViewHeader } from "../components/view-header/ViewHeader";
|
||||||
|
import { useAccess } from "../context/access/Access";
|
||||||
|
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
|
||||||
|
import { useRealm } from "../context/realm-context/RealmContext";
|
||||||
|
import helpUrls from "../help-urls";
|
||||||
|
import useIsFeatureEnabled, { Feature } from "../utils/useIsFeatureEnabled";
|
||||||
|
import useToggle from "../utils/useToggle";
|
||||||
|
import { GroupAttributes } from "./GroupAttributes";
|
||||||
|
import { GroupRoleMapping } from "./GroupRoleMapping";
|
||||||
|
import { GroupTable } from "./GroupTable";
|
||||||
|
import { GroupsModal } from "./GroupsModal";
|
||||||
|
import { Members } from "./Members";
|
||||||
|
import { useSubGroups } from "./SubGroupsContext";
|
||||||
|
import { DeleteGroup } from "./components/DeleteGroup";
|
||||||
|
import { GroupTree } from "./components/GroupTree";
|
||||||
|
import { getId, getLastId } from "./groupIdUtils";
|
||||||
|
import { toGroups } from "./routes/Groups";
|
||||||
|
|
||||||
import "./GroupsSection.css";
|
import "./GroupsSection.css";
|
||||||
|
|
||||||
|
@ -43,8 +42,6 @@ export default function GroupsSection() {
|
||||||
const { t } = useTranslation("groups");
|
const { t } = useTranslation("groups");
|
||||||
const [activeTab, setActiveTab] = useState(0);
|
const [activeTab, setActiveTab] = useState(0);
|
||||||
|
|
||||||
const { profileInfo } = useServerInfo();
|
|
||||||
|
|
||||||
const { adminClient } = useAdminClient();
|
const { adminClient } = useAdminClient();
|
||||||
const { subGroups, setSubGroups, currentGroup } = useSubGroups();
|
const { subGroups, setSubGroups, currentGroup } = useSubGroups();
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
|
@ -60,8 +57,9 @@ export default function GroupsSection() {
|
||||||
const refresh = () => setKey(key + 1);
|
const refresh = () => setKey(key + 1);
|
||||||
|
|
||||||
const { hasAccess } = useAccess();
|
const { hasAccess } = useAccess();
|
||||||
|
const isFeatureEnabled = useIsFeatureEnabled();
|
||||||
const canViewPermissions =
|
const canViewPermissions =
|
||||||
!profileInfo?.disabledFeatures?.includes("ADMIN_FINE_GRAINED_AUTHZ") &&
|
isFeatureEnabled(Feature.AdminFineGrainedAuthz) &&
|
||||||
hasAccess("manage-authorization", "manage-users", "manage-clients");
|
hasAccess("manage-authorization", "manage-users", "manage-clients");
|
||||||
const canManageGroup =
|
const canManageGroup =
|
||||||
hasAccess("manage-users") || currentGroup()?.access?.manage;
|
hasAccess("manage-users") || currentGroup()?.access?.manage;
|
||||||
|
|
|
@ -36,8 +36,8 @@ import {
|
||||||
import { ViewHeader } from "../../components/view-header/ViewHeader";
|
import { ViewHeader } from "../../components/view-header/ViewHeader";
|
||||||
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
|
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
|
||||||
import { useRealm } from "../../context/realm-context/RealmContext";
|
import { useRealm } from "../../context/realm-context/RealmContext";
|
||||||
import { useServerInfo } from "../../context/server-info/ServerInfoProvider";
|
|
||||||
import { toUpperCase } from "../../util";
|
import { toUpperCase } from "../../util";
|
||||||
|
import useIsFeatureEnabled, { Feature } from "../../utils/useIsFeatureEnabled";
|
||||||
import { useParams } from "../../utils/useParams";
|
import { useParams } from "../../utils/useParams";
|
||||||
import { ExtendedFieldsForm } from "../component/ExtendedFieldsForm";
|
import { ExtendedFieldsForm } from "../component/ExtendedFieldsForm";
|
||||||
import { toIdentityProviderAddMapper } from "../routes/AddMapper";
|
import { toIdentityProviderAddMapper } from "../routes/AddMapper";
|
||||||
|
@ -156,7 +156,7 @@ const MapperLink = ({ name, mapperId, provider }: MapperLinkProps) => {
|
||||||
export default function DetailSettings() {
|
export default function DetailSettings() {
|
||||||
const { t } = useTranslation("identity-providers");
|
const { t } = useTranslation("identity-providers");
|
||||||
const { alias, providerId } = useParams<IdentityProviderParams>();
|
const { alias, providerId } = useParams<IdentityProviderParams>();
|
||||||
|
const isFeatureEnabled = useIsFeatureEnabled();
|
||||||
const form = useForm<IdentityProviderRepresentation>();
|
const form = useForm<IdentityProviderRepresentation>();
|
||||||
const { handleSubmit, getValues, reset } = form;
|
const { handleSubmit, getValues, reset } = form;
|
||||||
const [provider, setProvider] = useState<IdentityProviderRepresentation>();
|
const [provider, setProvider] = useState<IdentityProviderRepresentation>();
|
||||||
|
@ -168,7 +168,6 @@ export default function DetailSettings() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
const [key, setKey] = useState(0);
|
const [key, setKey] = useState(0);
|
||||||
const { profileInfo } = useServerInfo();
|
|
||||||
const refresh = () => setKey(key + 1);
|
const refresh = () => setKey(key + 1);
|
||||||
|
|
||||||
useFetch(
|
useFetch(
|
||||||
|
@ -496,9 +495,7 @@ export default function DetailSettings() {
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Tab>
|
</Tab>
|
||||||
{!profileInfo?.disabledFeatures?.includes(
|
{isFeatureEnabled(Feature.AdminFineGrainedAuthz) && (
|
||||||
"ADMIN_FINE_GRAINED_AUTHZ"
|
|
||||||
) && (
|
|
||||||
<Tab
|
<Tab
|
||||||
id="permissions"
|
id="permissions"
|
||||||
data-testid="permissionsTab"
|
data-testid="permissionsTab"
|
||||||
|
|
|
@ -27,9 +27,9 @@ import {
|
||||||
AttributesForm,
|
AttributesForm,
|
||||||
} from "../components/key-value-form/AttributeForm";
|
} from "../components/key-value-form/AttributeForm";
|
||||||
import {
|
import {
|
||||||
|
KeyValueType,
|
||||||
arrayToKeyValue,
|
arrayToKeyValue,
|
||||||
keyValueToArray,
|
keyValueToArray,
|
||||||
KeyValueType,
|
|
||||||
} from "../components/key-value-form/key-value-convert";
|
} from "../components/key-value-form/key-value-convert";
|
||||||
import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner";
|
import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner";
|
||||||
import { PermissionsTab } from "../components/permission-tab/PermissionTab";
|
import { PermissionsTab } from "../components/permission-tab/PermissionTab";
|
||||||
|
@ -43,13 +43,14 @@ import {
|
||||||
import { ViewHeader } from "../components/view-header/ViewHeader";
|
import { ViewHeader } from "../components/view-header/ViewHeader";
|
||||||
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
|
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
|
||||||
import { useRealm } from "../context/realm-context/RealmContext";
|
import { useRealm } from "../context/realm-context/RealmContext";
|
||||||
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
|
import useIsFeatureEnabled, { Feature } from "../utils/useIsFeatureEnabled";
|
||||||
import { useParams } from "../utils/useParams";
|
import { useParams } from "../utils/useParams";
|
||||||
|
import { UsersInRoleTab } from "./UsersInRoleTab";
|
||||||
import { RealmRoleRoute, RealmRoleTab, toRealmRole } from "./routes/RealmRole";
|
import { RealmRoleRoute, RealmRoleTab, toRealmRole } from "./routes/RealmRole";
|
||||||
import { toRealmRoles } from "./routes/RealmRoles";
|
import { toRealmRoles } from "./routes/RealmRoles";
|
||||||
import { UsersInRoleTab } from "./UsersInRoleTab";
|
|
||||||
|
|
||||||
export default function RealmRoleTabs() {
|
export default function RealmRoleTabs() {
|
||||||
|
const isFeatureEnabled = useIsFeatureEnabled();
|
||||||
const { t } = useTranslation("roles");
|
const { t } = useTranslation("roles");
|
||||||
const form = useForm<AttributeForm>({
|
const form = useForm<AttributeForm>({
|
||||||
mode: "onChange",
|
mode: "onChange",
|
||||||
|
@ -67,8 +68,6 @@ export default function RealmRoleTabs() {
|
||||||
const [key, setKey] = useState(0);
|
const [key, setKey] = useState(0);
|
||||||
const [attributes, setAttributes] = useState<KeyValueType[] | undefined>();
|
const [attributes, setAttributes] = useState<KeyValueType[] | undefined>();
|
||||||
|
|
||||||
const { profileInfo } = useServerInfo();
|
|
||||||
|
|
||||||
const refresh = () => setKey(key + 1);
|
const refresh = () => setKey(key + 1);
|
||||||
|
|
||||||
const { addAlert, addError } = useAlerts();
|
const { addAlert, addError } = useAlerts();
|
||||||
|
@ -391,9 +390,7 @@ export default function RealmRoleTabs() {
|
||||||
<UsersInRoleTab data-cy="users-in-role-tab" />
|
<UsersInRoleTab data-cy="users-in-role-tab" />
|
||||||
</Tab>
|
</Tab>
|
||||||
)}
|
)}
|
||||||
{!profileInfo?.disabledFeatures?.includes(
|
{isFeatureEnabled(Feature.AdminFineGrainedAuthz) && (
|
||||||
"ADMIN_FINE_GRAINED_AUTHZ"
|
|
||||||
) && (
|
|
||||||
<Tab
|
<Tab
|
||||||
title={<TabTitleText>{t("common:permissions")}</TabTitleText>}
|
title={<TabTitleText>{t("common:permissions")}</TabTitleText>}
|
||||||
{...permissionsTab}
|
{...permissionsTab}
|
||||||
|
|
|
@ -22,33 +22,32 @@ import {
|
||||||
useRoutableTab,
|
useRoutableTab,
|
||||||
} from "../components/routable-tabs/RoutableTabs";
|
} from "../components/routable-tabs/RoutableTabs";
|
||||||
import { ViewHeader } from "../components/view-header/ViewHeader";
|
import { ViewHeader } from "../components/view-header/ViewHeader";
|
||||||
|
import { useRealms } from "../context/RealmsContext";
|
||||||
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 { useRealms } from "../context/RealmsContext";
|
|
||||||
import { toDashboard } from "../dashboard/routes/Dashboard";
|
import { toDashboard } from "../dashboard/routes/Dashboard";
|
||||||
import environment from "../environment";
|
import environment from "../environment";
|
||||||
import helpUrls from "../help-urls";
|
import helpUrls from "../help-urls";
|
||||||
import { convertFormValuesToObject, convertToFormValues } from "../util";
|
import { convertFormValuesToObject, convertToFormValues } from "../util";
|
||||||
import useIsFeatureEnabled, { Feature } from "../utils/useIsFeatureEnabled";
|
import useIsFeatureEnabled, { Feature } from "../utils/useIsFeatureEnabled";
|
||||||
import { RealmSettingsEmailTab } from "./EmailTab";
|
import { RealmSettingsEmailTab } from "./EmailTab";
|
||||||
import { EventsTab } from "./event-config/EventsTab";
|
|
||||||
import { RealmSettingsGeneralTab } from "./GeneralTab";
|
import { RealmSettingsGeneralTab } from "./GeneralTab";
|
||||||
import { KeysTab } from "./keys/KeysTab";
|
|
||||||
import { LocalizationTab } from "./LocalizationTab";
|
import { LocalizationTab } from "./LocalizationTab";
|
||||||
import { RealmSettingsLoginTab } from "./LoginTab";
|
import { RealmSettingsLoginTab } from "./LoginTab";
|
||||||
import { PartialExportDialog } from "./PartialExport";
|
import { PartialExportDialog } from "./PartialExport";
|
||||||
import { PartialImportDialog } from "./PartialImport";
|
import { PartialImportDialog } from "./PartialImport";
|
||||||
import { PoliciesTab } from "./PoliciesTab";
|
import { PoliciesTab } from "./PoliciesTab";
|
||||||
import ProfilesTab from "./ProfilesTab";
|
import ProfilesTab from "./ProfilesTab";
|
||||||
import { ClientPoliciesTab, toClientPolicies } from "./routes/ClientPolicies";
|
|
||||||
import { RealmSettingsTab, toRealmSettings } from "./routes/RealmSettings";
|
|
||||||
import { SecurityDefenses } from "./security-defences/SecurityDefenses";
|
|
||||||
import { RealmSettingsSessionsTab } from "./SessionsTab";
|
import { RealmSettingsSessionsTab } from "./SessionsTab";
|
||||||
import { RealmSettingsThemesTab } from "./ThemesTab";
|
import { RealmSettingsThemesTab } from "./ThemesTab";
|
||||||
import { RealmSettingsTokensTab } from "./TokensTab";
|
import { RealmSettingsTokensTab } from "./TokensTab";
|
||||||
import { UserProfileTab } from "./user-profile/UserProfileTab";
|
|
||||||
import { UserRegistration } from "./UserRegistration";
|
import { UserRegistration } from "./UserRegistration";
|
||||||
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
|
import { EventsTab } from "./event-config/EventsTab";
|
||||||
|
import { KeysTab } from "./keys/KeysTab";
|
||||||
|
import { ClientPoliciesTab, toClientPolicies } from "./routes/ClientPolicies";
|
||||||
|
import { RealmSettingsTab, toRealmSettings } from "./routes/RealmSettings";
|
||||||
|
import { SecurityDefenses } from "./security-defences/SecurityDefenses";
|
||||||
|
import { UserProfileTab } from "./user-profile/UserProfileTab";
|
||||||
|
|
||||||
type RealmSettingsHeaderProps = {
|
type RealmSettingsHeaderProps = {
|
||||||
onChange: (value: boolean) => void;
|
onChange: (value: boolean) => void;
|
||||||
|
@ -237,8 +236,6 @@ export const RealmSettingsTabs = ({
|
||||||
const sessionsTab = useTab("sessions");
|
const sessionsTab = useTab("sessions");
|
||||||
const tokensTab = useTab("tokens");
|
const tokensTab = useTab("tokens");
|
||||||
const clientPoliciesTab = useTab("client-policies");
|
const clientPoliciesTab = useTab("client-policies");
|
||||||
const clientPoliciesDisabled =
|
|
||||||
useServerInfo().profileInfo?.disabledFeatures?.includes("CLIENT_POLICIES");
|
|
||||||
const userProfileTab = useTab("user-profile");
|
const userProfileTab = useTab("user-profile");
|
||||||
const userRegistrationTab = useTab("user-registration");
|
const userRegistrationTab = useTab("user-registration");
|
||||||
|
|
||||||
|
@ -353,7 +350,7 @@ export const RealmSettingsTabs = ({
|
||||||
>
|
>
|
||||||
<RealmSettingsTokensTab save={save} realm={realm} />
|
<RealmSettingsTokensTab save={save} realm={realm} />
|
||||||
</Tab>
|
</Tab>
|
||||||
{!clientPoliciesDisabled && (
|
{isFeatureEnabled(Feature.ClientPolicies) && (
|
||||||
<Tab
|
<Tab
|
||||||
title={
|
title={
|
||||||
<TabTitleText>
|
<TabTitleText>
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import { ScrollForm } from "../components/scroll-form/ScrollForm";
|
import { ScrollForm } from "../components/scroll-form/ScrollForm";
|
||||||
import { useRealm } from "../context/realm-context/RealmContext";
|
import { useRealm } from "../context/realm-context/RealmContext";
|
||||||
|
import useIsFeatureEnabled, { Feature } from "../utils/useIsFeatureEnabled";
|
||||||
import { LdapSettingsAdvanced } from "./ldap/LdapSettingsAdvanced";
|
import { LdapSettingsAdvanced } from "./ldap/LdapSettingsAdvanced";
|
||||||
import { LdapSettingsConnection } from "./ldap/LdapSettingsConnection";
|
import { LdapSettingsConnection } from "./ldap/LdapSettingsConnection";
|
||||||
import { LdapSettingsGeneral } from "./ldap/LdapSettingsGeneral";
|
import { LdapSettingsGeneral } from "./ldap/LdapSettingsGeneral";
|
||||||
|
@ -14,7 +15,6 @@ import { LdapSettingsSearching } from "./ldap/LdapSettingsSearching";
|
||||||
import { LdapSettingsSynchronization } from "./ldap/LdapSettingsSynchronization";
|
import { LdapSettingsSynchronization } from "./ldap/LdapSettingsSynchronization";
|
||||||
import { toUserFederation } from "./routes/UserFederation";
|
import { toUserFederation } from "./routes/UserFederation";
|
||||||
import { SettingsCache } from "./shared/SettingsCache";
|
import { SettingsCache } from "./shared/SettingsCache";
|
||||||
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
|
|
||||||
|
|
||||||
export type LdapComponentRepresentation = ComponentRepresentation & {
|
export type LdapComponentRepresentation = ComponentRepresentation & {
|
||||||
config?: {
|
config?: {
|
||||||
|
@ -36,8 +36,7 @@ export const UserFederationLdapForm = ({
|
||||||
const form = useFormContext<LdapComponentRepresentation>();
|
const form = useFormContext<LdapComponentRepresentation>();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
const kerberosDisabled =
|
const isFeatureEnabled = useIsFeatureEnabled();
|
||||||
useServerInfo().profileInfo?.disabledFeatures?.includes("KERBEROS");
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -62,7 +61,7 @@ export const UserFederationLdapForm = ({
|
||||||
{
|
{
|
||||||
title: t("kerberosIntegration"),
|
title: t("kerberosIntegration"),
|
||||||
panel: <LdapSettingsKerberosIntegration form={form} />,
|
panel: <LdapSettingsKerberosIntegration form={form} />,
|
||||||
isHidden: kerberosDisabled,
|
isHidden: !isFeatureEnabled(Feature.Kerberos),
|
||||||
},
|
},
|
||||||
{ title: t("cacheSettings"), panel: <SettingsCache form={form} /> },
|
{ title: t("cacheSettings"), panel: <SettingsCache form={form} /> },
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,28 +1,26 @@
|
||||||
|
import type ComponentRepresentation from "@keycloak/keycloak-admin-client/lib/defs/componentRepresentation";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Wizard,
|
Wizard,
|
||||||
WizardContextConsumer,
|
WizardContextConsumer,
|
||||||
WizardFooter,
|
WizardFooter,
|
||||||
} from "@patternfly/react-core";
|
} from "@patternfly/react-core";
|
||||||
|
import { useForm } from "react-hook-form";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import { LdapSettingsGeneral } from "./ldap/LdapSettingsGeneral";
|
import useIsFeatureEnabled, { Feature } from "../utils/useIsFeatureEnabled";
|
||||||
|
import { LdapSettingsAdvanced } from "./ldap/LdapSettingsAdvanced";
|
||||||
import { LdapSettingsConnection } from "./ldap/LdapSettingsConnection";
|
import { LdapSettingsConnection } from "./ldap/LdapSettingsConnection";
|
||||||
|
import { LdapSettingsGeneral } from "./ldap/LdapSettingsGeneral";
|
||||||
|
import { LdapSettingsKerberosIntegration } from "./ldap/LdapSettingsKerberosIntegration";
|
||||||
import { LdapSettingsSearching } from "./ldap/LdapSettingsSearching";
|
import { LdapSettingsSearching } from "./ldap/LdapSettingsSearching";
|
||||||
import { LdapSettingsSynchronization } from "./ldap/LdapSettingsSynchronization";
|
import { LdapSettingsSynchronization } from "./ldap/LdapSettingsSynchronization";
|
||||||
import { LdapSettingsKerberosIntegration } from "./ldap/LdapSettingsKerberosIntegration";
|
|
||||||
import { SettingsCache } from "./shared/SettingsCache";
|
import { SettingsCache } from "./shared/SettingsCache";
|
||||||
import { LdapSettingsAdvanced } from "./ldap/LdapSettingsAdvanced";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import type ComponentRepresentation from "@keycloak/keycloak-admin-client/lib/defs/componentRepresentation";
|
|
||||||
|
|
||||||
import { useForm } from "react-hook-form";
|
|
||||||
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
|
|
||||||
|
|
||||||
export const UserFederationLdapWizard = () => {
|
export const UserFederationLdapWizard = () => {
|
||||||
const form = useForm<ComponentRepresentation>();
|
const form = useForm<ComponentRepresentation>();
|
||||||
const { t } = useTranslation("user-federation");
|
const { t } = useTranslation("user-federation");
|
||||||
const kerberosDisabled =
|
const isFeatureEnabled = useIsFeatureEnabled();
|
||||||
useServerInfo().profileInfo?.disabledFeatures?.includes("KERBEROS");
|
|
||||||
|
|
||||||
const steps = [
|
const steps = [
|
||||||
{
|
{
|
||||||
|
@ -79,7 +77,7 @@ export const UserFederationLdapWizard = () => {
|
||||||
showSectionDescription
|
showSectionDescription
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
isDisabled: kerberosDisabled,
|
isDisabled: !isFeatureEnabled(Feature.Kerberos),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: t("cacheSettings"),
|
name: t("cacheSettings"),
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
import { useState } from "react";
|
|
||||||
import { Link, useNavigate } from "react-router-dom";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import {
|
import {
|
||||||
AlertVariant,
|
AlertVariant,
|
||||||
Button,
|
Button,
|
||||||
|
@ -29,31 +26,34 @@ import {
|
||||||
WarningTriangleIcon,
|
WarningTriangleIcon,
|
||||||
} from "@patternfly/react-icons";
|
} from "@patternfly/react-icons";
|
||||||
import type { IRowData } from "@patternfly/react-table";
|
import type { IRowData } from "@patternfly/react-table";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { Link, useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import type ComponentRepresentation from "@keycloak/keycloak-admin-client/lib/defs/componentRepresentation";
|
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 type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
|
||||||
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
|
import type UserRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userRepresentation";
|
||||||
import { useAlerts } from "../components/alert/Alerts";
|
import { useAlerts } from "../components/alert/Alerts";
|
||||||
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
|
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
|
||||||
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
|
|
||||||
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
|
|
||||||
import { ViewHeader } from "../components/view-header/ViewHeader";
|
|
||||||
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
|
|
||||||
import { useRealm } from "../context/realm-context/RealmContext";
|
|
||||||
import { emptyFormatter } from "../util";
|
|
||||||
import { toUser } from "./routes/User";
|
|
||||||
import { toAddUser } from "./routes/AddUser";
|
|
||||||
import helpUrls from "../help-urls";
|
|
||||||
import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner";
|
import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner";
|
||||||
|
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
|
||||||
import { PermissionsTab } from "../components/permission-tab/PermissionTab";
|
import { PermissionsTab } from "../components/permission-tab/PermissionTab";
|
||||||
import { toUsers, UserTab } from "./routes/Users";
|
import { BruteUser, findUsers } from "../components/role-mapping/resource";
|
||||||
import {
|
import {
|
||||||
RoutableTabs,
|
RoutableTabs,
|
||||||
useRoutableTab,
|
useRoutableTab,
|
||||||
} from "../components/routable-tabs/RoutableTabs";
|
} from "../components/routable-tabs/RoutableTabs";
|
||||||
|
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
|
||||||
|
import { ViewHeader } from "../components/view-header/ViewHeader";
|
||||||
import { useAccess } from "../context/access/Access";
|
import { useAccess } from "../context/access/Access";
|
||||||
import { BruteUser, findUsers } from "../components/role-mapping/resource";
|
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
|
||||||
|
import { useRealm } from "../context/realm-context/RealmContext";
|
||||||
|
import helpUrls from "../help-urls";
|
||||||
|
import { emptyFormatter } from "../util";
|
||||||
|
import useIsFeatureEnabled, { Feature } from "../utils/useIsFeatureEnabled";
|
||||||
|
import { toAddUser } from "./routes/AddUser";
|
||||||
|
import { toUser } from "./routes/User";
|
||||||
|
import { UserTab, toUsers } from "./routes/Users";
|
||||||
|
|
||||||
import "./user-section.css";
|
import "./user-section.css";
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ export default function UsersSection() {
|
||||||
const [realm, setRealm] = useState<RealmRepresentation | undefined>();
|
const [realm, setRealm] = useState<RealmRepresentation | undefined>();
|
||||||
const [kebabOpen, setKebabOpen] = useState(false);
|
const [kebabOpen, setKebabOpen] = useState(false);
|
||||||
const [selectedRows, setSelectedRows] = useState<UserRepresentation[]>([]);
|
const [selectedRows, setSelectedRows] = useState<UserRepresentation[]>([]);
|
||||||
const { profileInfo } = useServerInfo();
|
const isFeatureEnabled = useIsFeatureEnabled();
|
||||||
|
|
||||||
const [key, setKey] = useState(0);
|
const [key, setKey] = useState(0);
|
||||||
const refresh = () => setKey(key + 1);
|
const refresh = () => setKey(key + 1);
|
||||||
|
@ -420,9 +420,7 @@ export default function UsersSection() {
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Tab>
|
</Tab>
|
||||||
{!profileInfo?.disabledFeatures?.includes(
|
{isFeatureEnabled(Feature.AdminFineGrainedAuthz) && (
|
||||||
"ADMIN_FINE_GRAINED_AUTHZ"
|
|
||||||
) && (
|
|
||||||
<Tab
|
<Tab
|
||||||
id="permissions"
|
id="permissions"
|
||||||
data-testid="permissionsTab"
|
data-testid="permissionsTab"
|
||||||
|
|
|
@ -1,21 +1,17 @@
|
||||||
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
|
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
|
||||||
|
|
||||||
export enum Feature {
|
export enum Feature {
|
||||||
|
AdminFineGrainedAuthz = "ADMIN_FINE_GRAINED_AUTHZ",
|
||||||
|
ClientPolicies = "CLIENT_POLICIES",
|
||||||
DeclarativeUserProfile = "DECLARATIVE_USER_PROFILE",
|
DeclarativeUserProfile = "DECLARATIVE_USER_PROFILE",
|
||||||
|
Kerberos = "KERBEROS",
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function useIsFeatureEnabled() {
|
export default function useIsFeatureEnabled() {
|
||||||
const { profileInfo } = useServerInfo();
|
const { profileInfo } = useServerInfo();
|
||||||
|
|
||||||
const experimentalFeatures = profileInfo?.experimentalFeatures ?? [];
|
|
||||||
const previewFeatures = profileInfo?.previewFeatures ?? [];
|
|
||||||
const disabledFilters = profileInfo?.disabledFeatures ?? [];
|
const disabledFilters = profileInfo?.disabledFeatures ?? [];
|
||||||
const allFeatures = [...experimentalFeatures, ...previewFeatures];
|
|
||||||
const enabledFeatures = allFeatures.filter(
|
|
||||||
(feature) => !disabledFilters.includes(feature)
|
|
||||||
);
|
|
||||||
|
|
||||||
return function isFeatureEnabled(feature: Feature) {
|
return function isFeatureEnabled(feature: Feature) {
|
||||||
return enabledFeatures.includes(feature);
|
return !disabledFilters.includes(feature);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue