Skip to content

[CSM Portal Microapp] Fix Service Requests/Security Reports not loading, align state/severity with webapp - #1104

Merged
cloby99 merged 1 commit into
wso2-open-operations:dev-app-csm-portalfrom
2003dinijay:support
Jul 9, 2026
Merged

cloby99 merged 1 commit into
wso2-open-operations:dev-app-csm-portalfrom
2003dinijay:support

Conversation

@2003dinijay

@2003dinijay 2003dinijay commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes Service Requests/Security Reports cards getting stuck (severity is only populated for the case type; the previous normalizer crashed on null, and since that's a plain JS error rather than an HTTP 4xx, React Query burned several retries before ever showing the error state).
  • Also normalizes two other loose backend formats found while investigating: legacy ServiceNow priority codes (P2) for severity, and labeled state strings (Work In Progress) instead of the snake_case enum — both handled the same way apps/csm-portal/webapp's api/backend/mappers.ts already does.
  • State/severity labels and colors in config.tsx now match the webapp's STATE_LABEL/STATE_COLOR/SEVERITY_LABEL exactly.

Test plan

  • npm run lint / tsc --noEmit clean (verified with this commit isolated from other in-progress work)
  • Verified in a headless browser against a mocked backend: Service Requests/Security Reports load immediately with no retries and no console errors; severity chip is correctly omitted for types that don't have one

Summary by CodeRabbit

  • New Features
    • Case status and severity labels now display in a more consistent, user-friendly format.
  • Bug Fixes
    • Severity is shown only when available, preventing empty or incorrect severity indicators.
    • Case status and severity values are now handled more reliably, improving display consistency across case views.

…verity with webapp

Service Requests and Security Reports cards were stuck in an infinite
retry loop instead of loading: severity/issueType are only populated
for the "case" type (the backend's own create-payload docs say
"Required for case type"), so other types come back with severity
null. normalizeSeverity() called .toLowerCase() on that null
unconditionally and threw — a plain JS error, not an HTTP 4xx, so
React Query didn't treat it as non-retryable and burned several
seconds retrying before ever reaching the error state.

Also found while comparing against the real data: severity sometimes
arrives as a legacy ServiceNow priority code ("P2") rather than the
documented word ("high"), and state sometimes arrives as a labeled
string ("Work In Progress") rather than the snake_case enum. Both are
now normalized the same way apps/csm-portal/webapp's
api/backend/mappers.ts already does.

Severity is now nullable end-to-end (CaseSearchViewDto/CaseViewDto ->
CaseSummary/CaseDetail), and the severity chip is simply omitted on
cards/detail page for types that don't have one.

State/severity labels and colors in config.tsx now match the webapp's
STATE_LABEL/STATE_COLOR and SEVERITY_LABEL exactly (e.g. "S2 (High)"
code-first format, "Waiting on WSO2", etc.) instead of ad hoc wording.
Copilot AI review requested due to automatic review settings July 9, 2026 04:08

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR relaxes strict enum typing for case severity/issueType/state in DTOs to permissive string/nullable types, introduces normalizeSeverity and normalizeState helpers in the case model to canonicalize backend values, updates chip label/color configs, and makes severity chip rendering conditional in CaseCard and CaseDetailPage.

Changes

Case severity/state normalization and UI updates

Layer / File(s) Summary
DTO type relaxation
apps/csm-portal/microapp/src/types/case.dto.ts
severity, issueType, and state fields in CaseSearchViewDto and CaseViewDto change from strict enums to string | null, CaseIssueType | null, and string, with added explanatory comments.
Normalization helpers and mapping
apps/csm-portal/microapp/src/types/case.model.ts
normalizeSeverity and normalizeState are added to canonicalize backend strings; CaseSummary.severity/CaseDetail.severity become nullable; toCaseSummary/toCaseDetail use the normalizers instead of direct DTO assignment.
Chip label/color config updates
apps/csm-portal/microapp/src/components/support/config.tsx
STATE_LABELS, STATE_CHIP_COLOR_CONFIG, and SEVERITY_LABELS are updated with revised wording, colors, and “Sx (Label)” formatting.
Conditional severity chip rendering
apps/csm-portal/microapp/src/components/support/CaseCard.tsx, apps/csm-portal/microapp/src/pages/CaseDetailPage.tsx
SeverityChip is now rendered only when severity is present, with comments noting only case-type items carry severity.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • wso2-open-operations/cs-tools#943: Both PRs update case severity handling from strict enums to backend-provided strings and adjust mapping logic for chip rendering.

Suggested labels: Type/Bug, Area/Frontend

Suggested reviewers: Rashmika998, cloby99

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary and testing, but it omits most required template sections like Purpose, Goals, Approach, and Release note. Add the missing template sections, especially Purpose, Goals, Approach, Release note, Documentation, and the remaining required metadata.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the main fix: loading issues plus state/severity alignment with the webapp.
✨ 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.

@cloby99
cloby99 merged commit 5a2d53d into wso2-open-operations:dev-app-csm-portal Jul 9, 2026
2 checks passed
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.

3 participants