-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[WEB-2724] fix: custom properties issue while moving to project #6090
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,7 +113,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => { | |
|
|
||
| // store hooks | ||
| const { getProjectById } = useProject(); | ||
| const { getIssueTypeIdOnProjectChange, getActiveAdditionalPropertiesLength, handlePropertyValuesValidation } = | ||
| const { getIssueTypeIdOnProjectChange, getActiveAdditionalPropertiesLength, handlePropertyValuesValidation, handleCreateUpdatePropertyValues } = | ||
| useIssueModal(); | ||
| const { isMobile } = usePlatformOS(); | ||
| const { moveIssue } = useWorkspaceDraftIssues(); | ||
|
|
@@ -236,6 +236,23 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => { | |
| }); | ||
| }; | ||
|
|
||
| const handleMoveToProjects = async () => { | ||
| if( !data?.id ||!data?.project_id || !data) return | ||
| await handleCreateUpdatePropertyValues({ | ||
| issueId: data.id, | ||
| issueTypeId: data.type_id, | ||
| projectId: data.project_id, | ||
| workspaceSlug: workspaceSlug.toString(), | ||
| isDraft: true | ||
| }) | ||
|
|
||
| moveIssue(workspaceSlug.toString(), data.id, { | ||
| ...data, | ||
| ...getValues(), | ||
| } as TWorkspaceDraftIssue); | ||
|
|
||
| } | ||
|
||
|
|
||
| const condition = | ||
| (watch("name") && watch("name") !== "") || (watch("description_html") && watch("description_html") !== "<p></p>"); | ||
|
|
||
|
|
@@ -493,14 +510,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => { | |
| type="button" | ||
| size="sm" | ||
| loading={isSubmitting} | ||
| onClick={() => { | ||
| if (data?.id && data) { | ||
| moveIssue(workspaceSlug.toString(), data?.id, { | ||
| ...data, | ||
| ...getValues(), | ||
| } as TWorkspaceDraftIssue); | ||
| } | ||
| }} | ||
| onClick={handleMoveToProjects} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Update button to reflect loading state The button should display the loading state during the move operation. - onClick={handleMoveToProjects}
+ onClick={handleMoveToProjects}
+ loading={isMoving} // Add this prop after adding the state
+ disabled={isMoving} // Prevent multiple clicks
|
||
| > | ||
| Add to project | ||
| </Button> | ||
|
|
||
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.
🛠️ Refactor suggestion
Add error handling and user feedback
While the function correctly handles the core operations, it needs better error handling and user feedback:
Consider this implementation:
const handleMoveToProjects = async () => { if (!data?.id || !data?.project_id || !data) return; + try { + setIsMoving(true); // Add this state await handleCreateUpdatePropertyValues({ issueId: data.id, issueTypeId: data.type_id, projectId: data.project_id, workspaceSlug: workspaceSlug.toString(), isDraft: true }); await moveIssue(workspaceSlug.toString(), data.id, { ...data, ...getValues(), } as TWorkspaceDraftIssue); + setToast({ + type: TOAST_TYPE.SUCCESS, + title: "Success!", + message: "Issue successfully moved to project.", + }); + } catch (error) { + setToast({ + type: TOAST_TYPE.ERROR, + title: "Error!", + message: "Failed to move issue to project. Please try again.", + }); + } finally { + setIsMoving(false); // Add this state + } }