[WEB-2686] fix: move to issue cycle and module action#5851
[WEB-2686] fix: move to issue cycle and module action#5851anmolsinghbhatia wants to merge 1 commit intopreviewfrom
Conversation
WalkthroughThe pull request introduces enhancements to the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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 (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (2)
web/core/components/issues/issue-modal/form.tsx (2)
69-69: LGTM: NewhandleMoveIssueprop enhances issue movement functionality.The addition of the
handleMoveIssueprop provides a flexible way to handle issue movement. This change aligns with the removal of theuseWorkspaceDraftIssueshook, suggesting a more modular approach to issue management.Consider adding a brief comment to document the purpose and usage of this new prop for better maintainability.
438-442: LGTM: New "Add to project" button implements issue movement functionality.The addition of the "Add to project" button effectively utilizes the new
handleMoveIssueprop, allowing for flexible issue movement between projects. This implementation aligns well with the earlier changes in the component.Consider adding error handling for the case where
handleMoveIssueis undefined:onClick={() => { if (handleMoveIssue && data) { handleMoveIssue({ ...data, ...getValues(), }).catch((error) => { console.error("Failed to move issue:", error); // Optionally, show an error toast to the user }); } }}This will ensure graceful handling of any potential errors during the issue movement process.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
- web/core/components/issues/issue-modal/base.tsx (6 hunks)
- web/core/components/issues/issue-modal/draft-issue-layout.tsx (3 hunks)
- web/core/components/issues/issue-modal/form.tsx (5 hunks)
🧰 Additional context used
🔇 Additional comments (8)
web/core/components/issues/issue-modal/draft-issue-layout.tsx (3)
39-39: LGTM: New prophandleMoveIssueenhances component flexibility.The addition of the optional
handleMoveIssueprop is well-implemented. It follows the existing naming conventions and is correctly typed as(payload: Partial<TIssue>) => Promise<void>. This enhancement allows for external handling of issue movement, improving the component's versatility.
58-58: LGTM: Proper prop handling and passing to child component.The
handleMoveIssueprop is correctly destructured from the component props and appropriately passed down to theIssueFormRootcomponent. This change maintains the intended functionality flow and adheres to React's component composition principles.Also applies to: 178-178
39-39: Summary: Excellent enhancement to theDraftIssueLayoutcomponent.The changes introduced in this file are well-implemented and improve the component's flexibility:
- A new optional prop
handleMoveIssuehas been added to theDraftIssuePropsinterface.- The prop is correctly destructured from the component props.
- The prop is appropriately passed down to the
IssueFormRootcomponent.These changes allow for external handling of issue movement, enhancing the component's versatility without breaking existing functionality. The implementation follows React best practices and maintains consistency with the existing codebase structure.
Also applies to: 58-58, 178-178
web/core/components/issues/issue-modal/form.tsx (2)
10-10: LGTM: Import changes reflect updated type usage and draft issue handling.The addition of
TIssueimport and removal ofuseWorkspaceDraftIssuessuggest a shift in how issues, particularly draft issues, are handled in this component. This change appears to streamline the component's dependencies.Also applies to: 29-29
Line range hint
1-452: Overall: Excellent refactoring to improve issue movement handling.The changes in this file represent a well-executed refactoring of the
IssueFormRootcomponent, particularly in how it handles issue movement. By introducing thehandleMoveIssueprop and removing theuseWorkspaceDraftIssueshook, the component becomes more flexible and easier to maintain. The new "Add to project" button effectively utilizes this new structure.These modifications align well with React best practices by favoring prop-based function passing over tightly coupled hooks. This approach enhances the reusability and testability of the component.
Great job on improving the overall architecture of this component!
web/core/components/issues/issue-modal/base.tsx (3)
7-7: ImportingTWorkspaceDraftIssueis appropriateThe type
TWorkspaceDraftIssueis imported and used correctly in the code.
16-24: ImportinguseWorkspaceDraftIssueshookThe
useWorkspaceDraftIssueshook is imported appropriately and sets up for managing draft issues within the workspace.
71-71: DestructuringmoveIssuefromuseWorkspaceDraftIssues
moveIssueis correctly retrieved fromuseWorkspaceDraftIssuesand is ready for use in issue management.
| onCreateMoreToggleChange={handleCreateMoreToggleChange} | ||
| isDraft={isDraft} | ||
| moveToIssue={moveToIssue} | ||
| handleMoveIssue={handleMoveIssue} |
There was a problem hiding this comment.
Ensure handleMoveIssue is defined in child components' props
The handleMoveIssue prop is being passed to DraftIssueLayout and IssueFormRoot. Please ensure that these components accept handleMoveIssue as a prop and that their prop types (DraftIssueProps and IssueFormRootProps) are updated accordingly to include this new prop.
Also applies to: 379-379
| const handleMoveIssue = async (payload: Partial<TIssue>) => { | ||
| await handleUpdateIssue(payload).then(() => { | ||
| if (data?.id) { | ||
| moveIssue(workspaceSlug.toString(), data.id, payload as TWorkspaceDraftIssue); | ||
| } | ||
| }); | ||
| }; |
There was a problem hiding this comment.
Simplify async function and ensure proper type casting
-
Avoid mixing
awaitand.then(): In thehandleMoveIssuefunction, mixingawaitwith.then()is unnecessary and can be simplified by usingawaitalone. -
Ensure correct type casting: When calling
moveIssue,payloadis cast toTWorkspaceDraftIssue. Verify thatpayloadconforms toTWorkspaceDraftIssueto prevent potential runtime errors.
Apply this diff to simplify the code:
const handleMoveIssue = async (payload: Partial<TIssue>) => {
- await handleUpdateIssue(payload).then(() => {
- if (data?.id) {
- moveIssue(workspaceSlug.toString(), data.id, payload as TWorkspaceDraftIssue);
- }
- });
+ await handleUpdateIssue(payload);
+ if (data?.id) {
+ moveIssue(workspaceSlug.toString(), data.id, payload as TWorkspaceDraftIssue);
+ }
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const handleMoveIssue = async (payload: Partial<TIssue>) => { | |
| await handleUpdateIssue(payload).then(() => { | |
| if (data?.id) { | |
| moveIssue(workspaceSlug.toString(), data.id, payload as TWorkspaceDraftIssue); | |
| } | |
| }); | |
| }; | |
| const handleMoveIssue = async (payload: Partial<TIssue>) => { | |
| await handleUpdateIssue(payload); | |
| if (data?.id) { | |
| moveIssue(workspaceSlug.toString(), data.id, payload as TWorkspaceDraftIssue); | |
| } | |
| }; |
Reference:
[WEB-2686]
Summary by CodeRabbit
New Features
Improvements
These changes significantly enhance the functionality and usability of the issue management features in the application.