Skip to content

Prefill the deploy endpoint, redeploy suspended deployments, and scope-gate the deploy page - #3407

Open
dakshina99 wants to merge 3 commits into
wso2:mainfrom
dakshina99:apip-deploy-page-refinements
Open

Prefill the deploy endpoint, redeploy suspended deployments, and scope-gate the deploy page#3407
dakshina99 wants to merge 3 commits into
wso2:mainfrom
dakshina99:apip-deploy-page-refinements

Conversation

@dakshina99

Copy link
Copy Markdown
Contributor

Purpose

Three problems on the deploy plugin's page:

  1. The endpoint field started empty. Every deploy and promote made the user retype the backend URL, even though the API already declares one.
  2. A suspended deployment offered "Stop deployment". The button was enabled and could only fail — there was nothing left to stop.
  3. Reaching Deploy without an API in scope was a dead end. The sidebar shows the item at every scope, so clicking it from an organization- or project-level page is normal, but the page override replaced the built-in one along with the ScopeGate it wraps itself in.

Plus two bits of detail shown where they mean nothing: a build id in the "Build and Deploy" dialog (the id of the previous build, while that dialog creates a new one), and an Endpoint URL viewer on gateways with nothing deployed.

Goals

  • Prefill the endpoint from the API's own upstream.main.url, so a first deploy needs no typing.
  • Offer Redeploy on a suspended deployment, restoring that same deployment rather than building anything.
  • Give the overridden Deploy route the same project/API picker every other API-scoped page has.
  • Drop the misleading build id and the endpoint viewer where there is no deployment.

Approach

Endpoint default. deployApi gains readApiEndpointUrl() (GET /rest-apis/{handle}upstream.main.url). DeployFeature reads it once per API — deliberately not inside load(), so it is not re-fetched by the 4-second settling poll — and a failure leaves the rest of the page working. Precedence in the dialog: what the user typed → what this gateway already serves → the API's endpoint → empty. A gateway already running something keeps its own endpoint, so a re-deploy never silently changes it.

Redeploy. The row's single action is now derived from the gateway's state instead of one boolean: suspended restores the deployment (POST .../deployments/{deploymentId}/redeploy), failed re-deploys its build as a new deployment, serving stops. Only stopping is styled destructive. Restoring relies on the deployment being immutable, so the gateway gets back exactly what it was serving — same build, same endpoint, nothing rendered.

Scope gate. The page.apiDeploy override is wrapped in ScopeGate requires="api" to={routes.apiDeploy} at the registration seam, matching the built-in page. Done there rather than in AppRoutes so the open-source route is untouched and ScopeGate's dependencies stay out of the initial bundle, which that file explicitly guards.

UNDEPLOYED already mapped to "Suspended" in the status vocabulary, so no change was needed there.

Documentation

N/A — no new user-facing concepts; the deploy page's existing controls behave correctly rather than differently.

Automation tests

  • Unit tests

    None: these packages carry no test setup (their build script is tsc --noEmit), and this change adds no runtime module worth standing one up for. Verified by typecheck — tsc --noEmit clean on apip-cloud-ui-deploy, and the host package reports the same 27 pre-existing import.meta.env errors before and after, so the wider import graph adds none.

  • Integration tests

    Exercised by hand against a running console: first deploy prefilled from the API's upstream, a suspended gateway offering Redeploy and coming back on the same build, and the Deploy item from an organization-level page showing the project/API picker.

Security checks

  • Followed secure coding standards: yes
  • Ran FindSecurityBugs plugin and verified report: N/A — TypeScript only
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets: yes

Samples

Deploy page states: a gateway with nothing deployed shows no build id and no endpoint viewer; a suspended one shows Suspended with Redeploy; a serving one shows Active with Stop deployment.

Related PRs

Redeploy calls a redeploy route on the deployment API the plugin talks to, which is added alongside this change; the rest is self-contained.

Test environment

Node 24, Chrome, macOS (arm64).

dakshina99 and others added 3 commits September 8, 2026 23:45
…y detail

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…not work

An undeployed deployment already read as "Suspended", but the row still offered
"Stop deployment" — enabled, and certain to fail, since there was nothing left
to stop. It now offers Redeploy, which restores that same deployment: the
deployment is immutable, so the gateway gets back exactly what it was serving,
with no build and no re-render.

The row's single action is now chosen from the gateway's state rather than from
one boolean: suspended restores the deployment, failed re-deploys its build (a
new deployment), and serving stops. Only stopping is styled as destructive.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The override replaces the built-in Deploy page, and with it the ScopeGate that
page wraps itself in — so reaching Deploy from an organization- or project-level
page ended at "Open an API within a project to deploy it." with no way forward.
The sidebar shows the item at every scope, so getting there without an API in
scope is a normal thing to do.

Re-applying the gate gives that route the same project/API picker every other
API-scoped page has, which navigates to the fully scoped URL.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 93e1c0c6-d096-4008-85f3-3b3fbce0dbd8

📥 Commits

Reviewing files that changed from the base of the PR and between 60dd7b9 and 23260d1.

📒 Files selected for processing (7)
  • portals/cloud-plugins/apip-cloud-ui-deploy/src/DeployFeature.tsx
  • portals/cloud-plugins/apip-cloud-ui-deploy/src/DeployPage.tsx
  • portals/cloud-plugins/apip-cloud-ui-deploy/src/components/DeployDialog.tsx
  • portals/cloud-plugins/apip-cloud-ui-deploy/src/components/EnvironmentCard.tsx
  • portals/cloud-plugins/apip-cloud-ui-deploy/src/components/GatewayRow.tsx
  • portals/cloud-plugins/apip-cloud-ui-deploy/src/deployApi.ts
  • portals/cloud-plugins/apip-cloud-ui/src/hosts/api-control-plane.tsx

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The deployment UI now loads an API backend URL for initial deployments, supports redeploy actions for undeployed gateways, updates deployment dialog behavior, and restores API scope gating for the cloud plugin.

Changes

Deployment flow

Layer / File(s) Summary
Endpoint initialization and deploy dialog
portals/cloud-plugins/apip-cloud-ui-deploy/src/deployApi.ts, portals/cloud-plugins/apip-cloud-ui-deploy/src/DeployFeature.tsx, portals/cloud-plugins/apip-cloud-ui-deploy/src/DeployPage.tsx, portals/cloud-plugins/apip-cloud-ui-deploy/src/components/DeployDialog.tsx
The deployment client reads upstream.main.url. DeployFeature passes the value to DeployDialog, which uses it as the endpoint fallback. The dialog no longer shows the Build section when creating a build.
Gateway redeployment actions
portals/cloud-plugins/apip-cloud-ui-deploy/src/components/GatewayRow.tsx, portals/cloud-plugins/apip-cloud-ui-deploy/src/components/EnvironmentCard.tsx, portals/cloud-plugins/apip-cloud-ui-deploy/src/DeployPage.tsx, portals/cloud-plugins/apip-cloud-ui-deploy/src/DeployFeature.tsx, portals/cloud-plugins/apip-cloud-ui-deploy/src/deployApi.ts
Gateway actions now select redeploy, retry, or stop from gateway status. Redeploy requests use the deployment redeploy endpoint with environment and gateway query parameters.
API scope gating
portals/cloud-plugins/apip-cloud-ui/src/hosts/api-control-plane.tsx
The deploy extension now requires API scope and redirects to routes.apiDeploy when no API is in scope.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: 🟡 Moderate · up to 23260

The deployment dialog now prefills endpoints from the selected API. Switching APIs while that lookup is in flight can leave a prior API’s endpoint in the dialog, creating a risk of deploying to the wrong backend unless the response is scoped to the current API.

Sequence Diagram(s)

sequenceDiagram
  participant GatewayRow
  participant EnvironmentCard
  participant DeployPage
  participant DeployFeature
  participant deployApi
  GatewayRow->>EnvironmentCard: invoke onRedeploy
  EnvironmentCard->>DeployPage: pass gatewayId
  DeployPage->>DeployFeature: invoke onRedeployGateway
  DeployFeature->>deployApi: POST deployment /redeploy
  deployApi-->>DeployFeature: redeploy result
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the three main changes: endpoint prefilling, redeployment of suspended deployments, and scope gating.
Description check ✅ Passed The description is complete and follows the repository template. It explains the purpose, goals, approach, user-facing states, documentation impact, testing, security checks, related work, and test en…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 7 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant