Repository navigation
[Customer portal] [Web] Enhance Product Update Workflow with Improved State Management and Refactored Component Interfaces - #384
Conversation
Remove the unused `onClose` mock from the props in UpdateHistoryTab.test.tsx. This cleans up the test setup and avoids an unnecessary unused variable in the test file; no behavioral changes to the test logic.
Update UpdateHistoryTab to expose its form state to parents via an optional onFormStateChange callback (provides canAdd, isSaving and handleAdd). Compute isFormValid and notify the parent in a useEffect; hide the internal Add button when a parent callback is provided so the parent can control UI. Also sync TimelineItem edit form when the incoming update/isEditing changes. In ProjectDetails, derive the current project and its type label from the infinite projects cache (useInfiniteProjects + flattenProjectPages) to avoid duplicate lookups and to ensure availability earlier. Minor layout changes: replace the top-level fragment with a Box and simplify an inner Box wrapper.
Introduce addUpdateState in ManageProductModal to track whether the add/update form can add and is currently saving. Pass setAddUpdateState to the child form via onFormStateChange, disable the Close button while saving, and render an Add Update button (or a disabled "Adding..." spinner) on the Updates tab based on canAdd/isSaving. This lets the child form control the modal actions and prevents closing during save operations.
📝 WalkthroughWalkthroughThe changes refactor the "Add Update" form flow by shifting state management from the child Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@apps/customer-portal/webapp/src/components/project-details/deployments/ManageProductModal.tsx`:
- Around line 324-327: The modal can still be closed during a save because only
the footer Close Button is disabled; update the close logic by moving the busy
guard into handleClose (check isSubmitting || addUpdateState?.isSaving at the
top of handleClose and return early if busy) and then reuse handleClose
everywhere that can dismiss the Dialog (pass handleClose to Dialog's onClose and
the title-bar X onClick) so all dismissal paths respect the same guard.
In
`@apps/customer-portal/webapp/src/components/project-details/deployments/UpdateHistoryTab.tsx`:
- Around line 46-50: Change the lifted callback contract to accept a nullable
state and clear it on unmount: update the prop type signature for
onFormStateChange to accept (state: { canAdd: boolean; isSaving: boolean;
handleAdd: () => void; } | null) => void, and in the component that
sets/publishes the form state (the effect that calls onFormStateChange with {
canAdd, isSaving, handleAdd }) add a cleanup that calls
onFormStateChange?.(null) so the previous handleAdd is cleared when the tab
unmounts; apply the same nullable contract and unmount cleanup to the other
similar publisher (the second occurrence referenced in the review) and ensure
ManageProductModal consumers handle a null state.
In `@apps/customer-portal/webapp/src/pages/ProjectDetails.tsx`:
- Around line 56-63: The page is using the partial cache from
useInfiniteProjects + flattenProjectPages to derive currentProject and
projectTypeLabel, which can be undefined if the projectId isn't in the cached
pages; update the logic in ProjectDetails.tsx so that after computing
currentProject from flattenProjectPages(projectsData) you fall back to the exact
project details response (the hook or prop that returns the single project's
data) or trigger paging until the projectId is found; specifically, keep the
existing useInfiniteProjects and flattenProjectPages usage but if currentProject
is undefined then read from the project-details response (or call the
single-project hook) and set projectTypeLabel from that source (or loop/fetch
additional pages) so tab visibility is driven by the authoritative
project-details data rather than the partial projects cache.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d74a8d5d-2e6e-47fb-a41f-14c473a46a9f
📒 Files selected for processing (4)
apps/customer-portal/webapp/src/components/project-details/deployments/ManageProductModal.tsxapps/customer-portal/webapp/src/components/project-details/deployments/UpdateHistoryTab.tsxapps/customer-portal/webapp/src/components/project-details/deployments/__tests__/UpdateHistoryTab.test.tsxapps/customer-portal/webapp/src/pages/ProjectDetails.tsx
💤 Files with no reviewable changes (1)
- apps/customer-portal/webapp/src/components/project-details/deployments/tests/UpdateHistoryTab.test.tsx
Description
This pull request introduces improvements to the product update workflow in the customer portal, focusing on enhanced state management and UI responsiveness for adding updates, as well as refactoring component interfaces for better flexibility. The most important changes are grouped below:
Product Update Workflow Enhancements
addUpdateStatetoManageProductModal, allowing the modal to track whether an update can be added, whether saving is in progress, and providing a callback for adding updates. This enables more responsive UI controls and prevents duplicate submissions.Component Interface Refactoring
onCloseprop inUpdateHistoryTabwith a more flexibleonFormStateChangecallback, allowing parent components to react to form validity and saving state. [1] [2]UpdateHistoryTabto notify the parent of form state changes, enabling improved coordination between modal and tab components.UpdateHistoryTabto conditionally render controls based on whether the parent manages form state, increasing component reusability.Project Details Page Improvements
ProjectDetailsto useuseInfiniteProjectsandflattenProjectPagesfor retrieving all projects, ensuring the project type label is always up-to-date and improving logic for hiding deployments and time tracking sections. [1] [2] [3]ProjectDetailsfor improved maintainability and consistency. [1] [2]Minor Improvements and Fixes
useEffectinTimelineItemto reset edit form state when the update or editing state changes, ensuring form data remains consistent.onCloseprop from test setup forUpdateHistoryTab.These changes collectively improve the reliability and user experience of managing product updates within the portal.