-
Notifications
You must be signed in to change notification settings - Fork 103
Add API Portal Provision UI to API Control Plane #3220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Pranavan-S
wants to merge
29
commits into
wso2:main
Choose a base branch
from
Pranavan-S:feature/apip-devportal
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
eef5b28
Add Dev Portal feature with routing and UI components
Pranavan-S 909f97d
Add Dev Portal management features including creation and listing
Pranavan-S 89196fe
Add delete functionality for Dev Portals with UI integration
Pranavan-S 1aea97d
Enhance Dev Portal creation with IDP client credentials support
Pranavan-S b22af5a
Add Dev Portal detail and update features with IDP client credentials…
Pranavan-S 44ea907
Fix menu interaction in DevPortalCard to prevent unintended opens
Pranavan-S be6a7cb
Validate URLs in Dev Portal forms and provide user feedback for inval…
Pranavan-S 99f4bf6
Add stsTokenUrl and clientId to DevPortal type and update related fun…
Pranavan-S 9045a76
Rename form labels for clarity in DevPortal creation and detail pages
Pranavan-S e6ed27a
Add identifier editing and view toggle functionality in DevPortal cre…
Pranavan-S 8eecbbe
Add helper text for handle input validation in DevPortal creation
Pranavan-S 4c754cd
Make identifier field read-only when locked in DevPortal creation
Pranavan-S 9b88830
Refactored devportal to api-portal in the newly added UI
Pranavan-S 0c8b90c
Rename references from 'Devportal' to 'API Portal' in OverviewTab and…
Pranavan-S 00ec7d1
Update references from 'developer portal' to 'API Portal' in various …
Pranavan-S 192ae51
Enhance API Portal update handling by synchronously updating local fi…
Pranavan-S fecc926
Add organizationId to ApiPortal type and update related API client me…
Pranavan-S a7ef3e2
Fix slugify function to ensure leading and trailing hyphens are remov…
Pranavan-S 21f2c37
Pass orgHandle to useCreateApiPortal for context-specific API creation
Pranavan-S 81524c6
Trim whitespace from API Portal name before saving
Pranavan-S 8833dd6
Improve clipboard copy handling in ApiPortalCard for better user feed…
Pranavan-S 1aba6be
Enhance ApiPortalCard and ApiPortalRow to manage menu state and acces…
Pranavan-S 619dc2f
Refactor API portal input types and update creation/updating logic fo…
Pranavan-S 6caf53b
Rename DEV_PORTAL constants to API_PORTAL for consistency in authenti…
Pranavan-S 169ae5a
Add mock API handling for API Portal operations with appropriate erro…
Pranavan-S a6f1b16
Add tests for ApiPortalCreatePage to validate form submission and inp…
Pranavan-S f547c4b
Enable API Portal routes conditionally based on mock API status
Pranavan-S ba8059e
Refactor organization ID retrieval to throw an error if not found
Pranavan-S a2d28b4
Add htmlFor attributes to FormLabel components for improved accessibi…
Pranavan-S File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 160 additions & 0 deletions
160
portals/api-control-plane/src/api/apiportal/apiPortalClient.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| /* | ||
| * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com). | ||
| * | ||
| * WSO2 LLC. licenses this file to you under the Apache License, | ||
| * Version 2.0 (the "License"); you may not use this file except | ||
| * in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import type { | ||
| CreateApiPortalInput, | ||
| ApiPortal, | ||
| UpdateApiPortalInput, | ||
| } from '../../types/domain'; | ||
| import { toApiPortal } from '../adapters'; | ||
| import { apiPortals, organizations } from '../mocks/data'; | ||
| import { delay, useMockApi } from '../shared/apiClientUtils'; | ||
| import { ApiError } from '../types/errors'; | ||
|
|
||
| /** | ||
| * API Portal management has no platform-api backend yet (console-only feature | ||
| * for now) — unlike gatewayClient, there is no real REST endpoint to call, so | ||
| * there's no usePlatformApi() branch. Every method still gates on | ||
| * useMockApi() so a non-mock deployment gets an explicit error/empty result | ||
| * instead of silently writing to (and reading back from) the in-memory mock | ||
| * store as if it were persisted. Swap the `!useMockApi()` branches for a real | ||
| * client (platformGet/platformPost against ApiPortalResponse) once | ||
| * platform-api adds one. | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| */ | ||
|
|
||
| const requireOrganizationId = (orgHandle: string): string => { | ||
| const organization = organizations.find((item) => item.handle === orgHandle); | ||
| if (!organization) { | ||
| throw new ApiError('Organization not found', 'NOT_FOUND', 404); | ||
| } | ||
| return organization.id; | ||
| }; | ||
|
|
||
| export async function listApiPortals(orgHandle: string): Promise<ApiPortal[]> { | ||
| if (!useMockApi()) { | ||
| return []; | ||
| } | ||
| await delay(); | ||
| const orgId = requireOrganizationId(orgHandle); | ||
| return apiPortals | ||
| .filter((item) => item.organizationId === orgId) | ||
| .map(toApiPortal); | ||
| } | ||
|
|
||
| export async function getApiPortal( | ||
| orgHandle: string, | ||
| id: string | ||
| ): Promise<ApiPortal | undefined> { | ||
| if (!useMockApi()) { | ||
| return undefined; | ||
| } | ||
| await delay(); | ||
| const orgId = requireOrganizationId(orgHandle); | ||
| const found = apiPortals.find( | ||
| (item) => item.id === id && item.organizationId === orgId | ||
| ); | ||
| return found ? toApiPortal(found) : undefined; | ||
| } | ||
|
|
||
| export async function createApiPortal( | ||
| orgHandle: string, | ||
| input: CreateApiPortalInput | ||
| ): Promise<ApiPortal> { | ||
| if (!useMockApi()) { | ||
| throw new ApiError('API Portal creation requires the platform API', 'UNKNOWN'); | ||
| } | ||
| await delay(); | ||
| const orgId = requireOrganizationId(orgHandle); | ||
| if (apiPortals.some((item) => item.organizationId === orgId && item.handle === input.handle)) { | ||
| throw new ApiError( | ||
| 'API Portal handle already exists in organization', | ||
| 'CONFLICT', | ||
| 409 | ||
| ); | ||
| } | ||
| // Picked explicitly (not `...input`) so `clientSecret` — the one genuinely | ||
| // write-only field — never ends up on the stored/returned record. | ||
| // stsTokenUrl/clientId are not secret and are stored/returned normally. | ||
| const apiPortal: ApiPortal = { | ||
| id: input.handle, | ||
| name: input.name, | ||
| handle: input.handle, | ||
| description: input.description, | ||
| url: input.url, | ||
| authType: input.authType, | ||
| stsTokenUrl: | ||
| input.authType === 'idp_client_credentials' ? input.stsTokenUrl : undefined, | ||
| clientId: | ||
| input.authType === 'idp_client_credentials' ? input.clientId : undefined, | ||
| workflowStatus: 'pending', | ||
| createdAt: new Date().toISOString(), | ||
| organizationId: orgId, | ||
| }; | ||
| apiPortals.push(apiPortal); | ||
| return toApiPortal(apiPortal); | ||
| } | ||
|
|
||
| export async function updateApiPortal( | ||
| orgHandle: string, | ||
| id: string, | ||
| input: UpdateApiPortalInput | ||
| ): Promise<ApiPortal> { | ||
| if (!useMockApi()) { | ||
| throw new ApiError('API Portal update requires the platform API', 'UNKNOWN'); | ||
| } | ||
| await delay(); | ||
| const orgId = requireOrganizationId(orgHandle); | ||
| const index = apiPortals.findIndex( | ||
| (item) => item.id === id && item.organizationId === orgId | ||
| ); | ||
| if (index < 0) { | ||
| throw new ApiError('API Portal not found', 'NOT_FOUND', 404); | ||
| } | ||
| // Same reasoning as createApiPortal: only clientSecret is excluded. | ||
| const updated: ApiPortal = { | ||
| ...apiPortals[index], | ||
| name: input.name, | ||
| description: input.description, | ||
| url: input.url, | ||
| authType: input.authType, | ||
| stsTokenUrl: | ||
| input.authType === 'idp_client_credentials' ? input.stsTokenUrl : undefined, | ||
| clientId: | ||
| input.authType === 'idp_client_credentials' ? input.clientId : undefined, | ||
| }; | ||
| apiPortals[index] = updated; | ||
| return toApiPortal(updated); | ||
| } | ||
|
|
||
| export async function deleteApiPortal( | ||
| orgHandle: string, | ||
| id: string | ||
| ): Promise<void> { | ||
| if (!useMockApi()) { | ||
| throw new ApiError('API Portal deletion requires the platform API', 'UNKNOWN'); | ||
| } | ||
| await delay(); | ||
| const orgId = requireOrganizationId(orgHandle); | ||
| const index = apiPortals.findIndex( | ||
| (item) => item.id === id && item.organizationId === orgId | ||
| ); | ||
| if (index < 0) { | ||
| throw new ApiError('API Portal not found', 'NOT_FOUND', 404); | ||
| } | ||
| apiPortals.splice(index, 1); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.