mirror of
https://github.com/makeplane/plane.git
synced 2025-12-24 07:39:32 +01:00
[WEB-3859] fix: work item links #6930
This commit is contained in:
committed by
GitHub
parent
24899887b2
commit
a4bca0c39c
@@ -39,11 +39,11 @@ export const IssueDetailWidgetModals: FC<Props> = observer((props) => {
|
||||
createRelation,
|
||||
issueCrudOperationState,
|
||||
setIssueCrudOperationState,
|
||||
} = useIssueDetail();
|
||||
} = useIssueDetail(issueServiceType);
|
||||
|
||||
// helper hooks
|
||||
const subIssueOperations = useSubIssueOperations();
|
||||
const handleLinkOperations = useLinkOperations(workspaceSlug, projectId, issueId);
|
||||
const subIssueOperations = useSubIssueOperations(issueServiceType);
|
||||
const handleLinkOperations = useLinkOperations(workspaceSlug, projectId, issueId, issueServiceType);
|
||||
|
||||
// handlers
|
||||
const handleIssueCrudState = (
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
"use client";
|
||||
import { useMemo } from "react";
|
||||
import { EIssueServiceType } from "@plane/constants";
|
||||
// plane imports
|
||||
import { useTranslation } from "@plane/i18n";
|
||||
import { TIssueLink, TIssueServiceType } from "@plane/types";
|
||||
import { TOAST_TYPE, setToast } from "@plane/ui";
|
||||
// hooks
|
||||
import { useIssueDetail } from "@/hooks/store";
|
||||
// types
|
||||
// local imports
|
||||
import { TLinkOperations } from "../../issue-detail/links";
|
||||
|
||||
export const useLinkOperations = (
|
||||
workspaceSlug: string,
|
||||
projectId: string,
|
||||
issueId: string,
|
||||
issueServiceType: TIssueServiceType = EIssueServiceType.ISSUES
|
||||
issueServiceType: TIssueServiceType
|
||||
): TLinkOperations => {
|
||||
const { createLink, updateLink, removeLink } = useIssueDetail(issueServiceType);
|
||||
// i18n
|
||||
@@ -66,7 +66,7 @@ export const useLinkOperations = (
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: t("links.toasts.removed.title"),
|
||||
});
|
||||
} catch (error) {
|
||||
} catch {
|
||||
setToast({
|
||||
message: t("links.toasts.not_removed.message"),
|
||||
type: TOAST_TYPE.ERROR,
|
||||
@@ -75,7 +75,7 @@ export const useLinkOperations = (
|
||||
}
|
||||
},
|
||||
}),
|
||||
[workspaceSlug, projectId, issueId, createLink, updateLink, removeLink]
|
||||
[workspaceSlug, projectId, issueId, createLink, updateLink, removeLink, t]
|
||||
);
|
||||
|
||||
return handleLinkOperations;
|
||||
|
||||
@@ -20,9 +20,7 @@ export type TRelationIssueOperations = {
|
||||
remove: (workspaceSlug: string, projectId: string, issueId: string) => Promise<void>;
|
||||
};
|
||||
|
||||
export const useSubIssueOperations = (
|
||||
issueServiceType: TIssueServiceType = EIssueServiceType.ISSUES
|
||||
): TSubIssueOperations => {
|
||||
export const useSubIssueOperations = (issueServiceType: TIssueServiceType): TSubIssueOperations => {
|
||||
// router
|
||||
const { epicId: epicIdParam } = useParams();
|
||||
const pathname = usePathname();
|
||||
@@ -32,15 +30,15 @@ export const useSubIssueOperations = (
|
||||
issue: { getIssueById },
|
||||
subIssues: { setSubIssueHelpers },
|
||||
createSubIssues,
|
||||
fetchSubIssues,
|
||||
updateSubIssue,
|
||||
deleteSubIssue,
|
||||
} = useIssueDetail();
|
||||
removeSubIssue,
|
||||
} = useIssueDetail(issueServiceType);
|
||||
const { getStateById } = useProjectState();
|
||||
const { peekIssue: epicPeekIssue } = useIssueDetail(EIssueServiceType.EPICS);
|
||||
// const { updateEpicAnalytics } = useIssueTypes();
|
||||
const { updateAnalytics } = updateEpicAnalytics();
|
||||
const { fetchSubIssues } = useIssueDetail();
|
||||
const { removeSubIssue } = useIssueDetail(issueServiceType);
|
||||
const { captureIssueEvent } = useEventTracker();
|
||||
|
||||
// derived values
|
||||
@@ -66,7 +64,7 @@ export const useSubIssueOperations = (
|
||||
fetchSubIssues: async (workspaceSlug: string, projectId: string, parentIssueId: string) => {
|
||||
try {
|
||||
await fetchSubIssues(workspaceSlug, projectId, parentIssueId);
|
||||
} catch (error) {
|
||||
} catch {
|
||||
setToast({
|
||||
type: TOAST_TYPE.ERROR,
|
||||
title: t("toast.error"),
|
||||
@@ -92,7 +90,7 @@ export const useSubIssueOperations = (
|
||||
: t("issue.label", { count: 2 }),
|
||||
}),
|
||||
});
|
||||
} catch (error) {
|
||||
} catch {
|
||||
setToast({
|
||||
type: TOAST_TYPE.ERROR,
|
||||
title: t("toast.error"),
|
||||
@@ -157,7 +155,7 @@ export const useSubIssueOperations = (
|
||||
message: t("sub_work_item.update.success"),
|
||||
});
|
||||
setSubIssueHelpers(parentIssueId, "issue_loader", issueId);
|
||||
} catch (error) {
|
||||
} catch {
|
||||
captureIssueEvent({
|
||||
eventName: "Sub-issue updated",
|
||||
payload: { ...oldIssue, ...issueData, state: "FAILED", element: "Issue detail page" },
|
||||
@@ -203,7 +201,7 @@ export const useSubIssueOperations = (
|
||||
path: pathname,
|
||||
});
|
||||
setSubIssueHelpers(parentIssueId, "issue_loader", issueId);
|
||||
} catch (error) {
|
||||
} catch {
|
||||
captureIssueEvent({
|
||||
eventName: "Sub-issue removed",
|
||||
payload: { id: issueId, state: "FAILED", element: "Issue detail page" },
|
||||
@@ -231,7 +229,7 @@ export const useSubIssueOperations = (
|
||||
});
|
||||
setSubIssueHelpers(parentIssueId, "issue_loader", issueId);
|
||||
});
|
||||
} catch (error) {
|
||||
} catch {
|
||||
captureIssueEvent({
|
||||
eventName: "Sub-issue removed",
|
||||
payload: { id: issueId, state: "FAILED", element: "Issue detail page" },
|
||||
@@ -245,7 +243,22 @@ export const useSubIssueOperations = (
|
||||
}
|
||||
},
|
||||
}),
|
||||
[fetchSubIssues, createSubIssues, updateSubIssue, removeSubIssue, deleteSubIssue, setSubIssueHelpers]
|
||||
[
|
||||
fetchSubIssues,
|
||||
createSubIssues,
|
||||
epicId,
|
||||
updateSubIssue,
|
||||
removeSubIssue,
|
||||
deleteSubIssue,
|
||||
setSubIssueHelpers,
|
||||
getIssueById,
|
||||
getStateById,
|
||||
updateAnalytics,
|
||||
captureIssueEvent,
|
||||
pathname,
|
||||
t,
|
||||
issueServiceType,
|
||||
]
|
||||
);
|
||||
|
||||
return subIssueOperations;
|
||||
|
||||
Reference in New Issue
Block a user