[WEB-3837] fix: mutation of child work item added via Cmd+K with parent context#6910
Conversation
WalkthroughThis change refactors the issue handling within the Changes
Sequence Diagram(s)sequenceDiagram
participant UI as User Interface
participant ILM as IssueLevelModals
participant Actions as Issues Actions Hook
UI->>ILM: Trigger handleDeleteIssue(issueId, workspaceSlug, projectId)
ILM->>ILM: Check if issue is Epic?
alt Issue is Epic
ILM->>Actions: Call removeEpic(issueId)
else Issue is Project Issue
ILM->>Actions: Call removeWorkItem(issueId)
end
Actions-->>ILM: Return result
ILM->>UI: Redirect on success / Show error on failure
sequenceDiagram
participant UI as User Interface
participant ILM as IssueLevelModals
participant API as Backend API
UI->>ILM: Trigger handleCreateIssueSubmit(newIssue)
ILM->>ILM: Validate newIssue properties
alt Issue is Epic
ILM->>API: Call createEpic(newIssue)
else Standard Work Item
ILM->>API: Call createWorkItem(newIssue)
end
API-->>ILM: Return creation result
ILM->>ILM: Prepare modal data with getCreateIssueModalData()
ILM->>UI: Update modal with new issue details
Possibly Related PRs
Suggested Labels
Suggested Reviewers
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Pull Request Linked with Plane Work Items
Comment Automatically Generated by Plane |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
web/ce/components/command-palette/modals/issue-level.tsx (2)
49-60: Consider user-facing error handling.
While the try/catch logs errors, users might benefit from a more explicit error notification when deletion fails.You could add a toast or alert modal to provide feedback:
} catch (error) { - console.error("Failed to delete issue:", error); + console.error("Failed to delete issue:", error); + // e.g., add a toast notification here }
62-67: Improve error handling during issue creation.
Currently, this function silently returns if any condition fails. Consider adding confirmation or logging for debug purposes, especially iffetchSubWorkItemsorfetchEpicSubWorkItemsthrows.const handleCreateIssueSubmit = async (newIssue: TIssue) => { if (!workspaceSlug || !newIssue.project_id || !newIssue.id || newIssue.parent_id !== issueDetails?.id) { // e.g., console.error or show a toast about invalid submission return; } try { const fetchAction = issueDetails?.is_epic ? fetchEpicSubWorkItems : fetchSubWorkItems; await fetchAction(workspaceSlug?.toString(), newIssue.project_id, issueDetails.id); } catch (error) { console.error("Issue creation failed:", error); } };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
web/ce/components/command-palette/modals/issue-level.tsx(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
web/ce/components/command-palette/modals/issue-level.tsx (5)
web/core/hooks/use-issues-actions.tsx (1)
useIssuesActions(40-82)web/core/hooks/store/use-issue-detail.ts (1)
useIssueDetail(9-14)packages/types/src/issues/issue.d.ts (1)
TIssue(54-67)web/core/components/issues/issue-modal/modal.tsx (1)
CreateUpdateIssueModal(34-50)web/core/components/issues/delete-issue-modal.tsx (1)
DeleteIssueModal(27-125)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Analyze (javascript)
- GitHub Check: Analyze (python)
🔇 Additional comments (8)
web/ce/components/command-palette/modals/issue-level.tsx (8)
4-6: Imports look good.
No issues here; this is a straightforward addition of imports and labeling with a comment.
13-13: New import usage is appropriate.
The import foruseIssuesActionslooks correct and consistent with the rest of the codebase.
31-34: Clear separation of epic vs. work item removal.
Renaming the imported removeIssue function is a good approach for readability, ensuring each removal action is context-specific.
46-47: Well-structured fetch action for sub-issues.
These aliases effectively distinguish between epic vs. standard work items, aligning with the logic inuseIssueDetail.
69-73: Data preparation method is concise.
This function cleanly handles conditional modal data logic.
80-80: Correct usage of modal data.
Passing the computed object fromgetCreateIssueModalData()ensures the right fields are pre-filled.
82-82: Submission handler properly assigned.
TheonSubmitprop correctly references the newly introducedhandleCreateIssueSubmit.
89-90: Deletion callback is well-integrated.
The code ensures the workspace, project, and issue IDs are passed in a controlled context, preventing undefined values.
Summary
Fixed an issue where adding a new work item via the Cmd+K menu, with the current detail page set as its parent, didn’t immediately update the UI to reflect the change. The mutation logic was updated to ensure newly added child items appear instantly, and data syncing was improved for a smoother user experience.
Type of Change
References
[WEB-3837]
Summary by CodeRabbit