Skip to content
Open
Show file tree
Hide file tree
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 Aug 10, 2026
909f97d
Add Dev Portal management features including creation and listing
Pranavan-S Aug 10, 2026
89196fe
Add delete functionality for Dev Portals with UI integration
Pranavan-S Aug 10, 2026
1aea97d
Enhance Dev Portal creation with IDP client credentials support
Pranavan-S Aug 10, 2026
b22af5a
Add Dev Portal detail and update features with IDP client credentials…
Pranavan-S Aug 10, 2026
44ea907
Fix menu interaction in DevPortalCard to prevent unintended opens
Pranavan-S Aug 10, 2026
be6a7cb
Validate URLs in Dev Portal forms and provide user feedback for inval…
Pranavan-S Aug 10, 2026
99f4bf6
Add stsTokenUrl and clientId to DevPortal type and update related fun…
Pranavan-S Aug 10, 2026
9045a76
Rename form labels for clarity in DevPortal creation and detail pages
Pranavan-S Aug 10, 2026
e6ed27a
Add identifier editing and view toggle functionality in DevPortal cre…
Pranavan-S Aug 10, 2026
8eecbbe
Add helper text for handle input validation in DevPortal creation
Pranavan-S Aug 11, 2026
4c754cd
Make identifier field read-only when locked in DevPortal creation
Pranavan-S Aug 11, 2026
9b88830
Refactored devportal to api-portal in the newly added UI
Pranavan-S Aug 13, 2026
0c8b90c
Rename references from 'Devportal' to 'API Portal' in OverviewTab and…
Pranavan-S Aug 13, 2026
00ec7d1
Update references from 'developer portal' to 'API Portal' in various …
Pranavan-S Aug 13, 2026
192ae51
Enhance API Portal update handling by synchronously updating local fi…
Pranavan-S Aug 13, 2026
fecc926
Add organizationId to ApiPortal type and update related API client me…
Pranavan-S Aug 13, 2026
a7ef3e2
Fix slugify function to ensure leading and trailing hyphens are remov…
Pranavan-S Aug 13, 2026
21f2c37
Pass orgHandle to useCreateApiPortal for context-specific API creation
Pranavan-S Aug 13, 2026
81524c6
Trim whitespace from API Portal name before saving
Pranavan-S Aug 13, 2026
8833dd6
Improve clipboard copy handling in ApiPortalCard for better user feed…
Pranavan-S Aug 13, 2026
1aba6be
Enhance ApiPortalCard and ApiPortalRow to manage menu state and acces…
Pranavan-S Aug 13, 2026
619dc2f
Refactor API portal input types and update creation/updating logic fo…
Pranavan-S Aug 13, 2026
6caf53b
Rename DEV_PORTAL constants to API_PORTAL for consistency in authenti…
Pranavan-S Aug 13, 2026
169ae5a
Add mock API handling for API Portal operations with appropriate erro…
Pranavan-S Aug 13, 2026
a6f1b16
Add tests for ApiPortalCreatePage to validate form submission and inp…
Pranavan-S Aug 13, 2026
f547c4b
Enable API Portal routes conditionally based on mock API status
Pranavan-S Aug 13, 2026
ba8059e
Refactor organization ID retrieval to throw an error if not found
Pranavan-S Aug 13, 2026
a2d28b4
Add htmlFor attributes to FormLabel components for improved accessibi…
Pranavan-S Aug 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions portals/api-control-plane/src/api/ApiClientProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,26 @@ import { createContext, type ReactNode, useContext } from 'react';
import {
createApi,
createApiKey,
createApiPortal,
createGateway,
createGatewayToken,
createProject,
deleteApi,
deleteApiPortal,
deleteGatewayDeployment,
deleteProject,
deployApi,
getApi,
getApiDetail,
getApiProxy,
getApiPortal,
getGateway,
getOrganization,
getProject,
listApiKeys,
listApis,
listDeployments,
listApiPortals,
listEnvironments,
listGatewayDeployments,
listGateways,
Expand All @@ -46,6 +50,7 @@ import {
revokeApiKey,
undeployGatewayDeployment,
updateApi,
updateApiPortal,
} from './mvpApi';
import {
getPolicyDefinition,
Expand Down Expand Up @@ -79,6 +84,12 @@ export const realApiClient = {
getGateway,
createGateway,
createGatewayToken,
// API Portals
listApiPortals,
getApiPortal,
createApiPortal,
updateApiPortal,
deleteApiPortal,
// gateway deployments (the deploy path)
listGatewayDeployments,
deployApi,
Expand Down
48 changes: 48 additions & 0 deletions portals/api-control-plane/src/api/adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import type {
ApiKind,
ApiStatus,
Deployment,
ApiPortal,
ApiPortalAuthType,
ApiPortalWorkflowStatus,
Environment,
Gateway,
GatewayDeployment,
Expand Down Expand Up @@ -298,6 +301,51 @@ export const toGateway = (value: unknown): Gateway => {
};
};

const API_PORTAL_AUTH_TYPES: ApiPortalAuthType[] = [
'local',
'idp_client_credentials',
];

const asApiPortalAuthType = (value: unknown): ApiPortalAuthType => {
const normalized = asString(value).toLowerCase();
return API_PORTAL_AUTH_TYPES.includes(normalized as ApiPortalAuthType)
? (normalized as ApiPortalAuthType)
: API_PORTAL_AUTH_TYPES[0];
};

const API_PORTAL_WORKFLOW_STATUSES: ApiPortalWorkflowStatus[] = [
'pending',
'active',
'failed',
];

const asApiPortalWorkflowStatus = (value: unknown): ApiPortalWorkflowStatus => {
const normalized = asString(value).toLowerCase();
return API_PORTAL_WORKFLOW_STATUSES.includes(
normalized as ApiPortalWorkflowStatus
)
? (normalized as ApiPortalWorkflowStatus)
: API_PORTAL_WORKFLOW_STATUSES[0];
};

export const toApiPortal = (value: unknown): ApiPortal => {
const source = asRecord(value);
const name = asString(source.name, 'unknown-api-portal');
return {
id: asString(source.id, name),
name,
handle: asString(source.handle, name),
description: asOptionalString(source.description),
url: asOptionalString(source.url),
workflowStatus: asApiPortalWorkflowStatus(source.workflowStatus),
authType: asApiPortalAuthType(source.authType),
createdAt: asOptionalString(source.createdAt),
stsTokenUrl: asOptionalString(source.stsTokenUrl),
clientId: asOptionalString(source.clientId),
organizationId: asOptionalString(source.organizationId),
};
};

const GATEWAY_DEPLOYMENT_STATUSES: GatewayDeploymentStatus[] = [
'DEPLOYED',
'UNDEPLOYED',
Expand Down
160 changes: 160 additions & 0 deletions portals/api-control-plane/src/api/apiportal/apiPortalClient.ts
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.
Comment thread
Pranavan-S marked this conversation as resolved.
Comment thread
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);
}
97 changes: 97 additions & 0 deletions portals/api-control-plane/src/api/hooks/useMvpQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ import type {
ApiDetail,
CreateApiInput,
CreateApiKeyInput,
CreateApiPortalInput,
CreateGatewayInput,
CreateProjectInput,
DeployApiInput,
ApiPortal,
GatewayDeployment,
Project,
UpdateApiPortalInput,
} from '../../types/domain';
import { useApiClient } from '../ApiClientProvider';

Expand Down Expand Up @@ -58,6 +61,9 @@ export const queryKeys = {
gateways: (orgHandle: string) => ['gateways', orgHandle] as const,
gateway: (orgHandle: string, gatewayId: string) =>
['gateway', orgHandle, gatewayId] as const,
apiPortals: (orgHandle: string) => ['apiPortals', orgHandle] as const,
apiPortal: (orgHandle: string, apiPortalId: string) =>
['apiPortal', orgHandle, apiPortalId] as const,
};

/**
Expand Down Expand Up @@ -532,6 +538,97 @@ export const useCreateGatewayToken = (
});
};

export const useApiPortals = (orgHandleArg?: string) => {
const client = useApiClient();
const { orgHandle } = useScopeArgs(orgHandleArg);
return useQuery({
queryKey: queryKeys.apiPortals(orgHandle || ''),
queryFn: () => {
if (!orgHandle) {
throw new Error('orgHandle is required to list API Portals');
}
return client.listApiPortals(orgHandle);
},
enabled: !!orgHandle,
});
};

export const useApiPortal = (orgHandleArg?: string, apiPortalId?: string) => {
const client = useApiClient();
const { orgHandle } = useScopeArgs(orgHandleArg);
return useQuery({
queryKey: queryKeys.apiPortal(orgHandle || '', apiPortalId || ''),
queryFn: () => {
if (!orgHandle) {
throw new Error('orgHandle is required to fetch an API Portal');
}
if (!apiPortalId) {
throw new Error('apiPortalId is required to fetch an API Portal');
}
return client.getApiPortal(orgHandle, apiPortalId);
},
enabled: !!orgHandle && !!apiPortalId,
});
};

export const useCreateApiPortal = (orgHandleArg?: string) => {
const client = useApiClient();
const queryClient = useQueryClient();
const { orgHandle = '' } = useScopeArgs(orgHandleArg);
return useMutation({
mutationFn: (input: CreateApiPortalInput) =>
client.createApiPortal(orgHandle, input),
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: queryKeys.apiPortals(orgHandle),
});
},
});
};

export const useUpdateApiPortal = (
orgHandleArg?: string,
apiPortalId = ''
) => {
const client = useApiClient();
const queryClient = useQueryClient();
const { orgHandle = '' } = useScopeArgs(orgHandleArg);
return useMutation({
mutationFn: (input: UpdateApiPortalInput) =>
client.updateApiPortal(orgHandle, apiPortalId, input),
onSuccess: (updated) => {
// Write the response into the cache synchronously so callers reading
// this query (e.g. a dirty-state check) see the saved values
// immediately, rather than waiting on the background refetch below.
queryClient.setQueryData(
queryKeys.apiPortal(orgHandle, updated.id),
updated
);
queryClient.invalidateQueries({
queryKey: queryKeys.apiPortal(orgHandle, updated.id),
});
queryClient.invalidateQueries({
queryKey: queryKeys.apiPortals(orgHandle),
});
},
});
};

export const useDeleteApiPortal = (orgHandleArg?: string) => {
const client = useApiClient();
const queryClient = useQueryClient();
const { orgHandle = '' } = useScopeArgs(orgHandleArg);
return useMutation({
mutationFn: (apiPortal: ApiPortal) =>
client.deleteApiPortal(orgHandle, apiPortal.id),
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: queryKeys.apiPortals(orgHandle),
});
},
});
};

export const useCreateApi = (
orgHandleArg?: string,
projectHandlerArg?: string
Expand Down
Loading
Loading