Skip to content

[CSM Portal] add "Assigned to me" dashboard widget + work sub-state in cases list - #1023

Merged
cloby99 merged 2 commits into
wso2-open-operations:v2from
rksk:csm-my-assigned-cases-widget
Jul 3, 2026
Merged

[CSM Portal] add "Assigned to me" dashboard widget + work sub-state in cases list#1023
cloby99 merged 2 commits into
wso2-open-operations:v2from
rksk:csm-my-assigned-cases-widget

Conversation

@rksk

@rksk rksk commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Adds an "Assigned to me" widget to the engineer dashboard and surfaces the work sub-state in the shared cases list.

What

  • "Assigned to me" dashboard widget — lists the signed-in engineer's non-closed cases (their active workload). Filtered server-side via POST /cases/search (assignedUserIds = caller's id + all non-closed states); no client-side filtering of a superset. Paginates a small page (5/page); "View all" jumps to the cases page pre-filtered to the same assignee + states. Skips the account-name lookup the main list does, so the dashboard adds a single request. Disabled until the caller's id is known (renders an unavailable state rather than broadening to everyone's cases).
  • Work sub-state in the cases listCasesList now shows Ongoing / Paused under the State chip when a case is in progress (paused is coloured to stand out). Shared by the cases page and the new widget.
  • State-label normalizationuiStateFromBe now normalizes the raw case-search state label ("Work In Progress") to the enum form (work_in_progress) at the API boundary, so cases render with the curated label/colour and state-based checks match regardless of source. Unknown states still pass through (humanized). Unit tests added.

Testing

  • pnpm test — all unit tests pass (incl. new uiStateFromBe normalization cases).
  • pnpm lint — clean for the changed files.
  • Verified live against the staging backend: the widget lists assigned non-closed cases, pagination works, State chips render correctly, and "View all" deep-links with the assignee + state filter.

Notes

  • Follows the existing pattern: no data-source UI gating.
  • Backend follow-up (tracked separately): the ServiceNow case-search view returns the raw state label instead of the normalized enum, unlike its sibling fields (severity / work state / issue type). This PR normalizes defensively on the FE; the clean fix is in the entity-service search view.

Summary by CodeRabbit

  • New Features

    • Added a dashboard widget showing your assigned open cases, with pagination and direct access to the full filtered case list.
    • Displayed additional state details for cases in progress, including a more descriptive substatus label.
  • Bug Fixes

    • Improved case state handling so human-readable backend labels are normalized correctly and shown consistently in the UI.

…n cases list

Add a dashboard widget listing the signed-in engineer's non-closed cases
(their active workload), and surface the work sub-state in the shared cases
list.

- New "Assigned to me" widget on the engineer dashboard. Filters server-side
  via POST /cases/search (assignedUserIds = caller's id + all non-closed
  states); no client-side filtering of a superset. Paginates a small page
  (5/page) and links "View all" to the cases page pre-filtered to the same
  assignee + states. Skips the account-name lookup the main list does, so the
  dashboard load stays a single request. Disabled until the caller's id is
  known (renders an unavailable state rather than broadening to everyone's
  cases).
- CasesList now shows the work sub-state (Ongoing / Paused) under the State
  chip when a case is in progress; paused is coloured to stand out. Shared by
  the cases page and the dashboard widget.
- uiStateFromBe now normalizes the raw ServiceNow state label
  ("Work In Progress") to the enum form (work_in_progress) at the API
  boundary, so SN-sourced cases render with the curated label/colour and
  state-based checks match regardless of source. Unknown states still pass
  through (humanized). Added unit tests.
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 468df411-a2b7-44b3-8661-e83b9c6c43ce

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR normalizes backend case-state strings for consistent enum mapping, adds a work sub-state caption to the CasesList "State" column, introduces a useGetMyAssignedOpenCases data hook, and adds a new MyAssignedCases dashboard widget wired into the engineer dashboard page.

Changes

State normalization and dashboard widget

Layer / File(s) Summary
Normalize backend case state mapping
apps/csm-portal/webapp/src/api/backend/mappers.ts, apps/csm-portal/webapp/src/api/backend/mappers.test.ts
uiStateFromBe now trims, lowercases, and collapses whitespace into underscores before casting to CaseState, with a new test verifying normalization of human-readable ServiceNow labels.
Display work sub-state caption in CasesList
apps/csm-portal/webapp/src/features/csm-cases/components/CasesList.tsx
The "State" cell now shows an additional caption with WORK_STATE_LABEL[c.workState] when a case is work_in_progress, colored based on paused status.
Assigned open cases data hook
apps/csm-portal/webapp/src/features/csm-dashboard/api/useGetMyAssignedOpenCases.ts
New hook fetches paginated non-closed cases assigned to the current user via a server-side search, exporting NON_CLOSED_STATES, MY_OPEN_CASES_LINK_STATES, MY_OPEN_CASES_PAGE_SIZE, and the MyAssignedOpenCases type.
MyAssignedCases widget and dashboard wiring
apps/csm-portal/webapp/src/features/csm-dashboard/components/MyAssignedCases.tsx, apps/csm-portal/webapp/src/features/csm-dashboard/pages/CsmDashboardPage.tsx
New widget renders paginated assigned cases in a SectionCard with a deep-link to full cases list, handles loading/error/empty/unknown-user states, and is added to the engineer dashboard.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CsmDashboardPage
  participant MyAssignedCases
  participant useGetMyAssignedOpenCases
  participant CasesSearchAPI
  participant CasesList

  CsmDashboardPage->>MyAssignedCases: render (engineer dashboard)
  MyAssignedCases->>useGetMyAssignedOpenCases: call(page, pageSize)
  useGetMyAssignedOpenCases->>CasesSearchAPI: POST /cases/search (assignedUserIds, non-closed states)
  CasesSearchAPI-->>useGetMyAssignedOpenCases: case records
  useGetMyAssignedOpenCases-->>MyAssignedCases: cases, total, hasMore
  MyAssignedCases->>CasesList: render rows with state/workState
  CasesList-->>MyAssignedCases: rendered state chip + caption
Loading

Possibly related PRs

Suggested reviewers: cloby99, dilshanfardil

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the feature, but it omits most required template sections such as Purpose, Goals, Approach, User stories, and release note. Rewrite the PR body using the template and add the missing sections: Purpose, Goals, Approach (with UI screenshot), User stories, Release note, Documentation, and the testing/security/migration fields.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the two main changes: a new Assigned to me widget and work sub-state rendering in the cases list.
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.
✨ 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.

@rksk

rksk commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 3, 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: 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-dashboard/api/useGetMyAssignedOpenCases.ts`:
- Around line 95-158: useGetMyAssignedOpenCases resets its query data on page
changes, which makes MyAssignedCases lose pagination state temporarily; update
the useQuery call in useGetMyAssignedOpenCases to preserve the previous result
while fetching the next page by adding placeholderData with keepPreviousData.
Make sure the change keeps the existing queryKey and queryFn behavior intact so
total and hasMore stay available between page transitions.
🪄 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: 4d73b9c7-ea12-4ad9-9f7d-ee6187f8f5f2

📥 Commits

Reviewing files that changed from the base of the PR and between e9694b8 and b0e4559.

📒 Files selected for processing (6)
  • apps/csm-portal/webapp/src/api/backend/mappers.test.ts
  • apps/csm-portal/webapp/src/api/backend/mappers.ts
  • apps/csm-portal/webapp/src/features/csm-cases/components/CasesList.tsx
  • apps/csm-portal/webapp/src/features/csm-dashboard/api/useGetMyAssignedOpenCases.ts
  • apps/csm-portal/webapp/src/features/csm-dashboard/components/MyAssignedCases.tsx
  • apps/csm-portal/webapp/src/features/csm-dashboard/pages/CsmDashboardPage.tsx

…oads

Add placeholderData: keepPreviousData to useGetMyAssignedOpenCases so the
widget keeps the prior page rows and total while the next page loads, instead
of dropping data (which blinked the pager out and flashed skeletons on every
page change). Matches the repo pagination-hook convention (useSearchAccounts,
useSearchChangeRequests, useProjectSearch).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

App/CSM Portal Area/Frontend Platform/Web Type/New Feature Represents a request or task for a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants