Add continuous action labels and chat routing - #243
Conversation
Introduce toPresentContinuousActionLabel util and tests to show present-continuous labels (e.g., "Closing...") for pending case actions. Update CaseDetailsActionRow to track the pending action label, display the continuous label while an action is pending, and clear it on settle to avoid incorrect button text. Add conditional chat routing in CasesTable using getNoveraChatEnabled to navigate to the appropriate chat or create-case flow. Trim activation/deactivation date values in ProjectInformationCard before formatting to prevent whitespace-related display issues. Includes corresponding unit tests for the new label mappings.
📝 WalkthroughWalkthroughThe PR enhances case management UX by introducing pending action state tracking in the case details header, adding a utility function for present-continuous action labels, implementing conditional routing in case creation based on Novera chat enablement, and improving date string validation robustness in project information display. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
apps/customer-portal/webapp/src/components/project-details/project-overview/project-information/ProjectInformationCard.tsx (1)
48-55: Redundant double.trim()call — store the trimmed value once.
val?.trim()is called twice: once as a truthiness check and once as the argument toformatProjectDate. Storing the trimmed value avoids the duplication.♻️ Suggested simplification
- const getStartDate = () => { - const val = project?.account?.activationDate; - return val?.trim() ? formatProjectDate(val.trim()) : "--"; - }; - const getEndDate = () => { - const val = project?.account?.deactivationDate; - return val?.trim() ? formatProjectDate(val.trim()) : "--"; - }; + const getStartDate = () => { + const val = project?.account?.activationDate?.trim(); + return val ? formatProjectDate(val) : "--"; + }; + const getEndDate = () => { + const val = project?.account?.deactivationDate?.trim(); + return val ? formatProjectDate(val) : "--"; + };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/webapp/src/components/project-details/project-overview/project-information/ProjectInformationCard.tsx` around lines 48 - 55, In getStartDate and getEndDate, avoid trimming the same string twice: read the raw date (project?.account?.activationDate / deactivationDate) into a variable, compute a single trimmed value (e.g., trimmed = raw?.trim()), then use that trimmed value for the truthiness check and pass it to formatProjectDate; update getStartDate and getEndDate to use the trimmed variable instead of calling val?.trim() twice.apps/customer-portal/webapp/src/utils/support.ts (1)
840-849: Consider extracting the label map as a module-level constant.The
mapobject is reallocated on every call. While the map is small and the impact is negligible, extracting it as a module-levelconst(the same improvement also applies totoPresentTenseActionLabel) avoids repeated allocation and makes the mapping directly visible at the module level.♻️ Suggested refactor
+const PRESENT_CONTINUOUS_ACTION_LABEL_MAP: Record<string, string> = { + Closed: "Closing...", + Reopened: "Reopening...", + "Waiting on WSO2": "Waiting on WSO2...", + "Waiting On WSO2": "Waiting on WSO2...", + "Accept Solution": "Accepting...", + "Reject Solution": "Rejecting...", +}; + export function toPresentContinuousActionLabel(label: string): string { - const map: Record<string, string> = { - Closed: "Closing...", - Reopened: "Reopening...", - "Waiting on WSO2": "Waiting on WSO2...", - "Waiting On WSO2": "Waiting on WSO2...", - "Accept Solution": "Accepting...", - "Reject Solution": "Rejecting...", - }; - return map[label] ?? `${label}...`; + return PRESENT_CONTINUOUS_ACTION_LABEL_MAP[label] ?? `${label}...`; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/webapp/src/utils/support.ts` around lines 840 - 849, Extract the inline mapping object in toPresentContinuousActionLabel into a module-level constant (e.g., PRESENT_CONTINUOUS_ACTION_LABEL_MAP) and have the function reference that constant instead of recreating the map on each call; do the same refactor for toPresentTenseActionLabel (e.g., PRESENT_TENSE_ACTION_LABEL_MAP) so both functions use preallocated module-level objects for their lookups.apps/customer-portal/webapp/src/utils/__tests__/support.test.ts (1)
367-384: Missing test cases for"Waiting on WSO2"mapping and the fallback.The new test suite covers 4 of the 6 explicit mappings. Two gaps:
"Waiting on WSO2"→"Waiting on WSO2..."— this label is actually returned bygetAvailableCaseActionsand rendered inCaseDetailsActionRow, so leaving it untested is a real coverage gap.- Fallback case —
toPresentTenseActionLabelhas an equivalent test ("Accept Solution"returns unchanged); the continuous variant has no test for an unmapped label (e.g.,"Open Related Case"→"Open Related Case...").✅ Suggested additions
+ it("should map Waiting on WSO2 to Waiting on WSO2...", () => { + expect(toPresentContinuousActionLabel("Waiting on WSO2")).toBe( + "Waiting on WSO2...", + ); + }); + it("should append ... for unmapped labels", () => { + expect(toPresentContinuousActionLabel("Open Related Case")).toBe( + "Open Related Case...", + ); + });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/webapp/src/utils/__tests__/support.test.ts` around lines 367 - 384, Add two missing tests for toPresentContinuousActionLabel: one asserting "Waiting on WSO2" maps to "Waiting on WSO2..." and one asserting an unmapped label (e.g., "Open Related Case") falls back to appending "..." (so "Open Related Case" -> "Open Related Case..."). Place them in the same describe("toPresentContinuousActionLabel", ...) block in support.test.ts alongside the existing cases so the behavior in getAvailableCaseActions / CaseDetailsActionRow is covered and the fallback path is validated.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@apps/customer-portal/webapp/src/components/project-details/project-overview/project-information/ProjectInformationCard.tsx`:
- Around line 48-55: In getStartDate and getEndDate, avoid trimming the same
string twice: read the raw date (project?.account?.activationDate /
deactivationDate) into a variable, compute a single trimmed value (e.g., trimmed
= raw?.trim()), then use that trimmed value for the truthiness check and pass it
to formatProjectDate; update getStartDate and getEndDate to use the trimmed
variable instead of calling val?.trim() twice.
In `@apps/customer-portal/webapp/src/utils/__tests__/support.test.ts`:
- Around line 367-384: Add two missing tests for toPresentContinuousActionLabel:
one asserting "Waiting on WSO2" maps to "Waiting on WSO2..." and one asserting
an unmapped label (e.g., "Open Related Case") falls back to appending "..." (so
"Open Related Case" -> "Open Related Case..."). Place them in the same
describe("toPresentContinuousActionLabel", ...) block in support.test.ts
alongside the existing cases so the behavior in getAvailableCaseActions /
CaseDetailsActionRow is covered and the fallback path is validated.
In `@apps/customer-portal/webapp/src/utils/support.ts`:
- Around line 840-849: Extract the inline mapping object in
toPresentContinuousActionLabel into a module-level constant (e.g.,
PRESENT_CONTINUOUS_ACTION_LABEL_MAP) and have the function reference that
constant instead of recreating the map on each call; do the same refactor for
toPresentTenseActionLabel (e.g., PRESENT_TENSE_ACTION_LABEL_MAP) so both
functions use preallocated module-level objects for their lookups.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/customer-portal/webapp/src/components/dashboard/cases-table/CasesTable.tsxapps/customer-portal/webapp/src/components/project-details/project-overview/project-information/ProjectInformationCard.tsxapps/customer-portal/webapp/src/components/support/case-details/header/CaseDetailsActionRow.tsxapps/customer-portal/webapp/src/utils/__tests__/support.test.tsapps/customer-portal/webapp/src/utils/support.ts
| "Waiting on WSO2": "Waiting on WSO2...", | ||
| "Waiting On WSO2": "Waiting on WSO2...", |
There was a problem hiding this comment.
Why do we have 02 different conventions to these keys? on and On?
There was a problem hiding this comment.
Because of data inconsisistensy , will adress in later
4fce3c9
into
wso2-open-operations:customer-portal-milestone-1
Introduce toPresentContinuousActionLabel util and tests to show present-continuous labels (e.g., "Closing...") for pending case actions. Update CaseDetailsActionRow to track the pending action label, display the continuous label while an action is pending, and clear it on settle to avoid incorrect button text. Add conditional chat routing in CasesTable using getNoveraChatEnabled to navigate to the appropriate chat or create-case flow. Trim activation/deactivation date values in ProjectInformationCard before formatting to prevent whitespace-related display issues. Includes corresponding unit tests for the new label mappings.
Purpose
Goals
Approach
User stories
Release note
Documentation
Training
Certification
Marketing
Automation tests
Security checks
Samples
Related PRs
Migrations (if applicable)
Test environment
Learning
Summary by CodeRabbit
New Features
Bug Fixes