[CSM Portal Microapp] Add create service request flow to the microapp - #1232
Conversation
Ports the webapp's catalog-driven service request creation (cascading project/deployment/deployed-product/catalog/catalog-item picker, dynamic ServiceNow variable form, attachments) to the microapp, entered via a new Fab on the Service Requests tab, matching the existing "Create case" Fab pattern on the Support page.
📝 WalkthroughWalkthroughAdds a catalog-driven service request creation flow to the operations microapp, including cascading lookups, dynamic variable fields, attachment uploads, validation, case creation support, and routing from the Service Requests tab. ChangesService request creation
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested labels: 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/csm-portal/microapp/src/services/catalogs.ts (1)
29-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicated pagination limit constant.
SEARCH_PAGE_LIMIT = 50is duplicated fromdeployments.tsper the comment. Consider extracting a shared constant (e.g., in a common config/util module) so both call sites stay in sync if the backend's effective cap changes.🤖 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/services/catalogs.ts` at line 29, Extract SEARCH_PAGE_LIMIT into a shared configuration or utility module, then update the references in catalogs.ts and deployments.ts to import and reuse that single constant. Preserve the existing value of 50 and pagination behavior.
🤖 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/pages/NewServiceRequestPage.tsx`:
- Around line 187-189: Update the disabled conditions for ProjectSelect, the
form controls, all other inputs, and the Cancel button in NewServiceRequestPage
to use isSubmitting alongside their existing field-specific conditions instead
of relying on createCase.isPending alone. Preserve each control’s current
validation/loading conditions while keeping every control non-interactive until
attachment uploads and the full submission complete.
- Around line 175-177: Update the submission catch block in
NewServiceRequestPage to capture the thrown error and log it with Logger.warn
before calling setSubmitError. Preserve the existing generic user-facing error
message and finally behavior.
---
Nitpick comments:
In `@apps/csm-portal/microapp/src/services/catalogs.ts`:
- Line 29: Extract SEARCH_PAGE_LIMIT into a shared configuration or utility
module, then update the references in catalogs.ts and deployments.ts to import
and reuse that single constant. Preserve the existing value of 50 and pagination
behavior.
🪄 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 Plus
Run ID: ef06412b-c99a-4e85-8bd4-41d16417319d
📒 Files selected for processing (12)
apps/csm-portal/microapp/src/App.tsxapps/csm-portal/microapp/src/components/operations/CatalogVariableFields.tsxapps/csm-portal/microapp/src/components/operations/ServiceRequestsTab.tsxapps/csm-portal/microapp/src/config/endpoints.tsapps/csm-portal/microapp/src/pages/NewServiceRequestPage.tsxapps/csm-portal/microapp/src/pages/OperationsPage.tsxapps/csm-portal/microapp/src/services/cases.tsapps/csm-portal/microapp/src/services/catalogs.tsapps/csm-portal/microapp/src/types/case.dto.tsapps/csm-portal/microapp/src/types/catalog.dto.tsapps/csm-portal/microapp/src/types/index.tsapps/csm-portal/microapp/src/utils/catalogVariables.ts
Log the caught error before showing the generic create-failure message, and gate every field's disabled state on isSubmitting alongside createCase.isPending — createCase.isPending alone flips false once the case-create call resolves, while attachments are still uploading, which let the form re-enable mid-submission.
Summary
Adds the "Create service request" flow to the CSM Portal microapp, matching how it already works in the webapp (
CreateServiceRequestPage.tsx).NewServiceRequestPageat/operations/service-requests/new: cascading Project → Deployment → Deployed Product → Catalog → Catalog Item picker, followed by a dynamically generated form built from that catalog item's ServiceNow variables, plus attachments.types/catalog.dto.ts— catalog / catalog-item / catalog-item-variable DTOsservices/catalogs.ts—POST /catalogs/searchand the catalog-item-variables endpointutils/catalogVariables.ts— ServiceNow variable classification (context/hidden/attachment/date-time/description fields) and value encoding, mirroring the webapp'sfeatures/csm-operations/utils/catalogVariables.tscomponents/operations/CatalogVariableFields.tsx— renders the dynamic per-variable inputsServiceRequestCreatePayloadDto/CaseVariableDtoadded totypes/case.dto.ts, andservices/cases.ts's create call extended to accept the new payload typeTwo deliberate mobile deviations from the webapp, consistent with this app's existing
NewCasePage.tsx:Stacklayout instead of the webapp's responsiveGrid/Card.TextFieldinstead of a rich-text editor (the microapp has no rich-text component).Review fixes
Addressed CodeRabbit findings on
NewServiceRequestPage.tsx:catchblock now captures and logs the underlying error viaLogger.warnbefore showing the existing generic user-facing message.disabledstate (project/deployment/product/catalog/catalog item selects, the dynamic variable fields, attachments, and Cancel) now also checksisSubmitting, not justcreateCase.isPending— the case-create mutation resolves before attachment uploads finish, socreateCase.isPendingalone was letting the form re-enable mid-submission.Test plan
tsc -bpasses with no errorseslintpasses on all new/changed files/operations/service-requests/newrenders the full cascading form with correct disabled/helper-text states at each stepSummary by CodeRabbit