Skip to content

[CSM Portal Microapp] Add a Linked Items tab to case details - #1394

Merged
rksk merged 2 commits into
wso2-open-operations:mainfrom
2003dinijay:feat/case-detail-linked-items
Aug 7, 2026
Merged

rksk merged 2 commits into
wso2-open-operations:mainfrom
2003dinijay:feat/case-detail-linked-items

Conversation

@2003dinijay

@2003dinijay 2003dinijay commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds a Linked Items tab to the case detail page, mirroring the webapp's related tab — the backend already returns child cases, linked service requests, and linked change requests on the case-detail response, but none of it was surfaced anywhere in the microapp.
  • Child cases and Linked service requests both page through a new parentId-scoped case search (POST /cases/search { filters: { parentId } }) — the same underlying relationship both lists share, so the two queries dedupe against one cache entry. Rows are tappable, navigating straight to that case/change request.
  • Linked change requests fans out a per-row GET /change-requests/{id} (via useQueries) using the ids the case-detail response already carries, so state/target-environment resolve independently per row without blocking the others.
  • Adapted from the webapp's desktop tables to mobile cards; dropped the webapp's per-widget refresh buttons since this page already refetches the whole case on every mutation.
  • Adds LinkCaseDialog — search-and-pick a case to link the current one to as its parent or as a related case, with the same confirm-before-committing UX as the webapp (pick a result, review it, then confirm) before the PATCH fires.
  • Threads a CreateServiceRequestFromCaseNavState through to NewServiceRequestPage, so "Create service request" from a case locks the Project field, pre-seeds deployment/deployed product, and links the new request back to the originating case in the same create call — no separate create-then-link round trip.

Test plan

  • tsc --noEmit and eslint pass clean across every touched/new file.
  • exercised in a local browser session — the microapp authenticates via a native superapp bridge with no standalone fallback; verified by code review and close comparison against the webapp's working related tab, useSearchChildCases, useQuickCaseSearch, and LinkCaseDialog.

Summary by CodeRabbit

  • New Features
    • Added a Linked Items tab to case details.
    • Link cases as parent or related cases with search, review, and confirmation.
    • View linked service requests and change requests, including loading and error states.
    • Create pre-populated service requests directly from a case.
    • Added child-case search and quick case search across case types.
    • Linking and creation actions are disabled for closed cases.

The case detail page had no way to see or manage a case's related records —
child cases, linked service requests, and linked change requests were all
fetched by the backend but never surfaced, and there was no way to link a
case to another one or file a service request pre-linked to it. Adds a
"Linked Items" tab mirroring the webapp's `related` tab: Child cases and
Linked service requests both page through a new parentId-scoped case search
(POST /cases/search { filters: { parentId } }, the same relationship both
widgets share), and Linked change requests fans out a per-row GET via the
change-request ids the case-detail response already carries. Adapted from
the webapp's desktop tables to mobile cards, dropping its per-widget refresh
buttons — this page already refetches the whole case on every mutation.

Also adds LinkCaseDialog (search-and-pick a case to link as parent or
related, confirm-before-committing like the webapp) and threads a
CreateServiceRequestFromCaseNavState through to NewServiceRequestPage so
"Create service request" locks the Project field and links the new request
back to the originating case in one step, instead of a separate
create-then-link round trip.
Copilot AI lite review requested due to automatic review settings August 7, 2026 06:28

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 Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds linked-case search and confirmation, a Linked Items tab, child and related-record retrieval, case-link mutations, and case-originated service-request creation.

Changes

Case linked-items workflow

Layer / File(s) Summary
Case relationship contracts and search
apps/csm-portal/microapp/src/types/case.dto.ts, apps/csm-portal/microapp/src/types/case.model.ts, apps/csm-portal/microapp/src/services/cases.ts
Adds parent and related-case fields, linked-record references, child-case search, and debounced quick-search query options.
Case link selection and confirmation
apps/csm-portal/microapp/src/components/case-detail/LinkCaseDialog.tsx
Adds parent or related link selection, debounced search, current-case exclusion, confirmation, and linking states.
Linked items tab and related records
apps/csm-portal/microapp/src/components/case-detail/LinkedItemsTab.tsx
Displays child cases, linked service requests, and linked change requests with loading, error, empty, enrichment, and navigation states.
Case detail linking integration
apps/csm-portal/microapp/src/pages/CaseDetailPage.tsx
Adds the Linked Items tab, link mutation handling, cache invalidation, conditional tab visibility, and navigation to service-request creation.
Case-originated service-request creation
apps/csm-portal/microapp/src/pages/NewServiceRequestPage.tsx
Reads case navigation state, preloads deployment and product values, locks the project, displays the originating case, and sends relatedCaseId.

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

Sequence Diagram(s)

sequenceDiagram
  participant CaseDetailPage
  participant LinkCaseDialog
  participant cases.quickSearch
  participant LinkedItemsTab
  participant NewServiceRequestPage
  CaseDetailPage->>LinkCaseDialog: Open case-link dialog
  LinkCaseDialog->>cases.quickSearch: Search for cases
  cases.quickSearch-->>LinkCaseDialog: Return matching cases
  LinkCaseDialog->>CaseDetailPage: Confirm case ID and link type
  CaseDetailPage->>LinkedItemsTab: Refresh linked items
  LinkedItemsTab->>NewServiceRequestPage: Open linked service-request form
  NewServiceRequestPage->>NewServiceRequestPage: Submit relatedCaseId
Loading

Possibly related PRs

Suggested labels: Type/New Feature

Suggested reviewers: hesara2003

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the feature, implementation approach, and test plan but omits most required template sections, including release note, documentation, security, training, and test environment. Complete the required template sections and explicitly mark non-applicable sections as N/A with brief explanations.
✅ Passed checks (3 passed)
Check name Status Explanation
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 identifies the primary change: adding a Linked Items tab to case details in the CSM Portal Microapp.
✨ 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: 4

🤖 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/LinkedItemsTab.tsx`:
- Around line 240-245: Update the enrichment flow around searchChildren and
enrichedById to use the related-case relationship for service requests: fetch
linked service-request details by ref.id or add a query filtering by
relatedCaseId, then merge those records into the map used by the cards so state,
severity, and assignee are populated.
- Around line 187-205: Update the count prop on the Child cases
LinkedItemsSection so it remains undefined while isError is true, as it already
does during loading; only use rows.length when the query succeeds. Preserve the
existing error content and empty-state behavior for non-error results.

In `@apps/csm-portal/microapp/src/pages/NewServiceRequestPage.tsx`:
- Around line 77-85: Handle errors from lockedProjectQuery in the project
initialization flow around lockedProjectId and the ProjectSelect disabled logic:
show a clear project-load failure state with retry or back navigation, or enable
ProjectSelect so the user can choose another project when loading fails. Ensure
the form is not left unusable when fromCaseState exists but lockedProjectQuery
cannot resolve the project.

In `@apps/csm-portal/microapp/src/services/cases.ts`:
- Around line 293-313: The searchChildCases function only retrieves the first
CHILD_CASES_LIMIT records, so update it to accept pagination parameters and
return the resulting pagination metadata alongside mapped cases. Update the
Linked Items child-case consumer to use load-more or an infinite-query flow,
requesting subsequent offsets until all cases are available while preserving the
existing filters and row mapping.
🪄 Autofix

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 Plus

Run ID: a0f6b98a-dc23-4265-b742-a66bed6346aa

📥 Commits

Reviewing files that changed from the base of the PR and between e8d38e1 and fa9b0a5.

📒 Files selected for processing (7)
  • apps/csm-portal/microapp/src/components/case-detail/LinkCaseDialog.tsx
  • apps/csm-portal/microapp/src/components/case-detail/LinkedItemsTab.tsx
  • apps/csm-portal/microapp/src/pages/CaseDetailPage.tsx
  • apps/csm-portal/microapp/src/pages/NewServiceRequestPage.tsx
  • apps/csm-portal/microapp/src/services/cases.ts
  • apps/csm-portal/microapp/src/types/case.dto.ts
  • apps/csm-portal/microapp/src/types/case.model.ts

Comment thread apps/csm-portal/microapp/src/pages/NewServiceRequestPage.tsx
Comment thread apps/csm-portal/microapp/src/services/cases.ts
… lock

Two CodeRabbit findings on PR wso2-open-operations#1394, both still valid:

Child cases' count fell back to rows.length (0) on a search error, which
tripped LinkedItemsSection's isEmpty check and rendered the generic "No
child cases linked to this case." message instead of the actual error text
sitting right there in children. count now stays undefined on error too,
same as it already did while loading.

NewServiceRequestPage locked the Project field whenever arriving with
fromCaseState, with no way out if the project lookup itself failed —
project stayed null and the field stayed disabled forever. It now only
stays locked while that lookup hasn't errored, with an inline message
telling the engineer to pick a project manually if it has.

Left two other findings as-is: linked-service-request enrichment scoped to
the parentId children search, and the 20-item cap on child cases with no
pagination, both faithfully mirror the webapp's own useSearchChildCases /
LinkedServiceRequestsWidget rather than being regressions introduced here.
@rksk
rksk merged commit f4bdc3d into wso2-open-operations:main Aug 7, 2026
1 check 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