From 2b987be971f9ce5a11fa434ac0f999832ec6009b Mon Sep 17 00:00:00 2001 From: Shan Chathusanda Jayathilaka Date: Thu, 19 Dec 2024 13:00:53 +0530 Subject: [PATCH] Enable API Resources UI in sub organization from View only capability --- .../src/extensions/i18n/models/extensions.ts | 1 + .../i18n/resources/en-US/extensions.ts | 1 + features/admin.api-resources.v2/package.json | 1 + .../pages/api-resources.tsx | 103 ++++++++++-------- .../admin.core.v1/constants/app-constants.ts | 3 +- pnpm-lock.yaml | 3 + 6 files changed, 68 insertions(+), 44 deletions(-) diff --git a/apps/console/src/extensions/i18n/models/extensions.ts b/apps/console/src/extensions/i18n/models/extensions.ts index 6a9e303f7e8..f27ca50995b 100755 --- a/apps/console/src/extensions/i18n/models/extensions.ts +++ b/apps/console/src/extensions/i18n/models/extensions.ts @@ -327,6 +327,7 @@ export interface Extensions { apiResource: { pageHeader: { description: string; + subOrgDescription: string; title: string; }; empty: string; diff --git a/apps/console/src/extensions/i18n/resources/en-US/extensions.ts b/apps/console/src/extensions/i18n/resources/en-US/extensions.ts index 8883120e4a2..2aba73ca8be 100755 --- a/apps/console/src/extensions/i18n/resources/en-US/extensions.ts +++ b/apps/console/src/extensions/i18n/resources/en-US/extensions.ts @@ -473,6 +473,7 @@ export const extensions: Extensions = { apiResource: { pageHeader: { description: "Create and manage the APIs used to define the API scopes/permissions that can be consumed by your applications.", + subOrgDescription: "View the APIs used to define the API scopes/permissions that can be consumed by your applications.", title: "API Resources" }, empty: "There are no API resources available at the moment.", diff --git a/features/admin.api-resources.v2/package.json b/features/admin.api-resources.v2/package.json index df29be32438..011c4395f16 100644 --- a/features/admin.api-resources.v2/package.json +++ b/features/admin.api-resources.v2/package.json @@ -22,6 +22,7 @@ "@wso2is/forms": "^2.3.5", "@wso2is/react-components": "^2.8.10", "@wso2is/admin.core.v1": "^2.34.59", + "@wso2is/admin.organizations.v1": "^2.26.59", "axios": "^0.19.2", "i18next": "^21.9.1", "node-forge": "^0.10.0", diff --git a/features/admin.api-resources.v2/pages/api-resources.tsx b/features/admin.api-resources.v2/pages/api-resources.tsx index d3b00eaa024..087cb87a270 100644 --- a/features/admin.api-resources.v2/pages/api-resources.tsx +++ b/features/admin.api-resources.v2/pages/api-resources.tsx @@ -25,6 +25,8 @@ import { getEmptyPlaceholderIllustrations, history } from "@wso2is/admin.core.v1"; +import { OrganizationType } from "@wso2is/admin.organizations.v1/constants"; +import { useGetCurrentOrganizationType } from "@wso2is/admin.organizations.v1/hooks/use-get-organization-type"; import { IdentityAppsApiException } from "@wso2is/core/exceptions"; import { AlertInterface, AlertLevels, IdentifiableComponentInterface, LinkInterface } from "@wso2is/core/models"; import { addAlert } from "@wso2is/core/store"; @@ -88,6 +90,7 @@ const APIResourcesPage: FunctionComponent = ( const featureConfig: FeatureConfigInterface = useSelector((state: AppState) => state.config.ui.features); const allowedScopes: string = useSelector((state: AppState) => state?.auth?.allowedScopes); + const { organizationType } = useGetCurrentOrganizationType(); const { data: apiResourcesListData, @@ -252,7 +255,7 @@ const APIResourcesPage: FunctionComponent = ( } pageTitle={ t("extensions:develop.apiResource.pageHeader.title") } title={ t("extensions:develop.apiResource.pageHeader.title") } - description={ ( + description={ organizationType !== OrganizationType.SUBORGANIZATION ? ( <> { t("extensions:develop.apiResource.pageHeader.description") } = ( { t("extensions:common.learnMore") } + ) : ( + <> + { t("extensions:develop.apiResource.pageHeader.subOrgDescription") } + + { t("extensions:common.learnMore") } + + ) } data-componentid={ `${ componentId }-page-layout` } data-testid={ `${ componentId }-page-layout` } headingColumnWidth="11" actionColumnWidth="5" > - { - history.push(APIResourcesConstants.getPaths().get("API_RESOURCES_CATEGORY") - .replace(":categoryId", APIResourceType.MANAGEMENT)); - } } - className="clickable" - data-componentid={ `${ componentId }-management-api-container` } - > - - - - - } - spaced="right" - floated="left" - className="mt-1" - /> - - { t("extensions:develop.apiResource.managementAPI.header") } - - - { t("extensions:develop.apiResource.managementAPI.description") } - - - - } - spaced="right" - floated="right" - /> - - - - - + { + organizationType !== OrganizationType.SUBORGANIZATION && + ( + { + history.push(APIResourcesConstants.getPaths().get("API_RESOURCES_CATEGORY") + .replace(":categoryId", APIResourceType.MANAGEMENT)); + } } + className="clickable" + data-componentid={ `${ componentId }-management-api-container` } + > + + + + + } + spaced="right" + floated="left" + className="mt-1" + /> + + { t("extensions:develop.apiResource.managementAPI.header") } + + + { t("extensions:develop.apiResource.managementAPI.description") } + + + + } + spaced="right" + floated="right" + /> + + + + + + ) + } { history.push(APIResourcesConstants.getPaths().get("API_RESOURCES_CATEGORY") diff --git a/features/admin.core.v1/constants/app-constants.ts b/features/admin.core.v1/constants/app-constants.ts index da04261f20c..1c8282a7a5b 100644 --- a/features/admin.core.v1/constants/app-constants.ts +++ b/features/admin.core.v1/constants/app-constants.ts @@ -483,7 +483,8 @@ export class AppConstants { "smsTemplates", "governanceConnectors", "branding", - "consoleSettings" + "consoleSettings", + "apiResources" ]; /** diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 421d1c3ad1d..f9409f85aaa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2268,6 +2268,9 @@ importers: '@wso2is/admin.core.v1': specifier: ^2.34.59 version: link:../admin.core.v1 + '@wso2is/admin.organizations.v1': + specifier: ^2.26.59 + version: link:../admin.organizations.v1 '@wso2is/core': specifier: ^2.5.1 version: link:../../modules/core