Skip to content

Commit 1d9b02b

Browse files
[WEB-2724] fix: custom properties issue while moving to project (#6090)
* fixed custom properties adding issue * added error handling to function
1 parent 84c5e70 commit 1d9b02b

File tree

1 file changed

+37
-11
lines changed
  • web/core/components/issues/issue-modal

1 file changed

+37
-11
lines changed

web/core/components/issues/issue-modal/form.tsx

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
101101
const [labelModal, setLabelModal] = useState(false);
102102
const [selectedParentIssue, setSelectedParentIssue] = useState<ISearchIssueResponse | null>(null);
103103
const [gptAssistantModal, setGptAssistantModal] = useState(false);
104+
const [isMoving, setIsMoving] = useState<boolean>(false);
104105

105106
// refs
106107
const editorRef = useRef<EditorRefApi>(null);
@@ -113,8 +114,12 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
113114

114115
// store hooks
115116
const { getProjectById } = useProject();
116-
const { getIssueTypeIdOnProjectChange, getActiveAdditionalPropertiesLength, handlePropertyValuesValidation } =
117-
useIssueModal();
117+
const {
118+
getIssueTypeIdOnProjectChange,
119+
getActiveAdditionalPropertiesLength,
120+
handlePropertyValuesValidation,
121+
handleCreateUpdatePropertyValues,
122+
} = useIssueModal();
118123
const { isMobile } = usePlatformOS();
119124
const { moveIssue } = useWorkspaceDraftIssues();
120125

@@ -236,6 +241,33 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
236241
});
237242
};
238243

244+
const handleMoveToProjects = async () => {
245+
if (!data?.id || !data?.project_id || !data) return;
246+
setIsMoving(true);
247+
try {
248+
await handleCreateUpdatePropertyValues({
249+
issueId: data.id,
250+
issueTypeId: data.type_id,
251+
projectId: data.project_id,
252+
workspaceSlug: workspaceSlug.toString(),
253+
isDraft: true,
254+
});
255+
256+
await moveIssue(workspaceSlug.toString(), data.id, {
257+
...data,
258+
...getValues(),
259+
} as TWorkspaceDraftIssue);
260+
} catch (error) {
261+
setToast({
262+
type: TOAST_TYPE.ERROR,
263+
title: "Error!",
264+
message: "Failed to move issue to project. Please try again.",
265+
});
266+
} finally {
267+
setIsMoving(false);
268+
}
269+
};
270+
239271
const condition =
240272
(watch("name") && watch("name") !== "") || (watch("description_html") && watch("description_html") !== "<p></p>");
241273

@@ -492,15 +524,9 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
492524
variant="primary"
493525
type="button"
494526
size="sm"
495-
loading={isSubmitting}
496-
onClick={() => {
497-
if (data?.id && data) {
498-
moveIssue(workspaceSlug.toString(), data?.id, {
499-
...data,
500-
...getValues(),
501-
} as TWorkspaceDraftIssue);
502-
}
503-
}}
527+
loading={isMoving}
528+
onClick={handleMoveToProjects}
529+
disabled={isMoving}
504530
>
505531
Add to project
506532
</Button>

0 commit comments

Comments
 (0)