Skip to content

[CSM Portal] add Problem management list and detail views - #1193

Merged
Rashmika998 merged 1 commit into
wso2-open-operations:mainfrom
rksk:problem-detail
Jul 21, 2026
Merged

Rashmika998 merged 1 commit into
wso2-open-operations:mainfrom
rksk:problem-detail

Conversation

@rksk

@rksk rksk commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

The CSM portal has no way to view Problem records. The existing search resource only returns id/number/subject, so there is no way to open a problem and see its full detail, including which incidents it links back to.

Goals

Adds Problem management to the CSM portal: a Problems tab (list + filters) on the Operations page, and a dedicated problem detail page, backed by a new GET /problems/{id} resource across the entity-service and CSM backend.

Approach

  • entity-service: new domain fields/handler wiring and a GET /problems/{id} resource on the backing data source, alongside the existing search resource.
  • CSM backend: entity client + handler + route for fetching a single problem, proxied through the existing auth/access-check pattern used by sibling resources.
  • webapp: useGetProblem/useSearchProblems hooks, a ProblemsTab + ProblemsFilterBar on the Operations page, and a ProblemDetailPage reachable via a new route from App.tsx.

Notable UX detail: a problem can link to multiple incidents, and the detail page renders each as its own distinct, clickable entry rather than collapsing them into a single reference. It also tolerates an origin-record reference that isn't guaranteed to be a Case.

Verified end-to-end against real data through the full stack (entity-service -> backend -> webapp), including a live browser check with a real login confirming a problem's linked incidents render correctly as separate entries.

A corresponding change on the backing data source side is tracked separately, outside this repo.

User stories

As a CS engineer, I can open a problem from the Operations page and see its full detail, including which incidents it is linked to, so I can triage without leaving the portal.

Release note

Adds Problem management (list + detail) to the CSM portal.

Documentation

N/A - internal CSM-portal feature, no external-facing docs impact.

Training

N/A

Certification

N/A - no certification content affected.

Marketing

N/A

Automation tests

  • Unit tests
    Backend: handler tests for the new GET /problems/{id} route (success, not-found, upstream error) using an in-package mock entity client. Webapp: unit tests for the problems util module and a component test for ProblemDetailPage covering the multi-incident rendering and the non-Case origin reference.
  • Integration tests
    Exercised the full chain (entity-service -> CSM backend -> webapp) against real data in a live browser session with a real login.

Security checks

Samples

N/A

Related PRs

None

Migrations (if applicable)

N/A - no schema migrations; additive API resource only.

Test environment

Verified locally against a real backing-data-source DEV environment, Node/pnpm + Go toolchain on macOS, Chrome (real login flow).

Learning

N/A


Note on PR size: this diff spans three components (entity-service, CSM backend, webapp) that are intentionally coupled - the webapp calls the new backend endpoint which calls the new entity-service endpoint - so it is one PR of 24 files rather than a split stack. One file (ProblemDetailPage.tsx, ~325 changed lines) is slightly over the usual per-file review size and may get summarized rather than line-by-line review.

Summary by CodeRabbit

  • New Features
    • Added Problem Management to Operations, including search, state filters, pagination, and clear-filter controls.
    • Added read-only problem detail pages with overview, linked records, resolution information, loading, error, and not-found states.
    • Added support for retrieving detailed problem records through the API.
  • Documentation
    • Updated API specifications with problem detail endpoints and response schemas.
  • Tests
    • Added coverage for problem search, detail views, validation, error handling, and filter utilities.

Adds a Problems tab to the Operations page and a dedicated problem
detail page, sourced end-to-end from a new backing-service GET
/problems/{id} resource. The existing search resource only returned
id/number/subject, so opening a problem needed a way to fetch the
full record including its linked incidents.

Renders linked incidents as distinct, individually clickable entries
(a genuine one-to-many relationship) and handles an origin-record
reference that isn't always guaranteed to be a case.
@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds end-to-end ServiceNow problem detail retrieval, including entity-service and CSM backend APIs, frontend search and filtering, Operations navigation, and a read-only problem detail page with linked records and resolution data.

Changes

Problem detail API stack

Layer / File(s) Summary
Entity service detail endpoint
entity-service/internal/domain/entity.go, entity-service/internal/service/..., entity-service/internal/handler/..., entity-service/openapi.yaml
Adds ProblemDetail, ServiceNow response mapping, GET /problems/{id}, service error handling, and OpenAPI definitions.
CSM backend problem proxy
apps/csm-portal/backend/cmd/server/main.go, apps/csm-portal/backend/internal/entity/entity.go, apps/csm-portal/backend/internal/handler/..., apps/csm-portal/backend/openapi.yaml
Adds authenticated UUID-validated proxy handling, upstream client access, route registration, response schema, and handler coverage.
Problem search and operations tab
apps/csm-portal/webapp/src/api/backend/types.ts, apps/csm-portal/webapp/src/features/csm-operations/api/*, apps/csm-portal/webapp/src/features/csm-operations/components/*, apps/csm-portal/webapp/src/features/csm-operations/pages/OperationsPage.tsx, apps/csm-portal/webapp/src/features/csm-operations/utils/*
Adds problem models, React Query hooks, state utilities, filters, debounced search, pagination, table states, and the Problem management tab.
Problem detail page
apps/csm-portal/webapp/src/App.tsx, apps/csm-portal/webapp/src/features/csm-operations/pages/ProblemDetailPage.tsx, apps/csm-portal/webapp/src/features/csm-operations/pages/ProblemDetailPage.test.tsx
Adds the authenticated detail route and a read-only page with overview, linked records, resolution data, navigation, and query-state tests.

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

Sequence Diagram(s)

sequenceDiagram
  participant OperationsUI
  participant CSMBackend
  participant EntityService
  participant ServiceNow
  OperationsUI->>CSMBackend: GET /problems/{id}
  CSMBackend->>EntityService: GET /problems/{id}
  EntityService->>ServiceNow: GET /problems/{sysid}
  ServiceNow-->>EntityService: Problem detail payload
  EntityService-->>CSMBackend: ProblemDetail JSON
  CSMBackend-->>OperationsUI: ProblemDetail JSON
Loading

Possibly related PRs

Suggested labels: Type/New Feature

Suggested reviewers: rashmika998

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 52.94% 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 summarizes the main change: adding Problem management list and detail views for the CSM Portal.
Description check ✅ Passed The description closely follows the template and includes clear Purpose, Goals, Approach, testing, and release information.
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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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

rksk commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor
✅ 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.

Actionable comments posted: 3

🧹 Nitpick comments (2)
entity-service/internal/handler/problem_handler.go (1)

61-62: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Explicitly set the HTTP status code.

While json.NewEncoder(w).Encode implicitly writes a 200 OK status upon the first write, explicitly calling w.WriteHeader(http.StatusOK) improves clarity and maintains consistency with other handlers (like SearchProblems).

♻️ Proposed refactor
 	w.Header().Set("Content-Type", "application/json")
+	w.WriteHeader(http.StatusOK)
 	_ = json.NewEncoder(w).Encode(result)
🤖 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 `@entity-service/internal/handler/problem_handler.go` around lines 61 - 62,
Update the response-writing flow in the problem handler to explicitly call
w.WriteHeader(http.StatusOK) before encoding result with
json.NewEncoder(w).Encode. Preserve the existing JSON content type and response
body behavior, matching the status handling used by SearchProblems.
apps/csm-portal/webapp/src/features/csm-operations/pages/ProblemDetailPage.tsx (1)

188-198: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate grid layout object across three cards.

The same gridTemplateColumns grid sx object is repeated verbatim for Overview, Linked records, and Resolution. Extracting it once avoids drift if the column layout changes later.

♻️ Proposed extraction
+const METACELL_GRID_SX = {
+  display: "grid",
+  gap: 2,
+  gridTemplateColumns: {
+    xs: "1fr",
+    sm: "repeat(2, minmax(0, 1fr))",
+    md: "repeat(3, minmax(0, 1fr))",
+  },
+} as const;

Then reuse sx={METACELL_GRID_SX} at each of the three call sites instead of the inline literal.

Also applies to: 221-231, 272-282

🤖 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-operations/pages/ProblemDetailPage.tsx`
around lines 188 - 198, Extract the repeated grid layout object used by the
Overview, Linked records, and Resolution cards into a shared METACELL_GRID_SX
constant in ProblemDetailPage, then replace all three inline sx objects with
sx={METACELL_GRID_SX}. Preserve the existing responsive grid values unchanged.
🤖 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-operations/components/ProblemsTab.tsx`:
- Around line 141-154: Make the clickable TableRow in the ProblemsTab rendering
keyboard-operable: add an appropriate row role and tabIndex, and handle Enter
and Space in onKeyDown to navigate to the same problem detail URL as onClick.
Preserve mouse navigation and prevent default behavior for activated keys.

In `@entity-service/internal/domain/entity.go`:
- Around line 2711-2714: Rename the timestamp fields and JSON tags in
entity-service/internal/domain/entity.go:2711-2714 from ResolvedAt, OpenedAt,
and ClosedAt to ResolvedOn, OpenedOn, and ClosedOn; update
entity-service/internal/service/sn_problem_service.go:186-188 to initialize the
new fields while retaining the existing source values; and rename the
corresponding schema properties to resolvedOn, openedOn, and closedOn in
entity-service/openapi.yaml:6241-6252 and
apps/csm-portal/backend/openapi.yaml:7095-7106.

In `@entity-service/openapi.yaml`:
- Around line 6219-6222: Update the linkedIncidents property in the relevant
OpenAPI schema to include nullable: true, preserving its existing array type and
CaseNumberRef item reference.

---

Nitpick comments:
In
`@apps/csm-portal/webapp/src/features/csm-operations/pages/ProblemDetailPage.tsx`:
- Around line 188-198: Extract the repeated grid layout object used by the
Overview, Linked records, and Resolution cards into a shared METACELL_GRID_SX
constant in ProblemDetailPage, then replace all three inline sx objects with
sx={METACELL_GRID_SX}. Preserve the existing responsive grid values unchanged.

In `@entity-service/internal/handler/problem_handler.go`:
- Around line 61-62: Update the response-writing flow in the problem handler to
explicitly call w.WriteHeader(http.StatusOK) before encoding result with
json.NewEncoder(w).Encode. Preserve the existing JSON content type and response
body behavior, matching the status handling used by SearchProblems.
🪄 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: 179c9566-0231-4de0-85f9-28e4fd81bc3b

📥 Commits

Reviewing files that changed from the base of the PR and between 6e0aecf and 7c2fd68.

📒 Files selected for processing (24)
  • apps/csm-portal/backend/cmd/server/main.go
  • apps/csm-portal/backend/internal/entity/entity.go
  • apps/csm-portal/backend/internal/handler/helpers_test.go
  • apps/csm-portal/backend/internal/handler/problems.go
  • apps/csm-portal/backend/internal/handler/problems_test.go
  • apps/csm-portal/backend/openapi.yaml
  • apps/csm-portal/webapp/src/App.tsx
  • apps/csm-portal/webapp/src/api/backend/types.ts
  • apps/csm-portal/webapp/src/constants/apiConstants.ts
  • apps/csm-portal/webapp/src/features/csm-operations/api/useGetProblem.ts
  • apps/csm-portal/webapp/src/features/csm-operations/api/useSearchProblems.ts
  • apps/csm-portal/webapp/src/features/csm-operations/components/ProblemsFilterBar.tsx
  • apps/csm-portal/webapp/src/features/csm-operations/components/ProblemsTab.tsx
  • apps/csm-portal/webapp/src/features/csm-operations/pages/OperationsPage.tsx
  • apps/csm-portal/webapp/src/features/csm-operations/pages/ProblemDetailPage.test.tsx
  • apps/csm-portal/webapp/src/features/csm-operations/pages/ProblemDetailPage.tsx
  • apps/csm-portal/webapp/src/features/csm-operations/utils/__tests__/problems.test.ts
  • apps/csm-portal/webapp/src/features/csm-operations/utils/problems.ts
  • entity-service/internal/domain/entity.go
  • entity-service/internal/handler/problem_handler.go
  • entity-service/internal/server/routes.go
  • entity-service/internal/service/interfaces.go
  • entity-service/internal/service/sn_problem_service.go
  • entity-service/openapi.yaml

Comment thread entity-service/internal/domain/entity.go
Comment thread entity-service/openapi.yaml
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