forked from github/plane
fix: cycle & module mutation , feat: cycle & module toast alerts (#962)
* fix: cycle remove issue mutation * fix: module remove issue mutation * feat: issue removed toast alert added
This commit is contained in:
parent
f0f24b6fc4
commit
0b9b4bb289
@ -17,7 +17,7 @@ type Props = {
|
||||
openIssuesListModal?: (() => void) | null;
|
||||
handleDeleteIssue: (issue: IIssue) => void;
|
||||
handleTrashBox: (isDragging: boolean) => void;
|
||||
removeIssue: ((bridgeId: string) => void) | null;
|
||||
removeIssue: ((bridgeId: string, issueId: string) => void) | null;
|
||||
isCompleted?: boolean;
|
||||
userAuth: UserAuth;
|
||||
};
|
||||
|
@ -29,7 +29,7 @@ type Props = {
|
||||
handleDeleteIssue: (issue: IIssue) => void;
|
||||
openIssuesListModal?: (() => void) | null;
|
||||
handleTrashBox: (isDragging: boolean) => void;
|
||||
removeIssue: ((bridgeId: string) => void) | null;
|
||||
removeIssue: ((bridgeId: string, issueId: string) => void) | null;
|
||||
isCompleted?: boolean;
|
||||
userAuth: UserAuth;
|
||||
};
|
||||
@ -130,7 +130,8 @@ export const SingleBoard: React.FC<Props> = ({
|
||||
handleDeleteIssue={handleDeleteIssue}
|
||||
handleTrashBox={handleTrashBox}
|
||||
removeIssue={() => {
|
||||
if (removeIssue && issue.bridge_id) removeIssue(issue.bridge_id);
|
||||
if (removeIssue && issue.bridge_id)
|
||||
removeIssue(issue.bridge_id, issue.id);
|
||||
}}
|
||||
isCompleted={isCompleted}
|
||||
userAuth={userAuth}
|
||||
|
@ -314,10 +314,26 @@ export const IssuesView: React.FC<Props> = ({
|
||||
);
|
||||
|
||||
const removeIssueFromCycle = useCallback(
|
||||
(bridgeId: string) => {
|
||||
(bridgeId: string, issueId: string) => {
|
||||
if (!workspaceSlug || !projectId || !cycleId) return;
|
||||
|
||||
mutate(CYCLE_ISSUES_WITH_PARAMS(cycleId as string, params));
|
||||
mutate(
|
||||
CYCLE_ISSUES_WITH_PARAMS(cycleId as string, params),
|
||||
(prevData: any) => {
|
||||
if (!prevData) return prevData;
|
||||
if (selectedGroup) {
|
||||
const filteredData: any = {};
|
||||
for (const key in prevData) {
|
||||
filteredData[key] = prevData[key].filter((item: any) => item.id !== issueId);
|
||||
}
|
||||
return filteredData;
|
||||
} else {
|
||||
const filteredData = prevData.filter((i: any) => i.id !== issueId);
|
||||
return filteredData;
|
||||
}
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
issuesService
|
||||
.removeIssueFromCycle(
|
||||
@ -326,6 +342,13 @@ export const IssuesView: React.FC<Props> = ({
|
||||
cycleId as string,
|
||||
bridgeId
|
||||
)
|
||||
.then(() => {
|
||||
setToastAlert({
|
||||
title: "Success",
|
||||
message: "Issue removed successfully.",
|
||||
type: "success",
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
@ -334,10 +357,26 @@ export const IssuesView: React.FC<Props> = ({
|
||||
);
|
||||
|
||||
const removeIssueFromModule = useCallback(
|
||||
(bridgeId: string) => {
|
||||
(bridgeId: string, issueId: string) => {
|
||||
if (!workspaceSlug || !projectId || !moduleId) return;
|
||||
|
||||
mutate(MODULE_ISSUES_WITH_PARAMS(moduleId as string, params));
|
||||
mutate(
|
||||
MODULE_ISSUES_WITH_PARAMS(moduleId as string, params),
|
||||
(prevData: any) => {
|
||||
if (!prevData) return prevData;
|
||||
if (selectedGroup) {
|
||||
const filteredData: any = {};
|
||||
for (const key in prevData) {
|
||||
filteredData[key] = prevData[key].filter((item: any) => item.id !== issueId);
|
||||
}
|
||||
return filteredData;
|
||||
} else {
|
||||
const filteredData = prevData.filter((item: any) => item.id !== issueId);
|
||||
return filteredData;
|
||||
}
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
modulesService
|
||||
.removeIssueFromModule(
|
||||
@ -346,6 +385,13 @@ export const IssuesView: React.FC<Props> = ({
|
||||
moduleId as string,
|
||||
bridgeId
|
||||
)
|
||||
.then(() => {
|
||||
setToastAlert({
|
||||
title: "Success",
|
||||
message: "Issue removed successfully.",
|
||||
type: "success",
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
|
@ -14,7 +14,7 @@ type Props = {
|
||||
handleEditIssue: (issue: IIssue) => void;
|
||||
handleDeleteIssue: (issue: IIssue) => void;
|
||||
openIssuesListModal?: (() => void) | null;
|
||||
removeIssue: ((bridgeId: string) => void) | null;
|
||||
removeIssue: ((bridgeId: string, issueId: string) => void) | null;
|
||||
isCompleted?: boolean;
|
||||
userAuth: UserAuth;
|
||||
};
|
||||
|
@ -37,7 +37,7 @@ type Props = {
|
||||
handleEditIssue: (issue: IIssue) => void;
|
||||
handleDeleteIssue: (issue: IIssue) => void;
|
||||
openIssuesListModal?: (() => void) | null;
|
||||
removeIssue: ((bridgeId: string) => void) | null;
|
||||
removeIssue: ((bridgeId: string, issueId: string) => void) | null;
|
||||
isCompleted?: boolean;
|
||||
userAuth: UserAuth;
|
||||
};
|
||||
@ -204,7 +204,7 @@ export const SingleList: React.FC<Props> = ({
|
||||
makeIssueCopy={() => makeIssueCopy(issue)}
|
||||
handleDeleteIssue={handleDeleteIssue}
|
||||
removeIssue={() => {
|
||||
if (removeIssue !== null && issue.bridge_id) removeIssue(issue.bridge_id);
|
||||
if (removeIssue !== null && issue.bridge_id) removeIssue(issue.bridge_id, issue.id);
|
||||
}}
|
||||
isCompleted={isCompleted}
|
||||
userAuth={userAuth}
|
||||
|
Loading…
Reference in New Issue
Block a user