[CSM Portal] add "Assigned to me" dashboard widget + work sub-state in cases list - #1023
Conversation
…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.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR normalizes backend case-state strings for consistent enum mapping, adds a work sub-state caption to the CasesList "State" column, introduces a ChangesState normalization and dashboard widget
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
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai resume |
✅ Action performedReviews resumed. |
There was a problem hiding this comment.
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
📒 Files selected for processing (6)
apps/csm-portal/webapp/src/api/backend/mappers.test.tsapps/csm-portal/webapp/src/api/backend/mappers.tsapps/csm-portal/webapp/src/features/csm-cases/components/CasesList.tsxapps/csm-portal/webapp/src/features/csm-dashboard/api/useGetMyAssignedOpenCases.tsapps/csm-portal/webapp/src/features/csm-dashboard/components/MyAssignedCases.tsxapps/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).
Adds an "Assigned to me" widget to the engineer dashboard and surfaces the work sub-state in the shared cases list.
What
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).CasesListnow 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.uiStateFromBenow 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. newuiStateFromBenormalization cases).pnpm lint— clean for the changed files.Notes
Summary by CodeRabbit
New Features
Bug Fixes