-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[WEB-2686] fix: move to issue cycle and module action #5851
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 all commits
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 |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ import React, { useEffect, useRef, useState } from "react"; | |
| import { observer } from "mobx-react"; | ||
| import { useParams, usePathname } from "next/navigation"; | ||
| // types | ||
| import type { TIssue } from "@plane/types"; | ||
| import type { TIssue, TWorkspaceDraftIssue } from "@plane/types"; | ||
| // ui | ||
| import { EModalPosition, EModalWidth, ModalCore, TOAST_TYPE, setToast } from "@plane/ui"; | ||
| import { CreateIssueToastActionItems, IssuesModalProps } from "@/components/issues"; | ||
|
|
@@ -13,7 +13,15 @@ import { ISSUE_CREATED, ISSUE_UPDATED } from "@/constants/event-tracker"; | |
| import { EIssuesStoreType } from "@/constants/issue"; | ||
| // hooks | ||
| import { useIssueModal } from "@/hooks/context/use-issue-modal"; | ||
| import { useEventTracker, useCycle, useIssues, useModule, useIssueDetail, useUser } from "@/hooks/store"; | ||
| import { | ||
| useEventTracker, | ||
| useCycle, | ||
| useIssues, | ||
| useModule, | ||
| useIssueDetail, | ||
| useUser, | ||
| useWorkspaceDraftIssues, | ||
| } from "@/hooks/store"; | ||
| import { useIssueStoreType } from "@/hooks/use-issue-layout-store"; | ||
| import { useIssuesActions } from "@/hooks/use-issues-actions"; | ||
| // services | ||
|
|
@@ -60,6 +68,7 @@ export const CreateUpdateIssueModalBase: React.FC<IssuesModalProps> = observer(( | |
| const { issues: draftIssues } = useIssues(EIssuesStoreType.WORKSPACE_DRAFT); | ||
| const { fetchIssue } = useIssueDetail(); | ||
| const { handleCreateUpdatePropertyValues } = useIssueModal(); | ||
| const { moveIssue } = useWorkspaceDraftIssues(); | ||
| // pathname | ||
| const pathname = usePathname(); | ||
| // current store details | ||
|
|
@@ -305,6 +314,14 @@ export const CreateUpdateIssueModalBase: React.FC<IssuesModalProps> = observer(( | |
| } | ||
| }; | ||
|
|
||
| const handleMoveIssue = async (payload: Partial<TIssue>) => { | ||
| await handleUpdateIssue(payload).then(() => { | ||
| if (data?.id) { | ||
| moveIssue(workspaceSlug.toString(), data.id, payload as TWorkspaceDraftIssue); | ||
| } | ||
| }); | ||
| }; | ||
|
|
||
| const handleFormChange = (formData: Partial<TIssue> | null) => setChangesMade(formData); | ||
|
|
||
| const handleUpdateUploadedAssetIds = (assetId: string) => setUploadedAssetIds((prev) => [...prev, assetId]); | ||
|
|
@@ -338,6 +355,7 @@ export const CreateUpdateIssueModalBase: React.FC<IssuesModalProps> = observer(( | |
| onCreateMoreToggleChange={handleCreateMoreToggleChange} | ||
| isDraft={isDraft} | ||
| moveToIssue={moveToIssue} | ||
| handleMoveIssue={handleMoveIssue} | ||
|
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. Ensure The Also applies to: 379-379 |
||
| /> | ||
| ) : ( | ||
| <IssueFormRoot | ||
|
|
@@ -358,6 +376,7 @@ export const CreateUpdateIssueModalBase: React.FC<IssuesModalProps> = observer(( | |
| moveToIssue={moveToIssue} | ||
| modalTitle={modalTitle} | ||
| primaryButtonText={primaryButtonText} | ||
| handleMoveIssue={handleMoveIssue} | ||
| /> | ||
| )} | ||
| </ModalCore> | ||
|
|
||
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
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