Skip to content

[CSM Portal] case-create project search, deployed-product labels, dashboard count cells - #871

Merged
Rashmika998 merged 6 commits into
wso2-open-operations:v2from
rksk:csm-case-create-async-project-search
Jun 16, 2026
Merged

[CSM Portal] case-create project search, deployed-product labels, dashboard count cells#871
Rashmika998 merged 6 commits into
wso2-open-operations:v2from
rksk:csm-case-create-async-project-search

Conversation

@rksk

@rksk rksk commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

What

Frontend-only changes to the CSM portal.

Case create page

  • Project field is now a type-ahead search. Previously the page paged through the entire project catalogue (hundreds of records) on mount before the form was usable. It now uses a new AsyncProjectSelect that queries the backend as the user types (debounced, first page of matches only), mirroring the existing async project filter on the case list.
  • Deployed-product labels fixed. The deployed-product records returned by the backend already embed resolved product and version objects, but the option builder was reading flat fields that don't exist in that shape, so every option collapsed to a generic Product label. It now reads the embedded objects and renders "{product name} {version}" directly. This also removes the obsolete secondary lookups (paging /products/search and a per-product versions search), so the dropdown populates from the single deployed-products call.

Case list page

  • The filter panel now starts expanded by default instead of collapsed.

Dashboard

  • In the Cases by severity and state matrix, 0 cells now use the same size, weight, and link treatment as non-zero counts, so the grid reads consistently instead of muting the zeros.

Notes

  • The FE BeDeployedProduct type was corrected to match the nested shape the backend actually returns.
  • Verified with pnpm lint and pnpm build.

Summary by CodeRabbit

  • New Features

    • Added an async Project selector with debounced, backend-backed search and stable selection during results updates.
    • Improved deployed product selection using embedded product/version data for smoother loading.
  • UI/UX Improvements

    • Case filters panel now opens by default on the CSM Cases page.
    • Case count values are always shown as clickable links.
    • Case metadata band now highlights “Project type” and updates the shown fact set.
  • Data & Display Updates

    • Customer tier values and related labels/colors now support only basic and enterprise.
    • Case detail customer context is updated to use embedded project account information with safe fallbacks.

…hboard count cells

- Case create: replace the eager full-catalogue project Select with a
  type-ahead AsyncProjectSelect that searches the backend as the user types,
  so the page no longer loads hundreds of projects up front.
- Deployed-product picker: read the embedded product/version objects the
  backend now returns and build "{product} {version}" labels directly,
  dropping the obsolete per-product name/version resolution calls.
- Case list: filter panel now starts expanded.
- Dashboard case-counts matrix: render 0 cells with the same styling and
  link treatment as non-zero counts for a consistent grid.
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@rksk, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 57 minutes and 24 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: beb99d30-7e04-4793-9ae9-c2c53b7583d6

📥 Commits

Reviewing files that changed from the base of the PR and between b5d5e48 and 5dea5ae.

📒 Files selected for processing (9)
  • apps/csm-portal/webapp/src/api/backend/types.ts
  • apps/csm-portal/webapp/src/components/SemanticChip.tsx
  • apps/csm-portal/webapp/src/features/csm-cases/api/useGetCsmCaseDetail.ts
  • apps/csm-portal/webapp/src/features/csm-cases/api/usePostCsmCase.ts
  • apps/csm-portal/webapp/src/features/csm-cases/components/CaseDetailWidgets.tsx
  • apps/csm-portal/webapp/src/features/csm-cases/components/CaseMetaBand.tsx
  • apps/csm-portal/webapp/src/features/csm-cases/pages/CsmCaseDetailPage.tsx
  • apps/csm-portal/webapp/src/features/csm-cases/types/csmCases.ts
  • apps/csm-portal/webapp/src/features/csm-cases/utils/caseTier.ts
📝 Walkthrough

Walkthrough

Updates BeDeployedProduct and BeProjectDetail to embedded object shapes with renamed timestamps, simplifies useDeployedProductOptions to use embedded fields, refactors case-detail account hydration to fetch projects instead of accounts, updates customer tier model from plan-based to account-based (basic/enterprise), adds AsyncProjectSelect component with debounced backend search, integrates it into CsmCaseCreatePage, defaults the cases filter panel to open, extracts project type in the case metadata band, and makes CountCell always render as a link.

Changes

CSM Portal: deployed-product enrichment, async project picker, and case detail refactoring

Layer / File(s) Summary
BeDeployedProduct and BeProjectDetail embedded shapes
apps/csm-portal/webapp/src/api/backend/types.ts
Adds BeProjectAccountRef and BeProjectDetail for project responses with embedded account; introduces BeDeployedProductVersion and replaces BeDeployedProduct's flat id-based fields with embedded deployment/product/version objects, metric fields, and renamed timestamps.
useDeployedProductOptions simplified to embedded fields
apps/csm-portal/webapp/src/features/csm-cases/api/useDeployedProductOptions.ts
Removes pagination constants and extra /products/search + /products/{id}/versions/search API calls; derives product name and version directly from embedded d.product and d.version objects.
Case detail account hydration refactored to project fetch
apps/csm-portal/webapp/src/features/csm-cases/api/useGetCsmCaseDetail.ts
Fetches BeProjectDetail and reads embedded account instead of separate /accounts/{accountId} call; updates account parameter type to BeProjectAccountRef; defaults tier to "basic" and hardcodes accountManager to "—".
Customer tier model updated to account-based values
apps/csm-portal/webapp/src/features/csm-cases/types/csmCases.ts, apps/csm-portal/webapp/src/features/csm-cases/utils/caseTier.ts
Changes CustomerTier type to "basic" | "enterprise"; updates TIER_LABEL and TIER_COLOR mappings with basic"default" and enterprise"info".
Mock tier data updated to new account-based values
apps/csm-portal/webapp/src/features/csm-cases/api/mocks/casesMocks.ts
Updates tier values in CUSTOMER_CONTEXTS and FALLBACK_CUSTOMER to match new basic/enterprise account-tier model.
AsyncProjectSelect component
apps/csm-portal/webapp/src/features/csm-cases/components/AsyncProjectSelect.tsx
New Autocomplete-backed component with ProjectOption/AsyncProjectSelectProps interfaces; debounces input, calls useProjectSearch, tracks picked option for label stability, de-duplicates options by id, and wires loading/error states.
CsmCaseCreatePage wired to AsyncProjectSelect
apps/csm-portal/webapp/src/features/csm-cases/pages/CsmCaseCreatePage.tsx
Imports AsyncProjectSelect, removes project-options error/refetch from hasOptionsError and retryOptions, and replaces static <Select> Project control with async component.
Filter panel default open, project type extraction, and count cell rendering
apps/csm-portal/webapp/src/features/csm-cases/pages/CsmCasesPage.tsx, apps/csm-portal/webapp/src/features/csm-cases/components/CaseMetaBand.tsx, apps/csm-portal/webapp/src/features/csm-dashboard/components/CaseCountsMatrix.tsx
isFiltersOpen defaults to true; CaseMetaBand extracts project type from projectName's second segment and adds Project type cell while removing Version cell; CountCell always renders count as Link instead of conditionally rendering muted Typography.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • wso2-open-operations/cs-tools#839: Directly modifies useDeployedProductOptions.ts with catalog pagination logic that this PR replaces entirely by using embedded fields.
  • wso2-open-operations/cs-tools#867: Both PRs modify useGetCsmCaseDetail.ts account hydration and customer context mapping, changing how backend payloads are mapped.
  • wso2-open-operations/cs-tools#869: The new AsyncProjectSelect component and its integration into CsmCaseCreatePage align with and depend on the useProjectSearch type-ahead hook pattern.

Suggested labels

Type/Improvement, Type/UX, Area/Frontend, Platform/Web, App/CSM Portal

Suggested reviewers

  • cloby99

Poem

🐇 Projects now embed their account ties so deep,
No more separate calls—the data we keep!
A picker that searches as you sweetly type,
Filters open wide, project types in sight,
And all counts are links, a consistent delight! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% 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 identifies the three main areas of change: case-create project search, deployed-product labels, and dashboard count cells.
Description check ✅ Passed The description includes Purpose (what), Goals (improvements), Approach (how, with clear examples), and implementation details; Release note is included. Several template sections (User stories, Automation tests, Security checks, etc.) are not filled, but core required information is present and substantive.
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.

✏️ 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.

@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

🤖 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
`@apps/csm-portal/webapp/src/features/csm-cases/components/AsyncProjectSelect.tsx`:
- Around line 57-58: Search failures from the useProjectSearch hook are
currently being treated as empty results, displaying "No projects found" instead
of surfacing the actual error to the user. In AsyncProjectSelect.tsx at line
57-58, destructure an error state from the useProjectSearch hook call alongside
data and isFetching. Then in the rendering logic at lines 102-115, check for the
error state and conditionally display an error message instead of the
empty-results message when a search failure occurs. This ensures users see an
explicit failure state with a clear recovery path rather than a misleading empty
results state.
🪄 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: fd24ecf9-db48-478e-8411-d3c89d5d66bd

📥 Commits

Reviewing files that changed from the base of the PR and between 3ff2732 and ac4cee4.

📒 Files selected for processing (6)
  • apps/csm-portal/webapp/src/api/backend/types.ts
  • apps/csm-portal/webapp/src/features/csm-cases/api/useDeployedProductOptions.ts
  • apps/csm-portal/webapp/src/features/csm-cases/components/AsyncProjectSelect.tsx
  • apps/csm-portal/webapp/src/features/csm-cases/pages/CsmCaseCreatePage.tsx
  • apps/csm-portal/webapp/src/features/csm-cases/pages/CsmCasesPage.tsx
  • apps/csm-portal/webapp/src/features/csm-dashboard/components/CaseCountsMatrix.tsx

Comment thread apps/csm-portal/webapp/src/features/csm-cases/components/AsyncProjectSelect.tsx Outdated
rksk added 2 commits June 16, 2026 07:29
A failed project search collapsed into the "No projects found" empty state,
which is misleading and (since project is required) blocks case creation with
no signal it was a failure. Surface isError as an explicit "Could not load
projects" / field error with a retry hint; typing re-runs the query.
…ix account hydration

- Fix account hydration: GET /projects/{id} embeds the account (id, name,
  tier, region) under `account`, but the detail builder read a non-existent
  top-level `accountId`, so the customer and tier never resolved. Read the
  embedded account directly and drop the redundant /accounts/{id} call.
- Tier now reflects the real account tier (basic/enterprise) instead of a
  hardcoded value; align CustomerTier and its label/colour maps accordingly
  (tier stays off the brand accent).
- Overview box: replace the Version cell (version already shows in the product
  label) with a Project type cell, derived for now from the second
  " - "-delimited segment of the project name.
- Reorder overview cells: Account, Project, Project type, Deployment, Product.
@rksk

rksk commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

rksk added 3 commits June 16, 2026 09:41
POST /cases returns { message, case: { id, ... } }, but the mutation typed the
response as a bare case and read `created.id`, so it was undefined and the
redirect went to /cases/undefined. Unwrap the envelope and return the inner
case. The envelope has no projectId, so the project-scoped search invalidation
now uses the submitted payload's projectId.
…ree-form tier

The CaseView embeds the account as { id, name, type }, where `type` is the
account/support tier ("Enterprise" for ServiceNow-sourced cases — a free-form
string, not the PG basic|enterprise enum). Two fixes:

- Read account (name + tier) straight off the CaseView instead of fetching the
  project detail; drops a network hop and resolves the customer + tier from the
  one /cases/{id} response.
- Tolerate free-form tier values: CustomerTier is now a string, and the closed
  TIER_LABEL/TIER_COLOR maps become tierLabel()/tierColor() helpers that
  title-case any value and fall back to a neutral colour. This fixes the page
  crash where an unmapped tier left SemanticChip reading `.main` off undefined.
- Harden SemanticChip itself to degrade an unknown role to the outlined default
  chip rather than throwing.
Tier still shows in the Overview band and the Customer widget; the chip above
the subject was redundant.
@rksk rksk added Type/Improvement Marks enhancements or improvements to existing features Area/Frontend App/CSM Portal labels Jun 16, 2026
@Rashmika998
Rashmika998 merged commit b68e200 into wso2-open-operations:v2 Jun 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

App/CSM Portal Area/Frontend Type/Improvement Marks enhancements or improvements to existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants