Skip to content

Commit

Permalink
Enable API Resources UI in sub organization from View only capability
Browse files Browse the repository at this point in the history
  • Loading branch information
ShanChathusanda93 committed Dec 19, 2024
1 parent 994ba7d commit 8b48582
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 45 deletions.
1 change: 1 addition & 0 deletions apps/console/src/extensions/i18n/models/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ export interface Extensions {
apiResource: {
pageHeader: {
description: string;
subOrgDescription: string;
title: string;
};
empty: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 1 addition & 0 deletions features/admin.api-resources.v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
105 changes: 61 additions & 44 deletions features/admin.api-resources.v2/pages/api-resources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -88,6 +90,7 @@ const APIResourcesPage: FunctionComponent<APIResourcesPageInterface> = (

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,
Expand Down Expand Up @@ -252,7 +255,7 @@ const APIResourcesPage: FunctionComponent<APIResourcesPageInterface> = (
}
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") }
<DocumentationLink
Expand All @@ -261,54 +264,68 @@ const APIResourcesPage: FunctionComponent<APIResourcesPageInterface> = (
{ t("extensions:common.learnMore") }
</DocumentationLink>
</>
) }
) : (
<>
{ t("extensions:develop.apiResource.pageHeader.subOrgDescription") }
<DocumentationLink
link={ getLink("develop.apiResources.learnMore") }
>
{ t("extensions:common.learnMore") }
</DocumentationLink>
</>
)}

Check warning on line 276 in features/admin.api-resources.v2/pages/api-resources.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint (STATIC ANALYSIS) (lts/*, 8.7.4)

A space is required before '}'
data-componentid={ `${ componentId }-page-layout` }
data-testid={ `${ componentId }-page-layout` }
headingColumnWidth="11"
actionColumnWidth="5"
>
<EmphasizedSegment
onClick={ () => {
history.push(APIResourcesConstants.getPaths().get("API_RESOURCES_CATEGORY")
.replace(":categoryId", APIResourceType.MANAGEMENT));
} }
className="clickable"
data-componentid={ `${ componentId }-management-api-container` }
>
<List>
<List.Item>
<Grid container direction="row" xs={ 12 } alignItems="center">
<Grid xs={ 10 } alignContent="center">
<GenericIcon
verticalAlign="middle"
fill="primary"
transparent
icon={ <BuildingGearIcon size="medium" /> }
spaced="right"
floated="left"
className="mt-1"
/>
<List.Header>
{ t("extensions:develop.apiResource.managementAPI.header") }
</List.Header>
<List.Description>
{ t("extensions:develop.apiResource.managementAPI.description") }
</List.Description>
</Grid>
<Grid xs={ 2 }>
<GenericIcon
verticalAlign="middle"
fill="primary"
transparent
icon={ <ChevronRightIcon /> }
spaced="right"
floated="right"
/>
</Grid>
</Grid>
</List.Item>
</List>
</EmphasizedSegment>
{
organizationType !== OrganizationType.SUBORGANIZATION &&
(
<EmphasizedSegment
onClick={ () => {
history.push(APIResourcesConstants.getPaths().get("API_RESOURCES_CATEGORY")
.replace(":categoryId", APIResourceType.MANAGEMENT));
} }
className="clickable"
data-componentid={ `${ componentId }-management-api-container` }
>
<List>
<List.Item>
<Grid container direction="row" xs={ 12 } alignItems="center">
<Grid xs={ 10 } alignContent="center">
<GenericIcon
verticalAlign="middle"
fill="primary"
transparent
icon={ <BuildingGearIcon size="medium" /> }
spaced="right"
floated="left"
className="mt-1"
/>
<List.Header>
{ t("extensions:develop.apiResource.managementAPI.header") }
</List.Header>
<List.Description>
{ t("extensions:develop.apiResource.managementAPI.description") }
</List.Description>
</Grid>
<Grid xs={ 2 }>
<GenericIcon
verticalAlign="middle"
fill="primary"
transparent
icon={ <ChevronRightIcon /> }
spaced="right"
floated="right"
/>
</Grid>
</Grid>
</List.Item>
</List>
</EmphasizedSegment>
)
}
<EmphasizedSegment
onClick={ () => {
history.push(APIResourcesConstants.getPaths().get("API_RESOURCES_CATEGORY")
Expand Down
3 changes: 2 additions & 1 deletion features/admin.core.v1/constants/app-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ export class AppConstants {
"smsTemplates",
"governanceConnectors",
"branding",
"consoleSettings"
"consoleSettings",
"apiResources"
];

/**
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8b48582

Please sign in to comment.