-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WEB-2686] fix: move to issue cycle and module action #5851
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (2)
web/core/components/issues/issue-modal/form.tsx (2)
69-69
: LGTM: NewhandleMoveIssue
prop enhances issue movement functionality.The addition of the
handleMoveIssue
prop provides a flexible way to handle issue movement. This change aligns with the removal of theuseWorkspaceDraftIssues
hook, 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
handleMoveIssue
prop, 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
handleMoveIssue
is 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 prophandleMoveIssue
enhances component flexibility.The addition of the optional
handleMoveIssue
prop 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
handleMoveIssue
prop is correctly destructured from the component props and appropriately passed down to theIssueFormRoot
component. 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 theDraftIssueLayout
component.The changes introduced in this file are well-implemented and improve the component's flexibility:
- A new optional prop
handleMoveIssue
has been added to theDraftIssueProps
interface.- The prop is correctly destructured from the component props.
- The prop is appropriately passed down to the
IssueFormRoot
component.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
TIssue
import and removal ofuseWorkspaceDraftIssues
suggest 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
IssueFormRoot
component, particularly in how it handles issue movement. By introducing thehandleMoveIssue
prop and removing theuseWorkspaceDraftIssues
hook, 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
: ImportingTWorkspaceDraftIssue
is appropriateThe type
TWorkspaceDraftIssue
is imported and used correctly in the code.
16-24
: ImportinguseWorkspaceDraftIssues
hookThe
useWorkspaceDraftIssues
hook is imported appropriately and sets up for managing draft issues within the workspace.
71-71
: DestructuringmoveIssue
fromuseWorkspaceDraftIssues
moveIssue
is correctly retrieved fromuseWorkspaceDraftIssues
and is ready for use in issue management.
@@ -338,6 +355,7 @@ export const CreateUpdateIssueModalBase: React.FC<IssuesModalProps> = observer(( | |||
onCreateMoreToggleChange={handleCreateMoreToggleChange} | |||
isDraft={isDraft} | |||
moveToIssue={moveToIssue} | |||
handleMoveIssue={handleMoveIssue} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplify async function and ensure proper type casting
-
Avoid mixing
await
and.then()
: In thehandleMoveIssue
function, mixingawait
with.then()
is unnecessary and can be simplified by usingawait
alone. -
Ensure correct type casting: When calling
moveIssue
,payload
is cast toTWorkspaceDraftIssue
. Verify thatpayload
conforms toTWorkspaceDraftIssue
to 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.