Skip to content

Commit

Permalink
Merge pull request #7087 from pavinduLakshan/improve_console_role_per…
Browse files Browse the repository at this point in the history
…mission
  • Loading branch information
pavinduLakshan authored Nov 5, 2024
2 parents 6945618 + f182ffa commit 6e369b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/serious-turkeys-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/admin.console-settings.v1": patch
---

Only show api resources for enabled features under console role permissions
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import Checkbox from "@oxygen-ui/react/Checkbox";
import Paper from "@oxygen-ui/react/Paper";
import Typography from "@oxygen-ui/react/Typography";
import { ChevronDownIcon } from "@oxygen-ui/react-icons";
import { AppState, FeatureConfigInterface } from "@wso2is/admin.core.v1";
import { CreateRolePermissionInterface } from "@wso2is/admin.roles.v2/models/roles";
import { IdentifiableComponentInterface } from "@wso2is/core/models";
import cloneDeep from "lodash-es/cloneDeep";
Expand All @@ -46,6 +47,7 @@ import React, {
useState
} from "react";
import { useTranslation } from "react-i18next";
import { useSelector } from "react-redux";
import useGetAPIResourceCollections from "../../../api/use-get-api-resource-collections";
import { ConsoleRolesOnboardingConstants } from "../../../constants/console-roles-onboarding-constants";
import {
Expand Down Expand Up @@ -114,6 +116,8 @@ const CreateConsoleRoleWizardPermissionsForm: FunctionComponent<CreateConsoleRol
"apiResources"
);

const featureConfig: FeatureConfigInterface = useSelector((state: AppState) => state.config.ui.features);

const [ expandedAccordions, setExpandedAccordions ] = useState<string[]>([]);
const [ selectedPermissions, setSelectedPermissions ] = useState<SelectedPermissionsInterface>(initialValues || {
organization: {},
Expand Down Expand Up @@ -155,14 +159,14 @@ const CreateConsoleRoleWizardPermissionsForm: FunctionComponent<CreateConsoleRol
cloneDeep(tenantAPIResourceCollections);
const filteringAPIResourceCollectionNames: string[] = [];


filteringAPIResourceCollectionNames.push(
ConsoleRolesOnboardingConstants.ROLE_V1_API_RESOURCES_COLLECTION_NAME);

clonedTenantAPIResourceCollections.apiResourceCollections =
clonedTenantAPIResourceCollections?.apiResourceCollections?.filter(
(item: APIResourceCollectionInterface) =>
!filteringAPIResourceCollectionNames.includes(item?.name)
!filteringAPIResourceCollectionNames.includes(item?.name) &&
featureConfig?.[item?.name]?.enabled
);

return clonedTenantAPIResourceCollections;
Expand Down

0 comments on commit 6e369b6

Please sign in to comment.