Skip to content

[CSM Portal] cases: product filter + cloud-project case creation - #1044

Merged
rksk merged 2 commits into
wso2-open-operations:v2from
rksk:csm-case-product-filter-fe
Jul 5, 2026
Merged

rksk merged 2 commits into
wso2-open-operations:v2from
rksk:csm-case-product-filter-fe

Conversation

@rksk

@rksk rksk commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Purpose

CS engineers had no way to filter the case list by product. Separately, the case-creation form always required selecting a deployment before a product, even for cloud projects that have a single primary-production deployment, an unnecessary step the customer portal already avoids.

Goals

  1. Add a Product filter to the cases list.
  2. For cloud-support projects, skip deployment selection in the case-creation form and go straight to product (match the customer portal).

Approach

Product filter:

  • New Product multi-select in the cases filter bar; options are the distinct product family names from /products/search (deduped, type-to-search).
  • Selected names are sent as filters.productNames on /cases/search, which matches all versions of each product.
  • Serialised to the products URL param via the shared filter URL codec (unit tests added).

Cloud-project case creation:

  • For cloud_support / cloud_evaluation_support subscriptions, hide the deployment picker and file against the project's single primary-production deployment; product loads immediately.
  • Non-cloud projects keep the normal deployment then product cascade.
  • The cloud deployment is derived (not synced via an effect), so product loading, validation, and the submit payload key off the effective deployment id.

User stories

  • As a CS engineer, I can filter cases by product.
  • As a CS engineer creating a case for a cloud project, I go straight to product selection without picking a deployment.

Release note

Added a product filter to the cases list, and streamlined case creation for cloud projects to skip deployment selection.

Documentation

N/A. Internal CS-engineer portal; no customer-facing documentation impact.

Training

N/A.

Certification

N/A. No impact on certification exams.

Marketing

N/A.

Automation tests

  • Unit tests

    Filter URL codec round-trip tests added; full suite (135 tests) passes. tsc and eslint clean.

  • Integration tests

    Full-stack verification on the local ServiceNow-backed stack; the product filter is exercised only against the ServiceNow data source.

Security checks

  • Followed secure coding standards? yes
  • Ran FindSecurityBugs plugin and verified report? N/A. TypeScript/React, not a Java project; eslint + tsc run clean.
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets? yes

Samples

N/A.

Related PRs

Product filter depends on the entity-service filter (#1043) and a corresponding ServiceNow-proxy (Ballerina entity-service) change tracked separately. Base is v2; until #1043 merges this PR's diff transiently includes that commit.

Migrations (if applicable)

N/A.

Test environment

Node + pnpm; tsc, eslint, vitest (135 pass), and pnpm build on macOS.

@rksk rksk added App/CSM Portal Area/Frontend Type/New Feature Represents a request or task for a new feature labels Jul 5, 2026
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a "product family" filter to CSM case search: a new productNames field flows through backend types, /cases/search request, URL state, and a new ProductNameMultiSelect UI component backed by useProductNameOptions. Separately, CsmCaseCreatePage derives deployment ID automatically for cloud-support subscription projects using a new isCloudSupportSubscription utility.

Changes

Product family filter

Layer / File(s) Summary
Backend contract and product name data fetching
apps/csm-portal/webapp/src/api/backend/types.ts, apps/csm-portal/webapp/src/features/csm-cases/api/useGetCsmCases.ts, apps/csm-portal/webapp/src/features/csm-cases/api/useProductNameOptions.ts
Adds optional productNames to BeCaseSearchFilters, forwards it in the /cases/search payload, and adds useProductNameOptions to paginate /products/search and return sorted distinct names.
URL filter state
apps/csm-portal/webapp/src/features/csm-cases/utils/casesFiltersUrl.ts, apps/csm-portal/webapp/src/features/csm-cases/utils/casesFiltersUrl.test.ts
Adds productNames default, reads/writes it via the products query param, counts it as active, and updates tests accordingly.
ProductNameMultiSelect component
apps/csm-portal/webapp/src/features/csm-cases/components/ProductNameMultiSelect.tsx
New Autocomplete-based multi-select merging fetched and selected names, with chip/checkbox rendering and loading/error states.
Filter bar and view wiring
apps/csm-portal/webapp/src/features/csm-cases/components/CasesFilterBar.tsx, apps/csm-portal/webapp/src/features/csm-cases/components/CsmIssuesView.tsx
Wires the new selector into the filter grid, extends CasesFilters, and adds "products" to URL-owned filter keys.

Cloud-support subscription deployment handling

Layer / File(s) Summary
Subscription type utility
apps/csm-portal/webapp/src/features/csm-projects/utils/subscriptionType.ts
New CLOUD_SUPPORT_SUBSCRIPTION_TYPES list and isCloudSupportSubscription predicate.
CsmCaseCreatePage deployment derivation
apps/csm-portal/webapp/src/features/csm-cases/pages/CsmCaseCreatePage.tsx
Derives effectiveDeploymentId from the project's primary-production deployment for cloud projects, hides the deployment picker, and updates submit validation, payload, and deployed-product dropdown state/messaging.

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

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ProductNameMultiSelect
  participant useProductNameOptions
  participant BackendAPI
  participant CasesFilterBar

  ProductNameMultiSelect->>useProductNameOptions: request product family names
  useProductNameOptions->>BackendAPI: paginated /products/search calls
  BackendAPI-->>useProductNameOptions: product rows
  useProductNameOptions-->>ProductNameMultiSelect: sorted distinct names
  User->>ProductNameMultiSelect: select/deselect names
  ProductNameMultiSelect->>CasesFilterBar: onChange(next productNames)
  CasesFilterBar->>BackendAPI: /cases/search with productNames filter
Loading

Possibly related PRs

Suggested labels: Type/Improvement

Suggested reviewers: cloby99

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the two main changes: product filtering and cloud-project case creation.
Description check ✅ Passed All required template sections are present and sufficiently filled; only the optional Learning section is omitted.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

rksk added 2 commits July 5, 2026 20:17
Adds a Product multi-select to the cases filter bar. Options are the distinct
product family names from /products/search (deduped); the selected names are
sent as filters.productNames on /cases/search, which matches every version of
each product. URL param "products"; round-trips via the shared filter URL codec.
Mirrors the customer portal: for cloud-support projects (cloud_support /
cloud_evaluation_support) the case-creation form hides the deployment picker and
files against the project's single primary-production deployment, so the user
goes straight to product selection. Non-cloud projects keep the normal
deployment -> product cascade. The cloud deployment is derived (not synced via
an effect) so downstream product/validation/payload key off it.
@rksk
rksk force-pushed the csm-case-product-filter-fe branch from 42cebbc to 14c5994 Compare July 5, 2026 15:03
@rksk

rksk commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

@rksk Resuming automatic reviews for this PR.

✅ Action performed

Reviews resumed.

@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.

Caution

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

⚠️ Outside diff range comments (1)
apps/csm-portal/webapp/src/features/csm-cases/api/useGetCsmCases.ts (1)

136-150: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

productNames missing from the React Query key — filter changes won't refetch.

filters.productNames is used in the payload (Lines 239-242) but is not included in queryKey (Lines 136-150). Since react-query only refetches on a key change, toggling the new Product filter will silently no-op — the case list keeps showing stale results.

🐛 Proposed fix
     queryKey: [
       ApiQueryKeys.CSM_CASES,
       search,
       [...filters.severities].sort(),
       [...filters.states].sort(),
       [...filters.caseTypes].sort(),
       [...filters.workStates].sort(),
       [...filters.assignees].sort(),
       [...filters.projects].sort(),
       [...filters.engagementTypes].sort(),
+      [...filters.productNames].sort(),
       currentUserEmail ?? "",
       currentUserId ?? "",
       page,
       pageSize,
     ],

Also applies to: 239-242

🤖 Prompt for 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.

In `@apps/csm-portal/webapp/src/features/csm-cases/api/useGetCsmCases.ts` around
lines 136 - 150, The React Query key in useGetCsmCases is missing
filters.productNames, so changing the Product filter will not trigger a refetch
and the list can stay stale. Update the queryKey array in useGetCsmCases to
include a stable, sorted representation of filters.productNames alongside the
other filter sets, matching how the payload already uses it. Keep the key
structure consistent with the existing filter symbols in useGetCsmCases so query
invalidation works when Product selections change.
🧹 Nitpick comments (1)
apps/csm-portal/webapp/src/features/csm-cases/api/useProductNameOptions.ts (1)

41-52: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Consider a hard iteration cap on the pagination loop.

The loop terminates only via page.length < PAGE_LIMIT; if the backend ever returns full pages indefinitely, this hook would fetch unboundedly. Given the catalogue is documented as bounded, this is low risk, but a safety cap (e.g., max N pages) would prevent a runaway loop from an unexpected backend response.

🤖 Prompt for 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.

In `@apps/csm-portal/webapp/src/features/csm-cases/api/useProductNameOptions.ts`
around lines 41 - 52, The pagination loop in useProductNameOptions can run
without a hard stop if the backend keeps returning full pages, so add a safety
cap to bound the number of requests. Update the offset loop around the
api.post("/products/search") call to stop after a maximum page count, while
still preserving the existing page.length < PAGE_LIMIT early exit. Use the
existing PAGE_LIMIT and the useProductNameOptions hook as the main symbols when
applying the fix.
🤖 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.

Outside diff comments:
In `@apps/csm-portal/webapp/src/features/csm-cases/api/useGetCsmCases.ts`:
- Around line 136-150: The React Query key in useGetCsmCases is missing
filters.productNames, so changing the Product filter will not trigger a refetch
and the list can stay stale. Update the queryKey array in useGetCsmCases to
include a stable, sorted representation of filters.productNames alongside the
other filter sets, matching how the payload already uses it. Keep the key
structure consistent with the existing filter symbols in useGetCsmCases so query
invalidation works when Product selections change.

---

Nitpick comments:
In `@apps/csm-portal/webapp/src/features/csm-cases/api/useProductNameOptions.ts`:
- Around line 41-52: The pagination loop in useProductNameOptions can run
without a hard stop if the backend keeps returning full pages, so add a safety
cap to bound the number of requests. Update the offset loop around the
api.post("/products/search") call to stop after a maximum page count, while
still preserving the existing page.length < PAGE_LIMIT early exit. Use the
existing PAGE_LIMIT and the useProductNameOptions hook as the main symbols when
applying the fix.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1f17fa72-ba1a-4374-a7f2-f85560560d44

📥 Commits

Reviewing files that changed from the base of the PR and between dd93324 and 14c5994.

📒 Files selected for processing (10)
  • apps/csm-portal/webapp/src/api/backend/types.ts
  • apps/csm-portal/webapp/src/features/csm-cases/api/useGetCsmCases.ts
  • apps/csm-portal/webapp/src/features/csm-cases/api/useProductNameOptions.ts
  • apps/csm-portal/webapp/src/features/csm-cases/components/CasesFilterBar.tsx
  • apps/csm-portal/webapp/src/features/csm-cases/components/CsmIssuesView.tsx
  • apps/csm-portal/webapp/src/features/csm-cases/components/ProductNameMultiSelect.tsx
  • apps/csm-portal/webapp/src/features/csm-cases/pages/CsmCaseCreatePage.tsx
  • apps/csm-portal/webapp/src/features/csm-cases/utils/casesFiltersUrl.test.ts
  • apps/csm-portal/webapp/src/features/csm-cases/utils/casesFiltersUrl.ts
  • apps/csm-portal/webapp/src/features/csm-projects/utils/subscriptionType.ts

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants