Skip to content

Add pagination for devportal application subscriptions list#1390

Merged
PasanT9 merged 4 commits into
wso2:mainfrom
PasanT9:fix-17318-apim-main
Jul 13, 2026
Merged

Add pagination for devportal application subscriptions list#1390
PasanT9 merged 4 commits into
wso2:mainfrom
PasanT9:fix-17318-apim-main

Conversation

@PasanT9

@PasanT9 PasanT9 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Devportal's "Subscriptions" tab for an application fetched every subscription for that application in a single request (up to app.subscriptionLimit, default 1000). The devportal REST endpoint enriches every returned subscription with several DB lookups, so applications with large subscription counts (e.g. 264) took over a minute to load.
  • Switches the subscriptions list to real backend-paginated fetches (10 per page) via a shared TablePagination control, so only the visible page's subscriptions are enriched per request. Because the subscriptions endpoint has no per-type filter, a fetched page is split client-side into the existing "Subscribed APIs" / "Subscribed MCP Servers" sections.
  • The "all subscriptions are pseudo/subscriptionless" check and the "Subscribe to API(s)/MCP Server(s)" dialogs need the complete subscription list (not just the current page); these now load the full list on demand only when required, instead of on every page load.
  • Consolidates SubscriptionTableData's two separate per-row API/MCP Server detail fetches (tier list + monetization status) into one cached fetch, cutting duplicate per-row API calls.
  • Removes a redundant, immediately-overwritten getSubscriptions call in the API details page.

Source fix

https://github.com/wso2-support/apim-apps/pull/720

Tracking issue

wso2/api-manager#5082

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dbca890f-655d-41b7-a9a6-bf32f6cf1602

📥 Commits

Reviewing files that changed from the base of the PR and between f4894e5 and d6e966f.

📒 Files selected for processing (2)
  • portals/devportal/src/main/webapp/source/src/app/components/Applications/Details/SubscriptionTableData.jsx
  • portals/devportal/src/main/webapp/source/src/app/components/Applications/Details/Subscriptions.jsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • portals/devportal/src/main/webapp/source/src/app/components/Applications/Details/SubscriptionTableData.jsx
  • portals/devportal/src/main/webapp/source/src/app/components/Applications/Details/Subscriptions.jsx

📝 Walkthrough

Walkthrough

Subscription loading now supports offset-based retrieval, incremental API/MCP accumulation, paginated subscription tables, cached entity lookups, and separately loaded subscription dialogs.

Changes

Subscription pagination flow

Layer / File(s) Summary
Subscription retrieval contracts
portals/devportal/.../data/Subscription.jsx, portals/devportal/.../components/Apis/Details/index.jsx
Subscription retrieval accepts offsets, while API detail queries use a bounded subscription limit.
Incremental subscription loading
portals/devportal/.../components/Applications/Details/Subscriptions.jsx
Subscriptions are loaded in chunks, accumulated by type, refreshed after mutations, and prepared separately for dialogs.
Subscription row detail resolution
portals/devportal/.../components/Applications/Details/SubscriptionTableData.jsx
Rows use injected API, MCP server, and policy lookups to resolve tiers, monetization, and dynamic usage status.
Paginated subscription presentation
portals/devportal/.../components/Applications/Details/SubscriptionSection.jsx, portals/devportal/.../components/Applications/Details/Subscriptions.jsx
Subscription tables receive paginated data and lookup callbacks, render pagination controls, and display loading states for dialog data.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Subscriptions
  participant Subscription
  participant SubscriptionsAPI
  participant SubscriptionSection
  Subscriptions->>Subscription: getSubscriptions(limit, offset)
  Subscription->>SubscriptionsAPI: get_subscriptions(limit, offset)
  SubscriptionsAPI-->>Subscription: subscription page
  Subscription-->>Subscriptions: accumulated API/MCP subscriptions
  Subscriptions->>SubscriptionSection: paginated rows and counts
  SubscriptionSection->>Subscriptions: request page change
  Subscriptions->>Subscription: load additional subscription chunks
Loading

Suggested reviewers: lasanthas, krishanx92, tharikagithub, heshansudarshana, hisanhunais

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding pagination to the Devportal application subscriptions list.
Description check ✅ Passed The description accurately covers the pagination refactor and related subscription-data changes in the PR.
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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@portals/devportal/src/main/webapp/source/src/app/components/Applications/Details/Subscriptions.jsx`:
- Around line 317-318: The initial loading logic in the subscription details
component forces ten items of both subscription types, causing unnecessary
full-list traversal when a type has fewer items or is disabled. Update the
`ensureLoaded` calls in the mount path and the referenced refresh path to derive
each required count from the subscription-type accessibility flags, using zero
for disabled types; preserve independent pagination where possible by applying
backend type filters or counts.
- Around line 364-388: Update getAPIById, getMCPServerById, and
getSubscriptionPolicyByName so each cached lookup promise removes its
corresponding apiUUID or policyName entry from the relevant cache when rejected,
then rethrows the error. Preserve successful caching and ensure cleanup only
deletes the matching in-flight promise.
- Around line 444-455: The error handler in the subscription-loading flow must
not mark failed requests as fully loaded. Update the catch logic associated with
the subscription request and its callers to preserve an error state or
rethrow/reject for 5xx and network failures, while retaining the existing
404/401 handling; set completion flags only after confirmed subscription
exhaustion so retries remain possible.

In
`@portals/devportal/src/main/webapp/source/src/app/components/Applications/Details/SubscriptionTableData.jsx`:
- Line 106: Update the row logic around checkIfDynamicUsagePolicy and the
related code at lines 209–232 to use the throttlingPolicy already available on
this.props.subscription instead of calling getSubscription(subscriptionId).
Remove the redundant per-row request while preserving the existing policy
evaluation behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b5539be2-7acc-4e01-bc49-d86d35a5fbe1

📥 Commits

Reviewing files that changed from the base of the PR and between ee6cca7 and 0335f08.

📒 Files selected for processing (5)
  • portals/devportal/src/main/webapp/source/src/app/components/Apis/Details/index.jsx
  • portals/devportal/src/main/webapp/source/src/app/components/Applications/Details/SubscriptionSection.jsx
  • portals/devportal/src/main/webapp/source/src/app/components/Applications/Details/SubscriptionTableData.jsx
  • portals/devportal/src/main/webapp/source/src/app/components/Applications/Details/Subscriptions.jsx
  • portals/devportal/src/main/webapp/source/src/app/data/Subscription.jsx
💤 Files with no reviewable changes (1)
  • portals/devportal/src/main/webapp/source/src/app/components/Apis/Details/index.jsx

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 10, 2026
RakhithaRR
RakhithaRR previously approved these changes Jul 10, 2026
…ejected cache entries, preserve retry state on load failure, drop redundant per-row subscription fetch
@PasanT9
PasanT9 dismissed stale reviews from RakhithaRR and coderabbitai[bot] via 095fe8b July 13, 2026 04:18
@PasanT9
PasanT9 force-pushed the fix-17318-apim-main branch from f4894e5 to 095fe8b Compare July 13, 2026 04:18
@sonarqubecloud

Copy link
Copy Markdown

@PasanT9
PasanT9 merged commit 61590f1 into wso2:main Jul 13, 2026
3 checks passed
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.

2 participants