Skip to content

[Customer Portal][FE][Web] Refactor case fetching with server-side filtering and pagination using new project hooks - #578

Merged
Rashmika998 merged 3 commits into
wso2-open-operations:mainfrom
dileepapeiris:feat-bug-fix-v10
Apr 23, 2026
Merged

Rashmika998 merged 3 commits into
wso2-open-operations:mainfrom
dileepapeiris:feat-bug-fix-v10

Conversation

@dileepapeiris

@dileepapeiris dileepapeiris commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

This pull request refactors how project cases are fetched and filtered in both the Operations and Support pages of the customer portal. It introduces the use of useGetProjectFilters and useGetProjectCasesPage hooks to improve filtering logic, especially for excluding closed cases, and simplifies the code by removing manual filtering and pagination logic.

API and Filtering Improvements:

  • Replaces the old useGetProjectCases hook with the new useGetProjectCasesPage hook in both OperationsPage.tsx and SupportPage.tsx, enabling more efficient server-side filtering and pagination. [1] [2]
  • Adds the useGetProjectFilters hook to fetch filter metadata (such as case states) and uses resolveCasesTableDefaultStatusIds to dynamically determine non-closed status IDs for filtering cases. [1] [2]

Code Simplification and Cleanup:

  • Removes manual client-side filtering of closed cases and unnecessary pagination logic, relying instead on server-side filtering via the new hooks. [1] [2] [3]
  • Updates loading state logic to account for the new hooks and filter metadata loading. [1] [2]

UI and Styling Adjustments:

  • Adjusts the layout of the Operations page case list containers to improve flex behavior and ensure proper sizing. [1] [2]

Performance Improvements:

  • Sets the staleTime for project filters to 5 minutes, reducing unnecessary refetching and improving performance.

Dependency Updates:

  • Updates imports throughout the affected files to use the new hooks and utility functions. [1] [2] [3]

These changes collectively improve code maintainability, performance, and the accuracy of case filtering in the customer portal.

Increase cache for project filter metadata (staleTime -> 5 minutes) and switch Support/Operations pages to use useGetProjectFilters + useGetProjectCasesPage. Resolve non-closed status IDs from filter metadata and pass them as statusIds to the cases queries, gating queries until filter metadata is available. Update loading flags and simplify client-side filtering (remove manual closed-status filtering and pagination workarounds). Also adjust OutstandingCasesList container layout to use flex sizing so it can grow/scroll correctly.
@dileepapeiris dileepapeiris self-assigned this Apr 23, 2026
@coderabbitai

coderabbitai Bot commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@dileepapeiris has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 46 minutes and 13 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 46 minutes and 13 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cd94aada-42be-4c03-b200-b81f59ae113c

📥 Commits

Reviewing files that changed from the base of the PR and between 93eacfd and 30f6cf5.

📒 Files selected for processing (2)
  • apps/customer-portal/webapp/src/features/operations/pages/OperationsPage.tsx
  • apps/customer-portal/webapp/src/features/support/pages/SupportPage.tsx
📝 Walkthrough

Walkthrough

Updates React Query cache staleness for project filters to 5 minutes and refactors OperationsPage and SupportPage to fetch filter metadata and derive default non-closed status filters, shifting case fetching from client-side filtering and pagination to server-side pagination via useGetProjectCasesPage with fixed page parameters.

Changes

Cohort / File(s) Summary
React Query Cache Configuration
apps/customer-portal/webapp/src/api/useGetProjectFilters.ts
Updates staleTime from immediate staleness to 5 minutes, extending the freshness window for cached filter results before triggering refetches.
Server-Side Case Filtering Migration
apps/customer-portal/webapp/src/features/operations/pages/OperationsPage.tsx, apps/customer-portal/webapp/src/features/support/pages/SupportPage.tsx
Migrates from client-side filtering and infinite pagination to server-side filtering via useGetProjectCasesPage. Derives default non-closed statusIds from filter metadata and removes client-side status exclusion logic. Updates data source shapes and loading states to include filter-metadata dependency. Adds flexbox layout adjustments to change-request card in OperationsPage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

Type/Improvement, Type/Task, App/Customer Portal, Area/Frontend, Platform/Web

Suggested reviewers

  • Rashmika998
  • v15a1

Poem

🐰✨ From client to server, the filters now flow,
Cache freshens for five, no longer stale-oh!
Cases page smartly, with status derived,
Flexbox and queries in harmony thrive! 🚀

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description lacks several required template sections including Purpose, Goals, Approach, User stories, Release note, Documentation, Training, Certification, Marketing, Security checks, and other sections that should be completed. Complete the pull request description by filling in all required template sections. At minimum, add Purpose (with linked issues), Goals, Approach, Release note, and Documentation sections. For non-applicable sections, provide explicit N/A explanations.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
Title check ✅ Passed The title accurately describes the main change: refactoring case fetching to use server-side filtering and pagination with new project hooks, which aligns with the core objectives of switching to useGetProjectFilters and useGetProjectCasesPage.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@dileepapeiris dileepapeiris added Type/Improvement Marks enhancements or improvements to existing features Type/Task General task that does not fit into other categories App/Customer Portal Area/Frontend Platform/Web labels Apr 23, 2026
@dileepapeiris dileepapeiris changed the title Use project filters and paged cases API [Customer Portal][FE][Web] Refactor case fetching with server-side filtering and pagination using new project hooks Apr 23, 2026

@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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/customer-portal/webapp/src/features/support/pages/SupportPage.tsx (1)

82-117: ⚠️ Potential issue | 🟠 Major

S0 client-side filtering can now shrink the outstanding list below SUPPORT_OVERVIEW_CASES_LIMIT.

The server is asked for exactly SUPPORT_OVERVIEW_CASES_LIMIT (5) cases via useGetProjectCasesPage(..., 0, SUPPORT_OVERVIEW_CASES_LIMIT, ...), and then — when includeS0InSupportMetrics === false — S0 cases are stripped on the client (lines 113–117). With the removed fetch-more effect, there is no longer anything to backfill the page.

Consequence: for projects that hide S0 from support metrics, the Outstanding Cases card will often display 0–4 items even when plenty of non-S0 outstanding cases exist beyond the first 5, and the user has no way to load more from this card. This is a UX regression versus the previous infinite-pagination + "keep fetching until we have enough non-S0 cases" flow.

Preferred fix: exclude S0 server-side by extending the filters in the request (e.g., a severityIds / excludeSeverityIds filter derived from filterMetadata) so the backend returns 5 already-filtered cases. If that isn't available yet, over-fetching (e.g., limit: SUPPORT_OVERVIEW_CASES_LIMIT * 2 and then .slice(0, SUPPORT_OVERVIEW_CASES_LIMIT) after S0 removal) is a pragmatic interim workaround but still not a full fix.

Also note: the empty-statusIds concern and the filter-metadata-error-masking concern raised on OperationsPage.tsx apply verbatim to this file (lines 77–98).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/customer-portal/webapp/src/features/support/pages/SupportPage.tsx`
around lines 82 - 117, The outstanding-cases list is being truncated by
client-side S0 filtering after requesting exactly SUPPORT_OVERVIEW_CASES_LIMIT
via useGetProjectCasesPage; update the request to exclude S0 server-side
(preferred) by adding an appropriate severity/excludeSeverity filter derived
from filterMetadata to the filters object passed to useGetProjectCasesPage so
the backend returns already-filtered results, referencing
useGetProjectCasesPage, filters, filterMetadata, nonClosedStatusIds, and
includeS0InSupportMetrics; if backend filtering isn't available yet,
pragmatically over-fetch (e.g., request SUPPORT_OVERVIEW_CASES_LIMIT * 2) and
then apply the current client-side filter (isS0Case) and slice the result to
SUPPORT_OVERVIEW_CASES_LIMIT, and also ensure you handle empty statusIds and
surface filter-metadata errors instead of masking them as noted similarly in
OperationsPage.tsx.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@apps/customer-portal/webapp/src/features/operations/pages/OperationsPage.tsx`:
- Around line 98-130: The filters fetch error is currently hidden because
OperationsPage only reads useGetProjectFilters' data but not its error state;
update the hook call to also destructure isError (e.g., const { data:
filterMetadata, isLoading: isFilterMetadataLoading, isError:
isFilterMetadataError } = useGetProjectFilters(projectId || ""); then include
that error when deciding SR loading/error: compute isSrLoading = isSrDataLoading
|| isFilterMetadataLoading and compute combinedIsSrError = isSrError ||
isFilterMetadataError (or pass isError={isSrError || isFilterMetadataError}
directly to the SupportOverviewCard); ensure the cases query gating (enabled)
still uses filterMetadata !== undefined but surface filter errors to the card by
wiring the new combined error into the card's isError prop.

---

Outside diff comments:
In `@apps/customer-portal/webapp/src/features/support/pages/SupportPage.tsx`:
- Around line 82-117: The outstanding-cases list is being truncated by
client-side S0 filtering after requesting exactly SUPPORT_OVERVIEW_CASES_LIMIT
via useGetProjectCasesPage; update the request to exclude S0 server-side
(preferred) by adding an appropriate severity/excludeSeverity filter derived
from filterMetadata to the filters object passed to useGetProjectCasesPage so
the backend returns already-filtered results, referencing
useGetProjectCasesPage, filters, filterMetadata, nonClosedStatusIds, and
includeS0InSupportMetrics; if backend filtering isn't available yet,
pragmatically over-fetch (e.g., request SUPPORT_OVERVIEW_CASES_LIMIT * 2) and
then apply the current client-side filter (isS0Case) and slice the result to
SUPPORT_OVERVIEW_CASES_LIMIT, and also ensure you handle empty statusIds and
surface filter-metadata errors instead of masking them as noted similarly in
OperationsPage.tsx.
🪄 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: ac447bc1-34a6-41bc-98f8-35c8e9349355

📥 Commits

Reviewing files that changed from the base of the PR and between a02c686 and 93eacfd.

📒 Files selected for processing (3)
  • apps/customer-portal/webapp/src/api/useGetProjectFilters.ts
  • apps/customer-portal/webapp/src/features/operations/pages/OperationsPage.tsx
  • apps/customer-portal/webapp/src/features/support/pages/SupportPage.tsx

Comment thread apps/customer-portal/webapp/src/features/operations/pages/OperationsPage.tsx Outdated
Aggregate error states so the UI reflects failures from either service requests or filter metadata. This adds isFilterMetadataError from useGetProjectFilters, computes combinedIsSrError = isSrError || isFilterMetadataError, and passes combinedIsSrError to the OutstandingCasesList isError prop to surface errors from either source.
Destructure isError from useGetProjectFilters and introduce combinedIsCasesError (isCasesError || isFilterMetadataError). Use this combined flag for the list component's isError prop so the UI reports an error when either cases or filter metadata fetching fails.
@Rashmika998
Rashmika998 merged commit 9781c4c into wso2-open-operations:main Apr 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

App/Customer Portal Area/Frontend Platform/Web Type/Improvement Marks enhancements or improvements to existing features Type/Task General task that does not fit into other categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants