[WEB-2724] fix: custom properties issue while moving to project (#6090)
* fixed custom properties adding issue * added error handling to function
This commit is contained in:
parent
84c5e70181
commit
1d9b02b085
1 changed files with 37 additions and 11 deletions
|
|
@ -101,6 +101,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
|
||||||
const [labelModal, setLabelModal] = useState(false);
|
const [labelModal, setLabelModal] = useState(false);
|
||||||
const [selectedParentIssue, setSelectedParentIssue] = useState<ISearchIssueResponse | null>(null);
|
const [selectedParentIssue, setSelectedParentIssue] = useState<ISearchIssueResponse | null>(null);
|
||||||
const [gptAssistantModal, setGptAssistantModal] = useState(false);
|
const [gptAssistantModal, setGptAssistantModal] = useState(false);
|
||||||
|
const [isMoving, setIsMoving] = useState<boolean>(false);
|
||||||
|
|
||||||
// refs
|
// refs
|
||||||
const editorRef = useRef<EditorRefApi>(null);
|
const editorRef = useRef<EditorRefApi>(null);
|
||||||
|
|
@ -113,8 +114,12 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
|
||||||
|
|
||||||
// store hooks
|
// store hooks
|
||||||
const { getProjectById } = useProject();
|
const { getProjectById } = useProject();
|
||||||
const { getIssueTypeIdOnProjectChange, getActiveAdditionalPropertiesLength, handlePropertyValuesValidation } =
|
const {
|
||||||
useIssueModal();
|
getIssueTypeIdOnProjectChange,
|
||||||
|
getActiveAdditionalPropertiesLength,
|
||||||
|
handlePropertyValuesValidation,
|
||||||
|
handleCreateUpdatePropertyValues,
|
||||||
|
} = useIssueModal();
|
||||||
const { isMobile } = usePlatformOS();
|
const { isMobile } = usePlatformOS();
|
||||||
const { moveIssue } = useWorkspaceDraftIssues();
|
const { moveIssue } = useWorkspaceDraftIssues();
|
||||||
|
|
||||||
|
|
@ -236,6 +241,33 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleMoveToProjects = async () => {
|
||||||
|
if (!data?.id || !data?.project_id || !data) return;
|
||||||
|
setIsMoving(true);
|
||||||
|
try {
|
||||||
|
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);
|
||||||
|
} catch (error) {
|
||||||
|
setToast({
|
||||||
|
type: TOAST_TYPE.ERROR,
|
||||||
|
title: "Error!",
|
||||||
|
message: "Failed to move issue to project. Please try again.",
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
setIsMoving(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const condition =
|
const condition =
|
||||||
(watch("name") && watch("name") !== "") || (watch("description_html") && watch("description_html") !== "<p></p>");
|
(watch("name") && watch("name") !== "") || (watch("description_html") && watch("description_html") !== "<p></p>");
|
||||||
|
|
||||||
|
|
@ -492,15 +524,9 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
|
||||||
variant="primary"
|
variant="primary"
|
||||||
type="button"
|
type="button"
|
||||||
size="sm"
|
size="sm"
|
||||||
loading={isSubmitting}
|
loading={isMoving}
|
||||||
onClick={() => {
|
onClick={handleMoveToProjects}
|
||||||
if (data?.id && data) {
|
disabled={isMoving}
|
||||||
moveIssue(workspaceSlug.toString(), data?.id, {
|
|
||||||
...data,
|
|
||||||
...getValues(),
|
|
||||||
} as TWorkspaceDraftIssue);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
Add to project
|
Add to project
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue