Skip to content

[CSM Portal Microapp] Build out the Case detail page - #1149

Merged
Rashmika998 merged 33 commits into
wso2-open-operations:dev-app-csm-portalfrom
Hesara2003:feature/csm-microapp-case-detail
Jul 15, 2026
Merged

[CSM Portal Microapp] Build out the Case detail page#1149
Rashmika998 merged 33 commits into
wso2-open-operations:dev-app-csm-portalfrom
Hesara2003:feature/csm-microapp-case-detail

Conversation

@Hesara2003

@Hesara2003 Hesara2003 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Purpose

Build out the CSM Portal microapp case detail experience so engineers can view and act on case information without falling back to the web app. This change also addresses interaction gaps around pause conflicts and dialog/input behavior inside the case detail flow.

Goals

  • Deliver a fuller case detail page in the microapp.
  • Support lifecycle actions, comments, attachments, SLAs, call requests, and time-tracking visibility.
  • Align case detail state and validation behavior with the backend rules.
  • Fix dialog and input interaction issues discovered during the case detail rollout.

Approach

  • Expanded the case detail page with dedicated tabs and components for attachments, comments, SLAs, call requests, and time tracking.
  • Added lifecycle action UI, including pause-conflict handling, resolution flows, and severity updates.
  • Added/updated service, endpoint, DTO, and model layers for case details, attachments, call requests, and SLA data.
  • Added work-state gating utilities so customer-visible comment behavior matches backend rules.
  • Hoisted dialog paper into a shared stable component and fixed the call-request duration input behavior to avoid disruptive remount/reset issues while typing.

User stories

  • As a CSM microapp user, I can inspect case details without leaving the microapp.
  • As a user, I can manage lifecycle actions such as pause, resolution, and severity changes from the case detail page.
  • As a user, I can review and add comments, inspect attachments, review SLAs, and manage call requests in one place.

Release note

Expanded the CSM Portal microapp case detail page with lifecycle actions, comments, attachments, SLAs, call requests, and supporting interaction fixes.

Documentation

N/A - This is a microapp UI and client-side integration enhancement; no external product documentation update is required.

Training

N/A - No training-material change is required for this microapp case detail enhancement.

Certification

N/A - No certification exam impact for this change.

Marketing

N/A - No marketing content is needed for this internal product enhancement.

Automation tests

  • Unit tests
    Not run locally for this PR.
  • Integration tests
    Not run locally for this PR.

Security checks

Samples

N/A - No sample assets or sample applications were added.

Related PRs

N/A

Migrations (if applicable)

N/A - No migration steps are required.

Test environment

Not run locally for this PR.

Learning

Reused existing microapp service and case UI patterns, then extended them to cover case-detail-specific state handling, backend-aligned comment gating, and more stable dialog composition.

Summary by CodeRabbit

  • New Features
    • Added case-detail tabs for Activities (unified timeline), Attachments, SLAs, and Call requests (plus a time-tracking shortcut).
    • Introduced severity/resolution modals, a pause-conflict confirmation, and redesigned case actions and comment composer with public vs internal work notes.
  • Improvements
    • Enhanced attachment uploads with configurable size limits, upload-disabled UI, partial-failure retry, and automatic refresh after completion.
    • Improved loading/retry behavior (Suspense + error boundaries) and more reliable backend error messaging, including safer comment rendering for HTML/plain text.

…ns, comments, attachments, SLAs, call requests

Adds the full webapp-parity Case detail experience: nextStates-driven
state transitions with the resolution dialog for close/propose-solution,
severity change, work-state (ongoing/paused) toggle with the
single-active-case pause-conflict dialog, gated comment composer
(public vs work-note rules) with inline attachments, and new SLAs /
Attachments / Call requests / Time tracking tabs backed by new
services (slas, callRequests, extended attachments/cases).
…for real

The ongoing-conflict check and confirm dialog from the previous commit
had three real bugs, found by reading the Go backend directly and
tracing live 409s instead of guessing:

- The single-ongoing-case rule is enforced entirely by the upstream
  ServiceNow instance (confirmed: that error text appears nowhere in
  the portal's own backend), so the proactive search was only ever a
  prediction — it needed a reactive fallback using the case number
  ServiceNow's own 409 already names, not just a proactive check.
- The reactive fallback's case-number search always returned zero
  results because it omitted an explicit `types` filter — the only
  other place in this app that searches cases by text
  (SupportPage/toCaseSearchFilters) always sends one; omitting it
  scopes the search to nothing rather than "all types".
- "Assign to me"/"Start progress" ran the assignee change and state
  transition *before* checking for a conflict, so declining the pause
  dialog left the case reassigned and moved anyway. The whole
  sequence is now gated behind the conflict check so nothing is
  applied — not even the assignee change — until the check clears or
  the user explicitly confirms pausing the other case.

Also unwraps double-JSON-wrapped backend error messages (ApiError.ts)
so the real ServiceNow message surfaces cleanly instead of raw JSON.
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a185fc64-c7b6-43ce-9447-a80245ce0ca9

📥 Commits

Reviewing files that changed from the base of the PR and between e2b8e82 and 251936a.

📒 Files selected for processing (3)
  • apps/csm-portal/microapp/src/components/case-detail/AttachmentsTab.tsx
  • apps/csm-portal/microapp/src/components/support/AttachmentsField.tsx
  • apps/csm-portal/microapp/src/pages/CaseDetailPage.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/csm-portal/microapp/src/components/support/AttachmentsField.tsx
  • apps/csm-portal/microapp/src/pages/CaseDetailPage.tsx
  • apps/csm-portal/microapp/src/components/case-detail/AttachmentsTab.tsx

📝 Walkthrough

Walkthrough

Adds a tabbed CSM case-detail experience with case transitions, dialogs, comment composition, activity timelines, attachment uploads, SLA and call-request views, time-card navigation, conflict handling, and supporting query services and domain types.

Changes

Case detail functionality

Layer / File(s) Summary
Contracts and query services
apps/csm-portal/microapp/src/config/endpoints.ts, apps/csm-portal/microapp/src/services/*, apps/csm-portal/microapp/src/types/*
Adds endpoint constants, DTOs, domain mappers, type exports, and query services for case details, attachments, call requests, SLAs, comments, and activities.
Case transitions and dialogs
apps/csm-portal/microapp/src/pages/CaseDetailPage.tsx, apps/csm-portal/microapp/src/components/case-detail/CaseActionBar.tsx, apps/csm-portal/microapp/src/components/case-detail/*Dialog.tsx
Adds tab navigation, case patching, transition controls, resolution and severity workflows, ongoing-case conflict handling, and mutation error presentation.
Comment composition and rendering
apps/csm-portal/microapp/src/components/case-detail/Comment*.tsx, apps/csm-portal/microapp/src/components/support/AttachmentsField.tsx, apps/csm-portal/microapp/src/utils/*
Adds comment/work-note gating, attachment picker reuse and size overrides, sanitized/truncated comment rendering, normalized API errors, and comment submission behavior.
Unified activity timeline
apps/csm-portal/microapp/src/components/case-detail/CaseActivityFeed.tsx, apps/csm-portal/microapp/src/services/activities.ts, apps/csm-portal/microapp/src/types/activity.*
Adds field-change activity contracts, search and mapping services, and a combined newest-first comments, audit, and attachments feed.
Secondary case-detail tabs
apps/csm-portal/microapp/src/components/case-detail/{AttachmentsTab,CallRequestsTab,SlaTab,TimeTrackingTab}.tsx, apps/csm-portal/microapp/src/services/{attachments,callRequests,slas}.ts
Adds attachment listing/upload, call-request creation and listing, SLA progress display, and navigation to time cards with Suspense and retry states.

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

Sequence Diagram(s)

sequenceDiagram
  participant CaseDetailPage
  participant CommentComposer
  participant cases
  participant attachments
  CaseDetailPage->>CommentComposer: render gated composer
  CommentComposer-->>CaseDetailPage: submit comment and attachments
  CaseDetailPage->>cases: post comment
  CaseDetailPage->>attachments: create attachments
  CaseDetailPage-->>CaseDetailPage: invalidate comments query
Loading

Possibly related PRs

Suggested labels: Type/New Feature, Area/Frontend, Platform/Microapp

Suggested reviewers: cloby99, rashmika998

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 48.65% 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 matches the main change: expanding the CSM Portal microapp case detail page.
Description check ✅ Passed The description covers all required template sections with reasonable detail, including purpose, goals, approach, testing, and security notes.
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.

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

🤖 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/microapp/src/components/case-detail/AttachmentsTab.tsx`:
- Around line 67-78: Update the upload completion logic in AttachmentsTab to
retain only rejected attachment entries from the Promise.allSettled results,
rather than clearing all pending files. Preserve successful uploads as removed,
keep failed files selected for retry, and ensure the existing error messaging
and upload-state cleanup remain unchanged.

In `@apps/csm-portal/microapp/src/components/case-detail/CaseActionBar.tsx`:
- Around line 126-127: Replace the inline paper component in the CaseActionBar
dialog’s slots configuration with the shared DialogPaper component. Import
DialogPaper from its existing shared module and preserve the current paper
styling through slotProps.

In `@apps/csm-portal/microapp/src/components/case-detail/CommentBody.tsx`:
- Around line 42-55: Update CommentBody’s rendering decision to test
HTML_FORMAT_RE against the full content rather than the truncated shown value,
preserving the same rendering mode when expanded. For truncated HTML, sanitize
the sliced content first and append the ellipsis outside the sanitized HTML so
it remains visible even when truncation cuts through a tag; keep plain-text
truncation behavior unchanged.

In `@apps/csm-portal/microapp/src/components/case-detail/CommentComposer.tsx`:
- Around line 65-67: Update the canSubmit calculation in CommentComposer to
check whether the currently selected type is blocked, rather than relying only
on allBlocked. Preserve attachment-only submission and existing content and
isSubmitting requirements, while preventing posts when the selected comment type
becomes blocked after a caseState refresh.

In `@apps/csm-portal/microapp/src/components/case-detail/PauseConflictDialog.tsx`:
- Around line 42-46: Update the Dialog’s onClose handler in PauseConflictDialog
to ignore dismissal attempts while isSubmitting is true, while preserving the
existing onDecline behavior when submission is not in progress.

In `@apps/csm-portal/microapp/src/components/support/AttachmentsField.tsx`:
- Around line 57-61: Update the oversized-file validation branch in the
AttachmentsField change handler to reset the file input via
inputRef.current.value before returning. Preserve the existing error message and
early-return behavior so the same file can be selected again after correction.

In `@apps/csm-portal/microapp/src/pages/CaseDetailPage.tsx`:
- Around line 145-154: Update runOngoingAction and the assign/start/ongoing flow
to make the transition atomic: use a backend operation that applies assignment,
work-in-progress, and ongoing state together, or restore the original assignee
and state before setting pendingOngoingAction and showing the conflict dialog.
Ensure declining the dialog leaves the case unchanged as promised by the
cancellation path around the conflict handling.
- Around line 323-334: Update the submission promise handler around the results
processing so it returns failure when the submission contains only attachments
and every upload is rejected, preventing the composer from clearing files after
displaying the retry error. Preserve the existing success return for partial
failures or submissions with text, and use the existing fields.attachments and
text/content state symbols to distinguish the all-failed attachment-only case.

In `@apps/csm-portal/microapp/src/services/cases.ts`:
- Around line 129-133: Normalize both email values before the comparison in the
loop filtering within the cases-matching function: lowercase myEmail as well as
c.assignedEngineer.email, while preserving the existing fallback behavior and
other filters.

In `@apps/csm-portal/microapp/src/utils/ApiError.ts`:
- Around line 42-52: Update unwrapMessage to preserve the supplied fallback when
trimming or recursively unwrapping produces an empty message. Ensure the same
non-empty check is applied to the related fallback handling around the second
referenced section, while retaining existing JSON unwrapping and prefix removal
behavior for valid messages.
🪄 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: ab06391d-271d-4ef0-81fd-81d664ecb90c

📥 Commits

Reviewing files that changed from the base of the PR and between 3d1101d and b65d1eb.

📒 Files selected for processing (31)
  • apps/csm-portal/microapp/src/components/case-detail/AttachmentsTab.tsx
  • apps/csm-portal/microapp/src/components/case-detail/CallRequestsTab.tsx
  • apps/csm-portal/microapp/src/components/case-detail/CaseActionBar.tsx
  • apps/csm-portal/microapp/src/components/case-detail/ChangeSeverityDialog.tsx
  • apps/csm-portal/microapp/src/components/case-detail/CommentBody.tsx
  • apps/csm-portal/microapp/src/components/case-detail/CommentComposer.tsx
  • apps/csm-portal/microapp/src/components/case-detail/PauseConflictDialog.tsx
  • apps/csm-portal/microapp/src/components/case-detail/ResolutionDialog.tsx
  • apps/csm-portal/microapp/src/components/case-detail/SlaTab.tsx
  • apps/csm-portal/microapp/src/components/case-detail/TimeTrackingTab.tsx
  • apps/csm-portal/microapp/src/components/case-detail/caseResolution.ts
  • apps/csm-portal/microapp/src/components/common/DialogPaper.tsx
  • apps/csm-portal/microapp/src/components/support/AttachmentsField.tsx
  • apps/csm-portal/microapp/src/config/endpoints.ts
  • apps/csm-portal/microapp/src/pages/CaseDetailPage.tsx
  • apps/csm-portal/microapp/src/services/attachments.ts
  • apps/csm-portal/microapp/src/services/callRequests.ts
  • apps/csm-portal/microapp/src/services/cases.ts
  • apps/csm-portal/microapp/src/services/slas.ts
  • apps/csm-portal/microapp/src/types/attachment.dto.ts
  • apps/csm-portal/microapp/src/types/attachment.model.ts
  • apps/csm-portal/microapp/src/types/callRequest.dto.ts
  • apps/csm-portal/microapp/src/types/callRequest.model.ts
  • apps/csm-portal/microapp/src/types/case.dto.ts
  • apps/csm-portal/microapp/src/types/case.model.ts
  • apps/csm-portal/microapp/src/types/index.ts
  • apps/csm-portal/microapp/src/types/sla.dto.ts
  • apps/csm-portal/microapp/src/types/sla.model.ts
  • apps/csm-portal/microapp/src/utils/ApiError.ts
  • apps/csm-portal/microapp/src/utils/attachments.ts
  • apps/csm-portal/microapp/src/utils/caseWorkState.ts

Comment thread apps/csm-portal/microapp/src/components/case-detail/CaseActionBar.tsx Outdated
Comment thread apps/csm-portal/microapp/src/components/case-detail/CommentBody.tsx Outdated
Comment thread apps/csm-portal/microapp/src/components/case-detail/CommentComposer.tsx Outdated
Comment thread apps/csm-portal/microapp/src/pages/CaseDetailPage.tsx
Comment thread apps/csm-portal/microapp/src/pages/CaseDetailPage.tsx Outdated
Comment thread apps/csm-portal/microapp/src/services/cases.ts
Comment thread apps/csm-portal/microapp/src/utils/ApiError.ts
@Hesara2003

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 15, 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.

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

🧹 Nitpick comments (1)
apps/csm-portal/microapp/src/components/case-detail/CaseActionBar.tsx (1)

78-95: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove unnecessary React fragments.

The <Fragment> and <> wrappers around the single Button and FormControl root elements are redundant and can be safely removed, which will also allow you to drop the Fragment import.

♻️ Proposed refactor

For the single target button:

-    return (
-      <Fragment>
-        <Button
-          variant="contained"
-          size="small"
-          disabled={isPending}
-          onClick={() => runTarget(targets[0])}
-          sx={{ borderRadius: 999 }}
-        >
-          {labelFor(targets[0])}
-        </Button>
-      </Fragment>
-    );
+    return (
+      <Button
+        variant="contained"
+        size="small"
+        disabled={isPending}
+        onClick={() => runTarget(targets[0])}
+        sx={{ borderRadius: 999 }}
+      >
+        {labelFor(targets[0])}
+      </Button>
+    );

For the multiple target select (and remove </> at the end of the return statement):

-  return (
-    <>
-      <FormControl size="small" sx={{ minWidth: 150, flexShrink: 0 }}>
+  return (
+    <FormControl size="small" sx={{ minWidth: 150, flexShrink: 0 }}>
🤖 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/microapp/src/components/case-detail/CaseActionBar.tsx` around
lines 78 - 95, In CaseActionBar, remove the redundant Fragment wrappers around
the single Button and FormControl return roots, including the matching closing
fragment tag for the multi-target path, and remove the now-unused Fragment
import.
🤖 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/microapp/src/components/case-detail/CaseActivityFeed.tsx`:
- Around line 167-183: The “Download” IconButton in the attachment actions
currently invokes the same full-screen openUrl behavior as “Open.” Update its
onClick handler to use the bridge’s download mechanism with the attachment
downloadUrl, or remove the download control if no download API is available;
leave the “Open” button unchanged.

In `@apps/csm-portal/microapp/src/services/activities.ts`:
- Around line 31-40: Update searchCaseActivities to handle paginated responses
when hasMore is true, fetching subsequent pages with the appropriate offset
until all activity records are collected before filtering and mapping
field_change entries. Preserve the existing page limit and return the complete
CaseAuditEntry history.

---

Nitpick comments:
In `@apps/csm-portal/microapp/src/components/case-detail/CaseActionBar.tsx`:
- Around line 78-95: In CaseActionBar, remove the redundant Fragment wrappers
around the single Button and FormControl return roots, including the matching
closing fragment tag for the multi-target path, and remove the now-unused
Fragment import.
🪄 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: 91c1ec17-81ab-4df8-94fd-67c39292571a

📥 Commits

Reviewing files that changed from the base of the PR and between b65d1eb and 71e9915.

📒 Files selected for processing (15)
  • apps/csm-portal/microapp/src/components/case-detail/AttachmentsTab.tsx
  • apps/csm-portal/microapp/src/components/case-detail/CaseActionBar.tsx
  • apps/csm-portal/microapp/src/components/case-detail/CaseActivityFeed.tsx
  • apps/csm-portal/microapp/src/components/case-detail/CommentBody.tsx
  • apps/csm-portal/microapp/src/components/case-detail/CommentComposer.tsx
  • apps/csm-portal/microapp/src/components/case-detail/PauseConflictDialog.tsx
  • apps/csm-portal/microapp/src/components/support/AttachmentsField.tsx
  • apps/csm-portal/microapp/src/config/endpoints.ts
  • apps/csm-portal/microapp/src/pages/CaseDetailPage.tsx
  • apps/csm-portal/microapp/src/services/activities.ts
  • apps/csm-portal/microapp/src/services/cases.ts
  • apps/csm-portal/microapp/src/types/activity.dto.ts
  • apps/csm-portal/microapp/src/types/activity.model.ts
  • apps/csm-portal/microapp/src/types/index.ts
  • apps/csm-portal/microapp/src/utils/ApiError.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • apps/csm-portal/microapp/src/utils/ApiError.ts
  • apps/csm-portal/microapp/src/config/endpoints.ts
  • apps/csm-portal/microapp/src/components/case-detail/PauseConflictDialog.tsx
  • apps/csm-portal/microapp/src/components/case-detail/AttachmentsTab.tsx
  • apps/csm-portal/microapp/src/components/case-detail/CommentComposer.tsx
  • apps/csm-portal/microapp/src/pages/CaseDetailPage.tsx
  • apps/csm-portal/microapp/src/services/cases.ts

Comment thread apps/csm-portal/microapp/src/components/case-detail/CaseActivityFeed.tsx Outdated
Comment thread apps/csm-portal/microapp/src/services/activities.ts Outdated
@s-sandali

Copy link
Copy Markdown

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 15, 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.

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