mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: error handling for user permission while issue drag & drop (#3060)
* filx: gantt chart quick add permission * fix: permission toast on drag & drop issues
This commit is contained in:
parent
bf2c6e36ef
commit
26d37fbd38
@ -4,6 +4,8 @@ import { observer } from "mobx-react-lite";
|
|||||||
import { DragDropContext, DropResult } from "@hello-pangea/dnd";
|
import { DragDropContext, DropResult } from "@hello-pangea/dnd";
|
||||||
// components
|
// components
|
||||||
import { CalendarChart, IssuePeekOverview } from "components/issues";
|
import { CalendarChart, IssuePeekOverview } from "components/issues";
|
||||||
|
// hooks
|
||||||
|
import useToast from "hooks/use-toast";
|
||||||
// types
|
// types
|
||||||
import { IIssue } from "types";
|
import { IIssue } from "types";
|
||||||
import {
|
import {
|
||||||
@ -34,7 +36,7 @@ interface IBaseCalendarRoot {
|
|||||||
[EIssueActions.REMOVE]?: (issue: IIssue) => Promise<void>;
|
[EIssueActions.REMOVE]?: (issue: IIssue) => Promise<void>;
|
||||||
};
|
};
|
||||||
viewId?: string;
|
viewId?: string;
|
||||||
handleDragDrop: (source: any, destination: any, issues: any, issueWithIds: any) => void;
|
handleDragDrop: (source: any, destination: any, issues: any, issueWithIds: any) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const BaseCalendarRoot = observer((props: IBaseCalendarRoot) => {
|
export const BaseCalendarRoot = observer((props: IBaseCalendarRoot) => {
|
||||||
@ -44,12 +46,15 @@ export const BaseCalendarRoot = observer((props: IBaseCalendarRoot) => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspaceSlug, peekIssueId, peekProjectId } = router.query;
|
const { workspaceSlug, peekIssueId, peekProjectId } = router.query;
|
||||||
|
|
||||||
|
// hooks
|
||||||
|
const { setToastAlert } = useToast();
|
||||||
|
|
||||||
const displayFilters = issuesFilterStore.issueFilters?.displayFilters;
|
const displayFilters = issuesFilterStore.issueFilters?.displayFilters;
|
||||||
|
|
||||||
const issues = issueStore.getIssues;
|
const issues = issueStore.getIssues;
|
||||||
const groupedIssueIds = (issueStore.getIssuesIds ?? {}) as IGroupedIssues;
|
const groupedIssueIds = (issueStore.getIssuesIds ?? {}) as IGroupedIssues;
|
||||||
|
|
||||||
const onDragEnd = (result: DropResult) => {
|
const onDragEnd = async (result: DropResult) => {
|
||||||
if (!result) return;
|
if (!result) return;
|
||||||
|
|
||||||
// return if not dropped on the correct place
|
// return if not dropped on the correct place
|
||||||
@ -58,7 +63,15 @@ export const BaseCalendarRoot = observer((props: IBaseCalendarRoot) => {
|
|||||||
// return if dropped on the same date
|
// return if dropped on the same date
|
||||||
if (result.destination.droppableId === result.source.droppableId) return;
|
if (result.destination.droppableId === result.source.droppableId) return;
|
||||||
|
|
||||||
if (handleDragDrop) handleDragDrop(result.source, result.destination, issues, groupedIssueIds);
|
if (handleDragDrop) {
|
||||||
|
await handleDragDrop(result.source, result.destination, issues, groupedIssueIds).catch((err) => {
|
||||||
|
setToastAlert({
|
||||||
|
title: "Error",
|
||||||
|
type: "error",
|
||||||
|
message: err.detail ?? "Failed to perform this action",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleIssues = useCallback(
|
const handleIssues = useCallback(
|
||||||
|
@ -41,9 +41,9 @@ export const CycleCalendarLayout: React.FC = observer(() => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDragDrop = (source: any, destination: any, issues: IIssue[], issueWithIds: any) => {
|
const handleDragDrop = async (source: any, destination: any, issues: IIssue[], issueWithIds: any) => {
|
||||||
if (workspaceSlug && projectId && cycleId)
|
if (workspaceSlug && projectId && cycleId)
|
||||||
handleCalenderDragDrop(
|
await handleCalenderDragDrop(
|
||||||
source,
|
source,
|
||||||
destination,
|
destination,
|
||||||
workspaceSlug.toString(),
|
workspaceSlug.toString(),
|
||||||
|
@ -38,8 +38,8 @@ export const ModuleCalendarLayout: React.FC = observer(() => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDragDrop = (source: any, destination: any, issues: IIssue[], issueWithIds: any) => {
|
const handleDragDrop = async (source: any, destination: any, issues: IIssue[], issueWithIds: any) => {
|
||||||
handleCalenderDragDrop(
|
await handleCalenderDragDrop(
|
||||||
source,
|
source,
|
||||||
destination,
|
destination,
|
||||||
workspaceSlug,
|
workspaceSlug,
|
||||||
|
@ -31,9 +31,9 @@ export const CalendarLayout: React.FC = observer(() => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDragDrop = (source: any, destination: any, issues: IIssue[], issueWithIds: any) => {
|
const handleDragDrop = async (source: any, destination: any, issues: IIssue[], issueWithIds: any) => {
|
||||||
if (workspaceSlug && projectId)
|
if (workspaceSlug && projectId)
|
||||||
handleCalenderDragDrop(
|
await handleCalenderDragDrop(
|
||||||
source,
|
source,
|
||||||
destination,
|
destination,
|
||||||
workspaceSlug.toString(),
|
workspaceSlug.toString(),
|
||||||
|
@ -32,9 +32,9 @@ export const ProjectViewCalendarLayout: React.FC = observer(() => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDragDrop = (source: any, destination: any, issues: IIssue[], issueWithIds: any) => {
|
const handleDragDrop = async (source: any, destination: any, issues: IIssue[], issueWithIds: any) => {
|
||||||
if (workspaceSlug && projectId)
|
if (workspaceSlug && projectId)
|
||||||
handleCalenderDragDrop(
|
await handleCalenderDragDrop(
|
||||||
source,
|
source,
|
||||||
destination,
|
destination,
|
||||||
workspaceSlug.toString(),
|
workspaceSlug.toString(),
|
||||||
|
@ -121,8 +121,9 @@ export const GanttInlineCreateIssueForm: React.FC<Props> = observer((props) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
quickAddCallback && quickAddCallback(workspaceSlug, projectId, payload, viewId);
|
if (quickAddCallback) {
|
||||||
|
await quickAddCallback(workspaceSlug, projectId, payload, viewId);
|
||||||
|
}
|
||||||
setToastAlert({
|
setToastAlert({
|
||||||
type: "success",
|
type: "success",
|
||||||
title: "Success!",
|
title: "Success!",
|
||||||
|
@ -147,7 +147,7 @@ export const BaseKanBanRoot: React.FC<IBaseKanBanLayout> = observer((props: IBas
|
|||||||
setIsDragStarted(true);
|
setIsDragStarted(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onDragEnd = (result: DropResult) => {
|
const onDragEnd = async (result: DropResult) => {
|
||||||
setIsDragStarted(false);
|
setIsDragStarted(false);
|
||||||
|
|
||||||
if (!result) return;
|
if (!result) return;
|
||||||
@ -171,7 +171,15 @@ export const BaseKanBanRoot: React.FC<IBaseKanBanLayout> = observer((props: IBas
|
|||||||
});
|
});
|
||||||
setDeleteIssueModal(true);
|
setDeleteIssueModal(true);
|
||||||
} else {
|
} else {
|
||||||
handleDragDrop(result.source, result.destination, sub_group_by, group_by, issues, issueIds);
|
await handleDragDrop(result.source, result.destination, sub_group_by, group_by, issues, issueIds).catch(
|
||||||
|
(err) => {
|
||||||
|
setToastAlert({
|
||||||
|
title: "Error",
|
||||||
|
type: "error",
|
||||||
|
message: err.detail ?? "Failed to perform this action",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -45,8 +45,8 @@ export class CalendarHelpers implements ICalendarHelpers {
|
|||||||
target_date: destinationColumnId,
|
target_date: destinationColumnId,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (viewId) store?.updateIssue(workspaceSlug, projectId, updateIssue.id, updateIssue, viewId);
|
if (viewId) return await store?.updateIssue(workspaceSlug, projectId, updateIssue.id, updateIssue, viewId);
|
||||||
else store?.updateIssue(workspaceSlug, projectId, updateIssue.id, updateIssue);
|
else return await store?.updateIssue(workspaceSlug, projectId, updateIssue.id, updateIssue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user