mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
[WEB-1138] feat: List lssue Layout Drag and Drop (#4536)
* List Dnd Complete feature * fix minor bugs in list dnd * remove double overlay in kanban post refactor * add missing dependencies to useEffects * make provision to add to the last issue of the group * show current child issues to also be disabled if the parent issue is being dragged * fix last issue border * fix code static analysis suggestions * prevent context menu on drag handle
This commit is contained in:
parent
0f5294c5e2
commit
afc2ca65cf
@ -1,19 +1,29 @@
|
|||||||
|
import React from "react";
|
||||||
import { forwardRef } from "react";
|
import { forwardRef } from "react";
|
||||||
import { MoreVertical } from "lucide-react";
|
import { MoreVertical } from "lucide-react";
|
||||||
|
|
||||||
interface IDragHandle {
|
interface IDragHandle {
|
||||||
isDragging: boolean;
|
isDragging: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DragHandle = forwardRef<HTMLButtonElement | null, IDragHandle>((props, ref) => {
|
export const DragHandle = forwardRef<HTMLButtonElement | null, IDragHandle>((props, ref) => {
|
||||||
const { isDragging } = props;
|
const { isDragging, disabled = false } = props;
|
||||||
|
|
||||||
|
if (disabled) {
|
||||||
|
return <div className="w-[14px] h-[18px]" />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`mr-1 flex flex-shrink-0 rounded text-custom-sidebar-text-200 group-hover:opacity-100 cursor-grab ${
|
className={`mr-1 p-[2px] flex flex-shrink-0 rounded bg-custom-background-90 text-custom-sidebar-text-200 group-hover:opacity-100 cursor-grab ${
|
||||||
isDragging ? "opacity-100" : "opacity-0"
|
isDragging ? "opacity-100" : "opacity-0"
|
||||||
}`}
|
}`}
|
||||||
|
onContextMenu={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
}}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
>
|
>
|
||||||
<MoreVertical className="h-3.5 w-3.5 stroke-custom-text-400" />
|
<MoreVertical className="h-3.5 w-3.5 stroke-custom-text-400" />
|
@ -12,4 +12,5 @@ export * from "./tooltip";
|
|||||||
export * from "./loader";
|
export * from "./loader";
|
||||||
export * from "./control-link";
|
export * from "./control-link";
|
||||||
export * from "./toast";
|
export * from "./toast";
|
||||||
|
export * from "./drag-handle";
|
||||||
export * from "./drop-indicator";
|
export * from "./drop-indicator";
|
61
web/components/issues/issue-layouts/group-drag-overlay.tsx
Normal file
61
web/components/issues/issue-layouts/group-drag-overlay.tsx
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
import { AlertCircle } from "lucide-react";
|
||||||
|
import { TIssueOrderByOptions } from "@plane/types";
|
||||||
|
import { ISSUE_ORDER_BY_OPTIONS } from "@/constants/issue";
|
||||||
|
import { cn } from "@/helpers/common.helper";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
dragColumnOrientation: "justify-start" | "justify-center" | "justify-end";
|
||||||
|
canDropOverIssue: boolean;
|
||||||
|
isDropDisabled: boolean;
|
||||||
|
dropErrorMessage?: string;
|
||||||
|
orderBy: TIssueOrderByOptions | undefined;
|
||||||
|
isDraggingOverColumn: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const GroupDragOverlay = (props: Props) => {
|
||||||
|
const { dragColumnOrientation, canDropOverIssue, isDropDisabled, dropErrorMessage, orderBy, isDraggingOverColumn } =
|
||||||
|
props;
|
||||||
|
|
||||||
|
const shouldOverlay = isDraggingOverColumn && (!canDropOverIssue || isDropDisabled);
|
||||||
|
const readableOrderBy = ISSUE_ORDER_BY_OPTIONS.find((orderByObj) => orderByObj.key === orderBy)?.title;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
`absolute top-0 left-0 h-full w-full items-center text-sm font-medium text-custom-text-300 rounded bg-custom-background-overlay ${dragColumnOrientation}`,
|
||||||
|
{
|
||||||
|
"flex flex-col border-[1px] border-custom-border-300 z-[2]": shouldOverlay,
|
||||||
|
},
|
||||||
|
{ hidden: !shouldOverlay }
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"p-3 mt-8 flex flex-col rounded items-center",
|
||||||
|
{
|
||||||
|
"text-custom-text-200": shouldOverlay,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text-custom-text-error": isDropDisabled,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{dropErrorMessage ? (
|
||||||
|
<div className="flex items-center">
|
||||||
|
<AlertCircle width={13} height={13} />
|
||||||
|
<span>{dropErrorMessage}</span>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{readableOrderBy && (
|
||||||
|
<span>
|
||||||
|
The layout is ordered by <span className="font-semibold">{readableOrderBy}</span>.
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
<span>Drop here to move the issue.</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
@ -4,26 +4,24 @@ import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element
|
|||||||
import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
|
import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { TIssue } from "@plane/types";
|
import { Spinner } from "@plane/ui";
|
||||||
import { Spinner, TOAST_TYPE, setToast } from "@plane/ui";
|
|
||||||
import { DeleteIssueModal } from "@/components/issues";
|
import { DeleteIssueModal } from "@/components/issues";
|
||||||
import { ISSUE_DELETED } from "@/constants/event-tracker";
|
import { ISSUE_DELETED } from "@/constants/event-tracker";
|
||||||
import { EIssueFilterType, EIssuesStoreType } from "@/constants/issue";
|
import { EIssueFilterType, EIssuesStoreType } from "@/constants/issue";
|
||||||
import { EUserProjectRoles } from "@/constants/project";
|
import { EUserProjectRoles } from "@/constants/project";
|
||||||
// hooks
|
// hooks
|
||||||
import { useEventTracker, useIssueDetail, useIssues, useKanbanView, useUser } from "@/hooks/store";
|
import { useEventTracker, useIssueDetail, useIssues, useKanbanView, useUser } from "@/hooks/store";
|
||||||
|
import { useGroupIssuesDragNDrop } from "@/hooks/use-group-dragndrop";
|
||||||
import { useIssuesActions } from "@/hooks/use-issues-actions";
|
import { useIssuesActions } from "@/hooks/use-issues-actions";
|
||||||
// store
|
// store
|
||||||
import { ISSUE_FILTER_DEFAULT_DATA } from "@/store/issue/helpers/issue-helper.store";
|
|
||||||
// ui
|
// ui
|
||||||
// types
|
// types
|
||||||
import { IQuickActionProps, TRenderQuickActions } from "../list/list-view-types";
|
import { IQuickActionProps, TRenderQuickActions } from "../list/list-view-types";
|
||||||
//components
|
//components
|
||||||
import { GroupDropLocation, handleGroupDragDrop, getSourceFromDropPayload } from "../utils";
|
import { getSourceFromDropPayload } from "../utils";
|
||||||
import { KanBan } from "./default";
|
import { KanBan } from "./default";
|
||||||
import { KanBanSwimLanes } from "./swimlanes";
|
import { KanBanSwimLanes } from "./swimlanes";
|
||||||
|
|
||||||
|
|
||||||
export type KanbanStoreType =
|
export type KanbanStoreType =
|
||||||
| EIssuesStoreType.PROJECT
|
| EIssuesStoreType.PROJECT
|
||||||
| EIssuesStoreType.MODULE
|
| EIssuesStoreType.MODULE
|
||||||
@ -65,12 +63,6 @@ export const BaseKanBanRoot: React.FC<IBaseKanBanLayout> = observer((props: IBas
|
|||||||
} = useIssueDetail();
|
} = useIssueDetail();
|
||||||
const { updateIssue, removeIssue, removeIssueFromView, archiveIssue, restoreIssue, updateFilters } =
|
const { updateIssue, removeIssue, removeIssueFromView, archiveIssue, restoreIssue, updateFilters } =
|
||||||
useIssuesActions(storeType);
|
useIssuesActions(storeType);
|
||||||
const {
|
|
||||||
issues: { addCycleToIssue, removeCycleFromIssue },
|
|
||||||
} = useIssues(EIssuesStoreType.CYCLE);
|
|
||||||
const {
|
|
||||||
issues: { changeModulesInIssue },
|
|
||||||
} = useIssues(EIssuesStoreType.MODULE);
|
|
||||||
|
|
||||||
const deleteAreaRef = useRef<HTMLDivElement | null>(null);
|
const deleteAreaRef = useRef<HTMLDivElement | null>(null);
|
||||||
const [isDragOverDelete, setIsDragOverDelete] = useState(false);
|
const [isDragOverDelete, setIsDragOverDelete] = useState(false);
|
||||||
@ -101,6 +93,8 @@ export const BaseKanBanRoot: React.FC<IBaseKanBanLayout> = observer((props: IBas
|
|||||||
|
|
||||||
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER;
|
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER;
|
||||||
|
|
||||||
|
const handleOnDrop = useGroupIssuesDragNDrop(storeType, orderBy, group_by, sub_group_by);
|
||||||
|
|
||||||
const canEditProperties = useCallback(
|
const canEditProperties = useCallback(
|
||||||
(projectId: string | undefined) => {
|
(projectId: string | undefined) => {
|
||||||
const isEditingAllowedBasedOnProject =
|
const isEditingAllowedBasedOnProject =
|
||||||
@ -153,86 +147,6 @@ export const BaseKanBanRoot: React.FC<IBaseKanBanLayout> = observer((props: IBas
|
|||||||
);
|
);
|
||||||
}, [deleteAreaRef?.current, setIsDragOverDelete, setDraggedIssueId, setDeleteIssueModal]);
|
}, [deleteAreaRef?.current, setIsDragOverDelete, setDraggedIssueId, setDeleteIssueModal]);
|
||||||
|
|
||||||
/**
|
|
||||||
* update Issue on Drop, checks if modules or cycles are changed and then calls appropriate functions
|
|
||||||
* @param projectId
|
|
||||||
* @param issueId
|
|
||||||
* @param data
|
|
||||||
* @param issueUpdates
|
|
||||||
*/
|
|
||||||
const updateIssueOnDrop = async (
|
|
||||||
projectId: string,
|
|
||||||
issueId: string,
|
|
||||||
data: Partial<TIssue>,
|
|
||||||
issueUpdates: {
|
|
||||||
[groupKey: string]: {
|
|
||||||
ADD: string[];
|
|
||||||
REMOVE: string[];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
) => {
|
|
||||||
|
|
||||||
const errorToastProps = {
|
|
||||||
type: TOAST_TYPE.ERROR,
|
|
||||||
title: "Error!",
|
|
||||||
message: "Error while updating issue"
|
|
||||||
}
|
|
||||||
const moduleKey = ISSUE_FILTER_DEFAULT_DATA["module"];
|
|
||||||
const cycleKey = ISSUE_FILTER_DEFAULT_DATA["cycle"];
|
|
||||||
|
|
||||||
const isModuleChanged = Object.keys(data).includes(moduleKey);
|
|
||||||
const isCycleChanged = Object.keys(data).includes(cycleKey);
|
|
||||||
|
|
||||||
if (isCycleChanged && workspaceSlug) {
|
|
||||||
if(data[cycleKey]) {
|
|
||||||
addCycleToIssue(workspaceSlug.toString(), projectId, data[cycleKey], issueId).catch(() => setToast(errorToastProps));
|
|
||||||
} else {
|
|
||||||
removeCycleFromIssue(workspaceSlug.toString(), projectId, issueId).catch(() => setToast(errorToastProps))
|
|
||||||
}
|
|
||||||
delete data[cycleKey];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isModuleChanged && workspaceSlug && issueUpdates[moduleKey]) {
|
|
||||||
changeModulesInIssue(
|
|
||||||
workspaceSlug.toString(),
|
|
||||||
projectId,
|
|
||||||
issueId,
|
|
||||||
issueUpdates[moduleKey].ADD,
|
|
||||||
issueUpdates[moduleKey].REMOVE
|
|
||||||
).catch(() => setToast(errorToastProps));
|
|
||||||
delete data[moduleKey];
|
|
||||||
}
|
|
||||||
|
|
||||||
updateIssue && updateIssue(projectId, issueId, data).catch(() => setToast(errorToastProps));
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleOnDrop = async (source: GroupDropLocation, destination: GroupDropLocation) => {
|
|
||||||
if (
|
|
||||||
source.columnId &&
|
|
||||||
destination.columnId &&
|
|
||||||
destination.columnId === source.columnId &&
|
|
||||||
destination.id === source.id
|
|
||||||
)
|
|
||||||
return;
|
|
||||||
|
|
||||||
await handleGroupDragDrop(
|
|
||||||
source,
|
|
||||||
destination,
|
|
||||||
getIssueById,
|
|
||||||
issues.getIssueIds,
|
|
||||||
updateIssueOnDrop,
|
|
||||||
group_by,
|
|
||||||
sub_group_by,
|
|
||||||
orderBy !== "sort_order"
|
|
||||||
).catch((err) => {
|
|
||||||
setToast({
|
|
||||||
title: "Error!",
|
|
||||||
type: TOAST_TYPE.ERROR,
|
|
||||||
message: err?.detail ?? "Failed to perform this action",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderQuickActions: TRenderQuickActions = useCallback(
|
const renderQuickActions: TRenderQuickActions = useCallback(
|
||||||
({ issue, parentRef, customActionButton }) => (
|
({ issue, parentRef, customActionButton }) => (
|
||||||
<QuickActions
|
<QuickActions
|
||||||
|
@ -169,7 +169,7 @@ export const KanbanIssueBlock: React.FC<IssueBlockProps> = observer((props) => {
|
|||||||
}),
|
}),
|
||||||
dropTargetForElements({
|
dropTargetForElements({
|
||||||
element,
|
element,
|
||||||
canDrop: () => canDropOverIssue,
|
canDrop: ({ source }) => source?.data?.id !== issue?.id && canDropOverIssue,
|
||||||
getData: () => ({ id: issue?.id, type: "ISSUE" }),
|
getData: () => ({ id: issue?.id, type: "ISSUE" }),
|
||||||
onDragEnter: () => {
|
onDragEnter: () => {
|
||||||
setIsDraggingOverBlock(true);
|
setIsDraggingOverBlock(true);
|
||||||
@ -182,7 +182,7 @@ export const KanbanIssueBlock: React.FC<IssueBlockProps> = observer((props) => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}, [cardRef?.current, issue?.id, setIsCurrentBlockDragging, setIsDraggingOverBlock]);
|
}, [cardRef?.current, issue?.id, isDragAllowed, canDropOverIssue, setIsCurrentBlockDragging, setIsDraggingOverBlock]);
|
||||||
|
|
||||||
if (!issue) return null;
|
if (!issue) return null;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import { MutableRefObject, useEffect, useRef, useState } from "react";
|
|||||||
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
||||||
import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
||||||
import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
|
import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
|
||||||
import { AlertCircle } from "lucide-react";
|
import { observer } from "mobx-react";
|
||||||
//types
|
//types
|
||||||
import {
|
import {
|
||||||
TGroupedIssues,
|
TGroupedIssues,
|
||||||
@ -14,13 +14,14 @@ import {
|
|||||||
TIssueGroupByOptions,
|
TIssueGroupByOptions,
|
||||||
TIssueOrderByOptions,
|
TIssueOrderByOptions,
|
||||||
} from "@plane/types";
|
} from "@plane/types";
|
||||||
|
import { TOAST_TYPE, setToast } from "@plane/ui";
|
||||||
import { highlightIssueOnDrop } from "@/components/issues/issue-layouts/utils";
|
import { highlightIssueOnDrop } from "@/components/issues/issue-layouts/utils";
|
||||||
import { ISSUE_ORDER_BY_OPTIONS } from "@/constants/issue";
|
|
||||||
// helpers
|
// helpers
|
||||||
import { cn } from "@/helpers/common.helper";
|
import { cn } from "@/helpers/common.helper";
|
||||||
// hooks
|
// hooks
|
||||||
import { useProjectState } from "@/hooks/store";
|
import { useProjectState } from "@/hooks/store";
|
||||||
//components
|
//components
|
||||||
|
import { GroupDragOverlay } from "../group-drag-overlay";
|
||||||
import { TRenderQuickActions } from "../list/list-view-types";
|
import { TRenderQuickActions } from "../list/list-view-types";
|
||||||
import { GroupDropLocation, getSourceFromDropPayload, getDestinationFromDropPayload, getIssueBlockId } from "../utils";
|
import { GroupDropLocation, getSourceFromDropPayload, getDestinationFromDropPayload, getIssueBlockId } from "../utils";
|
||||||
import { KanbanIssueBlocksList, KanBanQuickAddIssueForm } from ".";
|
import { KanbanIssueBlocksList, KanBanQuickAddIssueForm } from ".";
|
||||||
@ -54,7 +55,7 @@ interface IKanbanGroup {
|
|||||||
orderBy: TIssueOrderByOptions | undefined;
|
orderBy: TIssueOrderByOptions | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const KanbanGroup = (props: IKanbanGroup) => {
|
export const KanbanGroup = observer((props: IKanbanGroup) => {
|
||||||
const {
|
const {
|
||||||
groupId,
|
groupId,
|
||||||
sub_group_id,
|
sub_group_id,
|
||||||
@ -108,7 +109,17 @@ export const KanbanGroup = (props: IKanbanGroup) => {
|
|||||||
const source = getSourceFromDropPayload(payload);
|
const source = getSourceFromDropPayload(payload);
|
||||||
const destination = getDestinationFromDropPayload(payload);
|
const destination = getDestinationFromDropPayload(payload);
|
||||||
|
|
||||||
if (!source || !destination || isDropDisabled) return;
|
if (!source || !destination) return;
|
||||||
|
|
||||||
|
if (isDropDisabled) {
|
||||||
|
dropErrorMessage &&
|
||||||
|
setToast({
|
||||||
|
type: TOAST_TYPE.WARNING,
|
||||||
|
title: "Warning!",
|
||||||
|
message: dropErrorMessage,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
handleOnDrop(source, destination);
|
handleOnDrop(source, destination);
|
||||||
|
|
||||||
@ -122,7 +133,7 @@ export const KanbanGroup = (props: IKanbanGroup) => {
|
|||||||
element,
|
element,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}, [columnRef?.current, groupId, sub_group_id, setIsDraggingOverColumn, orderBy, isDropDisabled, handleOnDrop]);
|
}, [columnRef, groupId, sub_group_id, setIsDraggingOverColumn, orderBy, isDropDisabled, dropErrorMessage, handleOnDrop]);
|
||||||
|
|
||||||
const prePopulateQuickAddData = (
|
const prePopulateQuickAddData = (
|
||||||
groupByKey: string | undefined,
|
groupByKey: string | undefined,
|
||||||
@ -178,7 +189,6 @@ export const KanbanGroup = (props: IKanbanGroup) => {
|
|||||||
|
|
||||||
const canDropOverIssue = orderBy === "sort_order";
|
const canDropOverIssue = orderBy === "sort_order";
|
||||||
const shouldOverlay = isDraggingOverColumn && (!canDropOverIssue || isDropDisabled);
|
const shouldOverlay = isDraggingOverColumn && (!canDropOverIssue || isDropDisabled);
|
||||||
const readableOrderBy = ISSUE_ORDER_BY_OPTIONS.find((orderByObj) => orderByObj.key === orderBy)?.title;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -190,45 +200,14 @@ export const KanbanGroup = (props: IKanbanGroup) => {
|
|||||||
)}
|
)}
|
||||||
ref={columnRef}
|
ref={columnRef}
|
||||||
>
|
>
|
||||||
<div
|
<GroupDragOverlay
|
||||||
//column overlay when issues are not sorted by manual
|
dragColumnOrientation={sub_group_by ? "justify-start": "justify-center" }
|
||||||
className={cn(
|
canDropOverIssue={canDropOverIssue}
|
||||||
"absolute top-0 left-0 h-full w-full items-center text-sm font-medium text-custom-text-300 rounded bg-custom-background-overlay",
|
isDropDisabled={isDropDisabled}
|
||||||
{
|
dropErrorMessage={dropErrorMessage}
|
||||||
"flex flex-col border-[1px] border-custom-border-300 z-[2]": shouldOverlay,
|
orderBy={orderBy}
|
||||||
},
|
isDraggingOverColumn={isDraggingOverColumn}
|
||||||
{ hidden: !shouldOverlay },
|
/>
|
||||||
{ "justify-center": !sub_group_by }
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
"p-3 mt-8 flex flex-col rounded items-center",
|
|
||||||
{
|
|
||||||
"text-custom-text-200": shouldOverlay,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"text-custom-text-error": isDropDisabled,
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{dropErrorMessage ? (
|
|
||||||
<div className="flex items-center">
|
|
||||||
<AlertCircle width={13} height={13} />
|
|
||||||
<span>{dropErrorMessage}</span>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{readableOrderBy && (
|
|
||||||
<span>
|
|
||||||
The layout is ordered by <span className="font-semibold">{readableOrderBy}</span>.
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
<span>Drop here to move the issue.</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<KanbanIssueBlocksList
|
<KanbanIssueBlocksList
|
||||||
sub_group_id={sub_group_id}
|
sub_group_id={sub_group_id}
|
||||||
groupId={groupId}
|
groupId={groupId}
|
||||||
@ -259,4 +238,4 @@ export const KanbanGroup = (props: IKanbanGroup) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
@ -4,7 +4,7 @@ import { observer } from "mobx-react-lite";
|
|||||||
import { EIssuesStoreType } from "@/constants/issue";
|
import { EIssuesStoreType } from "@/constants/issue";
|
||||||
import { EUserProjectRoles } from "@/constants/project";
|
import { EUserProjectRoles } from "@/constants/project";
|
||||||
import { useIssues, useUser } from "@/hooks/store";
|
import { useIssues, useUser } from "@/hooks/store";
|
||||||
|
import { useGroupIssuesDragNDrop } from "@/hooks/use-group-dragndrop";
|
||||||
import { useIssuesActions } from "@/hooks/use-issues-actions";
|
import { useIssuesActions } from "@/hooks/use-issues-actions";
|
||||||
// components
|
// components
|
||||||
import { List } from "./default";
|
import { List } from "./default";
|
||||||
@ -17,9 +17,9 @@ type ListStoreType =
|
|||||||
| EIssuesStoreType.MODULE
|
| EIssuesStoreType.MODULE
|
||||||
| EIssuesStoreType.CYCLE
|
| EIssuesStoreType.CYCLE
|
||||||
| EIssuesStoreType.PROJECT_VIEW
|
| EIssuesStoreType.PROJECT_VIEW
|
||||||
| EIssuesStoreType.ARCHIVED
|
|
||||||
| EIssuesStoreType.DRAFT
|
| EIssuesStoreType.DRAFT
|
||||||
| EIssuesStoreType.PROFILE;
|
| EIssuesStoreType.PROFILE
|
||||||
|
| EIssuesStoreType.ARCHIVED;
|
||||||
interface IBaseListRoot {
|
interface IBaseListRoot {
|
||||||
QuickActions: FC<IQuickActionProps>;
|
QuickActions: FC<IQuickActionProps>;
|
||||||
viewId?: string;
|
viewId?: string;
|
||||||
@ -37,7 +37,8 @@ export const BaseListRoot = observer((props: IBaseListRoot) => {
|
|||||||
canEditPropertiesBasedOnProject,
|
canEditPropertiesBasedOnProject,
|
||||||
isCompletedCycle = false,
|
isCompletedCycle = false,
|
||||||
} = props;
|
} = props;
|
||||||
|
// router
|
||||||
|
//stores
|
||||||
const { issuesFilter, issues } = useIssues(storeType);
|
const { issuesFilter, issues } = useIssues(storeType);
|
||||||
const { updateIssue, removeIssue, removeIssueFromView, archiveIssue, restoreIssue } = useIssuesActions(storeType);
|
const { updateIssue, removeIssue, removeIssueFromView, archiveIssue, restoreIssue } = useIssuesActions(storeType);
|
||||||
// mobx store
|
// mobx store
|
||||||
@ -66,8 +67,11 @@ export const BaseListRoot = observer((props: IBaseListRoot) => {
|
|||||||
const displayProperties = issuesFilter?.issueFilters?.displayProperties;
|
const displayProperties = issuesFilter?.issueFilters?.displayProperties;
|
||||||
|
|
||||||
const group_by = displayFilters?.group_by || null;
|
const group_by = displayFilters?.group_by || null;
|
||||||
|
const orderBy = displayFilters?.order_by || undefined;
|
||||||
const showEmptyGroup = displayFilters?.show_empty_groups ?? false;
|
const showEmptyGroup = displayFilters?.show_empty_groups ?? false;
|
||||||
|
|
||||||
|
const handleOnDrop = useGroupIssuesDragNDrop(storeType, orderBy, group_by);
|
||||||
|
|
||||||
const renderQuickActions: TRenderQuickActions = useCallback(
|
const renderQuickActions: TRenderQuickActions = useCallback(
|
||||||
({ issue, parentRef }) => (
|
({ issue, parentRef }) => (
|
||||||
<QuickActions
|
<QuickActions
|
||||||
@ -91,6 +95,7 @@ export const BaseListRoot = observer((props: IBaseListRoot) => {
|
|||||||
issuesMap={issueMap}
|
issuesMap={issueMap}
|
||||||
displayProperties={displayProperties}
|
displayProperties={displayProperties}
|
||||||
group_by={group_by}
|
group_by={group_by}
|
||||||
|
orderBy={orderBy}
|
||||||
updateIssue={updateIssue}
|
updateIssue={updateIssue}
|
||||||
quickActions={renderQuickActions}
|
quickActions={renderQuickActions}
|
||||||
issueIds={issueIds}
|
issueIds={issueIds}
|
||||||
@ -103,6 +108,7 @@ export const BaseListRoot = observer((props: IBaseListRoot) => {
|
|||||||
storeType={storeType}
|
storeType={storeType}
|
||||||
addIssuesToView={addIssuesToView}
|
addIssuesToView={addIssuesToView}
|
||||||
isCompletedCycle={isCompletedCycle}
|
isCompletedCycle={isCompletedCycle}
|
||||||
|
handleOnDrop={handleOnDrop}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
import React, { FC, MutableRefObject, useState } from "react";
|
import React, { FC, MutableRefObject, useEffect, useRef, useState } from "react";
|
||||||
|
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
||||||
|
import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
||||||
|
import { attachInstruction, extractInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { IIssueDisplayProperties, TIssue, TIssueMap } from "@plane/types";
|
import { IIssueDisplayProperties, TIssue, TIssueMap } from "@plane/types";
|
||||||
// components
|
// components
|
||||||
|
import { DropIndicator } from "@plane/ui";
|
||||||
import RenderIfVisible from "@/components/core/render-if-visible-HOC";
|
import RenderIfVisible from "@/components/core/render-if-visible-HOC";
|
||||||
import { IssueBlock } from "@/components/issues/issue-layouts/list";
|
import { IssueBlock } from "@/components/issues/issue-layouts/list";
|
||||||
// hooks
|
// hooks
|
||||||
import { useIssueDetail } from "@/hooks/store";
|
import { useIssueDetail } from "@/hooks/store";
|
||||||
|
import useOutsideClickDetector from "@/hooks/use-outside-click-detector";
|
||||||
// types
|
// types
|
||||||
|
import { HIGHLIGHT_CLASS, getIssueBlockId } from "../utils";
|
||||||
import { TRenderQuickActions } from "./list-view-types";
|
import { TRenderQuickActions } from "./list-view-types";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@ -20,6 +26,11 @@ type Props = {
|
|||||||
nestingLevel: number;
|
nestingLevel: number;
|
||||||
spacingLeft?: number;
|
spacingLeft?: number;
|
||||||
containerRef: MutableRefObject<HTMLDivElement | null>;
|
containerRef: MutableRefObject<HTMLDivElement | null>;
|
||||||
|
groupId: string;
|
||||||
|
isDragAllowed: boolean;
|
||||||
|
canDropOverIssue: boolean;
|
||||||
|
isParentIssueBeingDragged?: boolean;
|
||||||
|
isLastChild?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const IssueBlockRoot: FC<Props> = observer((props) => {
|
export const IssueBlockRoot: FC<Props> = observer((props) => {
|
||||||
@ -27,6 +38,7 @@ export const IssueBlockRoot: FC<Props> = observer((props) => {
|
|||||||
issueIds,
|
issueIds,
|
||||||
issueId,
|
issueId,
|
||||||
issuesMap,
|
issuesMap,
|
||||||
|
groupId,
|
||||||
updateIssue,
|
updateIssue,
|
||||||
quickActions,
|
quickActions,
|
||||||
canEditProperties,
|
canEditProperties,
|
||||||
@ -34,26 +46,84 @@ export const IssueBlockRoot: FC<Props> = observer((props) => {
|
|||||||
nestingLevel,
|
nestingLevel,
|
||||||
spacingLeft = 14,
|
spacingLeft = 14,
|
||||||
containerRef,
|
containerRef,
|
||||||
|
isDragAllowed,
|
||||||
|
canDropOverIssue,
|
||||||
|
isParentIssueBeingDragged = false,
|
||||||
|
isLastChild = false,
|
||||||
} = props;
|
} = props;
|
||||||
// states
|
// states
|
||||||
const [isExpanded, setExpanded] = useState<boolean>(false);
|
const [isExpanded, setExpanded] = useState<boolean>(false);
|
||||||
|
const [instruction, setInstruction] = useState<"DRAG_OVER" | "DRAG_BELOW" | undefined>(undefined);
|
||||||
|
const [isCurrentBlockDragging, setIsCurrentBlockDragging] = useState(false);
|
||||||
|
// ref
|
||||||
|
const issueBlockRef = useRef<HTMLDivElement | null>(null);
|
||||||
// store hooks
|
// store hooks
|
||||||
const { subIssues: subIssuesStore } = useIssueDetail();
|
const { subIssues: subIssuesStore } = useIssueDetail();
|
||||||
|
|
||||||
|
const isSubIssue = nestingLevel !== 0;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const blockElement = issueBlockRef.current;
|
||||||
|
|
||||||
|
if (!blockElement) return;
|
||||||
|
|
||||||
|
return combine(
|
||||||
|
dropTargetForElements({
|
||||||
|
element: blockElement,
|
||||||
|
canDrop: ({ source }) => source?.data?.id !== issueId && !isSubIssue && canDropOverIssue,
|
||||||
|
getData: ({ input, element }) => {
|
||||||
|
const data = { id: issueId, type: "ISSUE" };
|
||||||
|
|
||||||
|
// attach instruction for last in list
|
||||||
|
return attachInstruction(data, {
|
||||||
|
input,
|
||||||
|
element,
|
||||||
|
currentLevel: 0,
|
||||||
|
indentPerLevel: 0,
|
||||||
|
mode: isLastChild ? "last-in-group" : "standard",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onDrag: ({ self }) => {
|
||||||
|
const extractedInstruction = extractInstruction(self?.data)?.type;
|
||||||
|
// check if the highlight is to be shown above or below
|
||||||
|
setInstruction(
|
||||||
|
extractedInstruction
|
||||||
|
? extractedInstruction === "reorder-below" && isLastChild
|
||||||
|
? "DRAG_BELOW"
|
||||||
|
: "DRAG_OVER"
|
||||||
|
: undefined
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onDragLeave: () => {
|
||||||
|
setInstruction(undefined);
|
||||||
|
},
|
||||||
|
onDrop: () => {
|
||||||
|
setInstruction(undefined);
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}, [issueId, isLastChild, issueBlockRef, isSubIssue, canDropOverIssue, setInstruction]);
|
||||||
|
|
||||||
|
useOutsideClickDetector(issueBlockRef, () => {
|
||||||
|
issueBlockRef?.current?.classList?.remove(HIGHLIGHT_CLASS);
|
||||||
|
});
|
||||||
|
|
||||||
if (!issueId) return null;
|
if (!issueId) return null;
|
||||||
|
|
||||||
const subIssues = subIssuesStore.subIssuesByIssueId(issueId);
|
const subIssues = subIssuesStore.subIssuesByIssueId(issueId);
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="relative" ref={issueBlockRef} id={getIssueBlockId(issueId, groupId)}>
|
||||||
|
<DropIndicator classNames={"absolute top-0 z-[2]"} isVisible={instruction === "DRAG_OVER"} />
|
||||||
<RenderIfVisible
|
<RenderIfVisible
|
||||||
key={`${issueId}`}
|
key={`${issueId}`}
|
||||||
defaultHeight="3rem"
|
defaultHeight="3rem"
|
||||||
root={containerRef}
|
root={containerRef}
|
||||||
classNames="relative border-b border-b-custom-border-200 last:border-b-transparent"
|
classNames={`relative ${isLastChild ? "" : "border-b border-b-custom-border-200"}`}
|
||||||
>
|
>
|
||||||
<IssueBlock
|
<IssueBlock
|
||||||
issueId={issueId}
|
issueId={issueId}
|
||||||
issuesMap={issuesMap}
|
issuesMap={issuesMap}
|
||||||
|
groupId={groupId}
|
||||||
updateIssue={updateIssue}
|
updateIssue={updateIssue}
|
||||||
quickActions={quickActions}
|
quickActions={quickActions}
|
||||||
canEditProperties={canEditProperties}
|
canEditProperties={canEditProperties}
|
||||||
@ -62,6 +132,9 @@ export const IssueBlockRoot: FC<Props> = observer((props) => {
|
|||||||
setExpanded={setExpanded}
|
setExpanded={setExpanded}
|
||||||
nestingLevel={nestingLevel}
|
nestingLevel={nestingLevel}
|
||||||
spacingLeft={spacingLeft}
|
spacingLeft={spacingLeft}
|
||||||
|
canDrag={!isSubIssue && isDragAllowed}
|
||||||
|
isCurrentBlockDragging={isParentIssueBeingDragged || isCurrentBlockDragging}
|
||||||
|
setIsCurrentBlockDragging={setIsCurrentBlockDragging}
|
||||||
/>
|
/>
|
||||||
</RenderIfVisible>
|
</RenderIfVisible>
|
||||||
|
|
||||||
@ -81,8 +154,13 @@ export const IssueBlockRoot: FC<Props> = observer((props) => {
|
|||||||
nestingLevel={nestingLevel + 1}
|
nestingLevel={nestingLevel + 1}
|
||||||
spacingLeft={spacingLeft + (displayProperties?.key ? 12 : 0)}
|
spacingLeft={spacingLeft + (displayProperties?.key ? 12 : 0)}
|
||||||
containerRef={containerRef}
|
containerRef={containerRef}
|
||||||
|
groupId={groupId}
|
||||||
|
isDragAllowed={isDragAllowed}
|
||||||
|
canDropOverIssue={canDropOverIssue}
|
||||||
|
isParentIssueBeingDragged={isParentIssueBeingDragged || isCurrentBlockDragging}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</>
|
{isLastChild && <DropIndicator classNames={"absolute z-[2]"} isVisible={instruction === "DRAG_BELOW"} />}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import { Dispatch, MouseEvent, SetStateAction, useRef } from "react";
|
import { Dispatch, MouseEvent, SetStateAction, useEffect, useRef } from "react";
|
||||||
|
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
||||||
|
import { draggable } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { ChevronRight } from "lucide-react";
|
import { ChevronRight } from "lucide-react";
|
||||||
// types
|
// types
|
||||||
import { TIssue, IIssueDisplayProperties, TIssueMap } from "@plane/types";
|
import { TIssue, IIssueDisplayProperties, TIssueMap } from "@plane/types";
|
||||||
// ui
|
// ui
|
||||||
import { Spinner, Tooltip, ControlLink } from "@plane/ui";
|
import { Spinner, Tooltip, ControlLink, DragHandle } from "@plane/ui";
|
||||||
// components
|
// components
|
||||||
import { IssueProperties } from "@/components/issues/issue-layouts/properties";
|
import { IssueProperties } from "@/components/issues/issue-layouts/properties";
|
||||||
// helpers
|
// helpers
|
||||||
@ -18,6 +20,7 @@ import { TRenderQuickActions } from "./list-view-types";
|
|||||||
interface IssueBlockProps {
|
interface IssueBlockProps {
|
||||||
issueId: string;
|
issueId: string;
|
||||||
issuesMap: TIssueMap;
|
issuesMap: TIssueMap;
|
||||||
|
groupId: string;
|
||||||
updateIssue: ((projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>) | undefined;
|
updateIssue: ((projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>) | undefined;
|
||||||
quickActions: TRenderQuickActions;
|
quickActions: TRenderQuickActions;
|
||||||
displayProperties: IIssueDisplayProperties | undefined;
|
displayProperties: IIssueDisplayProperties | undefined;
|
||||||
@ -26,12 +29,16 @@ interface IssueBlockProps {
|
|||||||
spacingLeft?: number;
|
spacingLeft?: number;
|
||||||
isExpanded: boolean;
|
isExpanded: boolean;
|
||||||
setExpanded: Dispatch<SetStateAction<boolean>>;
|
setExpanded: Dispatch<SetStateAction<boolean>>;
|
||||||
|
isCurrentBlockDragging: boolean;
|
||||||
|
setIsCurrentBlockDragging: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
|
canDrag: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IssueBlock: React.FC<IssueBlockProps> = observer((props: IssueBlockProps) => {
|
export const IssueBlock = observer((props: IssueBlockProps) => {
|
||||||
const {
|
const {
|
||||||
issuesMap,
|
issuesMap,
|
||||||
issueId,
|
issueId,
|
||||||
|
groupId,
|
||||||
updateIssue,
|
updateIssue,
|
||||||
quickActions,
|
quickActions,
|
||||||
displayProperties,
|
displayProperties,
|
||||||
@ -40,9 +47,13 @@ export const IssueBlock: React.FC<IssueBlockProps> = observer((props: IssueBlock
|
|||||||
spacingLeft = 14,
|
spacingLeft = 14,
|
||||||
isExpanded,
|
isExpanded,
|
||||||
setExpanded,
|
setExpanded,
|
||||||
|
isCurrentBlockDragging,
|
||||||
|
setIsCurrentBlockDragging,
|
||||||
|
canDrag,
|
||||||
} = props;
|
} = props;
|
||||||
// refs
|
// ref
|
||||||
const parentRef = useRef(null);
|
const issueRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const dragHandleRef = useRef(null);
|
||||||
// hooks
|
// hooks
|
||||||
const { workspaceSlug } = useAppRouter();
|
const { workspaceSlug } = useAppRouter();
|
||||||
const { getProjectIdentifierById } = useProject();
|
const { getProjectIdentifierById } = useProject();
|
||||||
@ -59,6 +70,29 @@ export const IssueBlock: React.FC<IssueBlockProps> = observer((props: IssueBlock
|
|||||||
const issue = issuesMap[issueId];
|
const issue = issuesMap[issueId];
|
||||||
const subIssues = subIssuesStore.subIssuesByIssueId(issueId);
|
const subIssues = subIssuesStore.subIssuesByIssueId(issueId);
|
||||||
const { isMobile } = usePlatformOS();
|
const { isMobile } = usePlatformOS();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const element = issueRef.current;
|
||||||
|
const dragHandleElement = dragHandleRef.current;
|
||||||
|
|
||||||
|
if (!element || !dragHandleElement) return;
|
||||||
|
|
||||||
|
return combine(
|
||||||
|
draggable({
|
||||||
|
element,
|
||||||
|
dragHandle: dragHandleElement,
|
||||||
|
canDrag: () => canDrag,
|
||||||
|
getInitialData: () => ({ id: issueId, type: "ISSUE", groupId }),
|
||||||
|
onDragStart: () => {
|
||||||
|
setIsCurrentBlockDragging(true);
|
||||||
|
},
|
||||||
|
onDrop: () => {
|
||||||
|
setIsCurrentBlockDragging(false);
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}, [issueRef?.current, canDrag, issueId, groupId, dragHandleRef?.current, setIsCurrentBlockDragging]);
|
||||||
|
|
||||||
if (!issue) return null;
|
if (!issue) return null;
|
||||||
|
|
||||||
const canEditIssueProperties = canEditProperties(issue.project_id);
|
const canEditIssueProperties = canEditProperties(issue.project_id);
|
||||||
@ -84,13 +118,14 @@ export const IssueBlock: React.FC<IssueBlockProps> = observer((props: IssueBlock
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={parentRef}
|
ref={issueRef}
|
||||||
className={cn(
|
className={cn(
|
||||||
"min-h-11 relative flex flex-col md:flex-row md:items-center gap-3 bg-custom-background-100 p-3 pl-1.5 text-sm",
|
"group min-h-11 relative flex flex-col md:flex-row md:items-center gap-3 bg-custom-background-100 p-3 text-sm",
|
||||||
{
|
{
|
||||||
"border border-custom-primary-70 hover:border-custom-primary-70":
|
"border border-custom-primary-70 hover:border-custom-primary-70":
|
||||||
getIsIssuePeeked(issue.id) && peekIssue?.nestingLevel === nestingLevel,
|
getIsIssuePeeked(issue.id) && peekIssue?.nestingLevel === nestingLevel,
|
||||||
"last:border-b-transparent": !getIsIssuePeeked(issue.id),
|
"last:border-b-transparent": !getIsIssuePeeked(issue.id),
|
||||||
|
"bg-custom-background-80": isCurrentBlockDragging,
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@ -98,11 +133,11 @@ export const IssueBlock: React.FC<IssueBlockProps> = observer((props: IssueBlock
|
|||||||
<div className="flex flex-grow items-center gap-3 truncate">
|
<div className="flex flex-grow items-center gap-3 truncate">
|
||||||
<div className="flex items-center gap-0.5">
|
<div className="flex items-center gap-0.5">
|
||||||
<div className="flex items-center group">
|
<div className="flex items-center group">
|
||||||
<span className="size-3.5" />
|
<DragHandle isDragging={isCurrentBlockDragging} ref={dragHandleRef} disabled={!canDrag} />
|
||||||
<div className="flex h-4 w-4 items-center justify-center">
|
<div className="flex h-5 w-5 items-center justify-center">
|
||||||
{subIssuesCount > 0 && (
|
{subIssuesCount > 0 && (
|
||||||
<button
|
<button
|
||||||
className="flex items-center justify-center h-4 w-4 cursor-pointer rounded-sm text-custom-text-400 hover:text-custom-text-300"
|
className="flex items-center justify-center h-5 w-5 cursor-pointer rounded-sm text-custom-text-400 hover:text-custom-text-300"
|
||||||
onClick={handleToggleExpand}
|
onClick={handleToggleExpand}
|
||||||
>
|
>
|
||||||
<ChevronRight className={`h-4 w-4 ${isExpanded ? "rotate-90" : ""}`} />
|
<ChevronRight className={`h-4 w-4 ${isExpanded ? "rotate-90" : ""}`} />
|
||||||
@ -146,7 +181,7 @@ export const IssueBlock: React.FC<IssueBlockProps> = observer((props: IssueBlock
|
|||||||
<div className="block md:hidden border border-custom-border-300 rounded ">
|
<div className="block md:hidden border border-custom-border-300 rounded ">
|
||||||
{quickActions({
|
{quickActions({
|
||||||
issue,
|
issue,
|
||||||
parentRef,
|
parentRef: issueRef,
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -165,7 +200,7 @@ export const IssueBlock: React.FC<IssueBlockProps> = observer((props: IssueBlock
|
|||||||
<div className="hidden md:block">
|
<div className="hidden md:block">
|
||||||
{quickActions({
|
{quickActions({
|
||||||
issue,
|
issue,
|
||||||
parentRef,
|
parentRef: issueRef,
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
@ -1,27 +1,42 @@
|
|||||||
import { FC, MutableRefObject } from "react";
|
import { FC, MutableRefObject } from "react";
|
||||||
// components
|
// components
|
||||||
import { TGroupedIssues, TIssue, IIssueDisplayProperties, TIssueMap, TUnGroupedIssues } from "@plane/types";
|
import { TIssue, IIssueDisplayProperties, TIssueMap, TUnGroupedIssues } from "@plane/types";
|
||||||
import { IssueBlockRoot } from "@/components/issues/issue-layouts/list";
|
import { IssueBlockRoot } from "@/components/issues/issue-layouts/list";
|
||||||
// types
|
// types
|
||||||
import { TRenderQuickActions } from "./list-view-types";
|
import { TRenderQuickActions } from "./list-view-types";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
issueIds: TGroupedIssues | TUnGroupedIssues | any;
|
issueIds: TUnGroupedIssues;
|
||||||
issuesMap: TIssueMap;
|
issuesMap: TIssueMap;
|
||||||
|
groupId: string;
|
||||||
canEditProperties: (projectId: string | undefined) => boolean;
|
canEditProperties: (projectId: string | undefined) => boolean;
|
||||||
updateIssue: ((projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>) | undefined;
|
updateIssue: ((projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>) | undefined;
|
||||||
quickActions: TRenderQuickActions;
|
quickActions: TRenderQuickActions;
|
||||||
displayProperties: IIssueDisplayProperties | undefined;
|
displayProperties: IIssueDisplayProperties | undefined;
|
||||||
containerRef: MutableRefObject<HTMLDivElement | null>;
|
containerRef: MutableRefObject<HTMLDivElement | null>;
|
||||||
|
isDragAllowed: boolean;
|
||||||
|
canDropOverIssue: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IssueBlocksList: FC<Props> = (props) => {
|
export const IssueBlocksList: FC<Props> = (props) => {
|
||||||
const { issueIds, issuesMap, updateIssue, quickActions, displayProperties, canEditProperties, containerRef } = props;
|
const {
|
||||||
|
issueIds,
|
||||||
|
issuesMap,
|
||||||
|
groupId,
|
||||||
|
updateIssue,
|
||||||
|
quickActions,
|
||||||
|
displayProperties,
|
||||||
|
canEditProperties,
|
||||||
|
containerRef,
|
||||||
|
isDragAllowed,
|
||||||
|
canDropOverIssue,
|
||||||
|
} = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative h-full w-full">
|
<div className="relative h-full w-full">
|
||||||
{issueIds && issueIds.length > 0 ? (
|
{issueIds &&
|
||||||
issueIds.map((issueId: string) => (
|
issueIds.length > 0 &&
|
||||||
|
issueIds.map((issueId: string, index) => (
|
||||||
<IssueBlockRoot
|
<IssueBlockRoot
|
||||||
key={`${issueId}`}
|
key={`${issueId}`}
|
||||||
issueIds={issueIds}
|
issueIds={issueIds}
|
||||||
@ -34,11 +49,12 @@ export const IssueBlocksList: FC<Props> = (props) => {
|
|||||||
nestingLevel={0}
|
nestingLevel={0}
|
||||||
spacingLeft={0}
|
spacingLeft={0}
|
||||||
containerRef={containerRef}
|
containerRef={containerRef}
|
||||||
|
groupId={groupId}
|
||||||
|
isLastChild={index === issueIds.length - 1}
|
||||||
|
isDragAllowed={isDragAllowed}
|
||||||
|
canDropOverIssue={canDropOverIssue}
|
||||||
/>
|
/>
|
||||||
))
|
))}
|
||||||
) : (
|
|
||||||
<div className="bg-custom-background-100 p-3 text-sm text-custom-text-400">No issues</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import { useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
|
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
||||||
|
import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
|
||||||
// components
|
// components
|
||||||
import {
|
import {
|
||||||
GroupByColumnTypes,
|
GroupByColumnTypes,
|
||||||
@ -8,20 +10,22 @@ import {
|
|||||||
TIssueMap,
|
TIssueMap,
|
||||||
TUnGroupedIssues,
|
TUnGroupedIssues,
|
||||||
IGroupByColumn,
|
IGroupByColumn,
|
||||||
|
TIssueOrderByOptions,
|
||||||
|
TIssueGroupByOptions,
|
||||||
} from "@plane/types";
|
} from "@plane/types";
|
||||||
import { IssueBlocksList, ListQuickAddIssueForm } from "@/components/issues";
|
|
||||||
// hooks
|
// hooks
|
||||||
import { EIssuesStoreType } from "@/constants/issue";
|
import { EIssuesStoreType } from "@/constants/issue";
|
||||||
import { useCycle, useLabel, useMember, useModule, useProject, useProjectState } from "@/hooks/store";
|
import { useCycle, useLabel, useMember, useModule, useProject, useProjectState } from "@/hooks/store";
|
||||||
// utils
|
// utils
|
||||||
import { getGroupByColumns, isWorkspaceLevel } from "../utils";
|
import { getGroupByColumns, isWorkspaceLevel, GroupDropLocation } from "../utils";
|
||||||
import { HeaderGroupByCard } from "./headers/group-by-card";
|
import { ListGroup } from "./list-group";
|
||||||
import { TRenderQuickActions } from "./list-view-types";
|
import { TRenderQuickActions } from "./list-view-types";
|
||||||
|
|
||||||
export interface IGroupByList {
|
export interface IGroupByList {
|
||||||
issueIds: TGroupedIssues | TUnGroupedIssues | any;
|
issueIds: TGroupedIssues | TUnGroupedIssues | any;
|
||||||
issuesMap: TIssueMap;
|
issuesMap: TIssueMap;
|
||||||
group_by: string | null;
|
group_by: TIssueGroupByOptions | null;
|
||||||
|
orderBy: TIssueOrderByOptions | undefined;
|
||||||
updateIssue: ((projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>) | undefined;
|
updateIssue: ((projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>) | undefined;
|
||||||
quickActions: TRenderQuickActions;
|
quickActions: TRenderQuickActions;
|
||||||
displayProperties: IIssueDisplayProperties | undefined;
|
displayProperties: IIssueDisplayProperties | undefined;
|
||||||
@ -36,6 +40,7 @@ export interface IGroupByList {
|
|||||||
) => Promise<TIssue | undefined>;
|
) => Promise<TIssue | undefined>;
|
||||||
disableIssueCreation?: boolean;
|
disableIssueCreation?: boolean;
|
||||||
storeType: EIssuesStoreType;
|
storeType: EIssuesStoreType;
|
||||||
|
handleOnDrop: (source: GroupDropLocation, destination: GroupDropLocation) => Promise<void>;
|
||||||
addIssuesToView?: (issueIds: string[]) => Promise<TIssue>;
|
addIssuesToView?: (issueIds: string[]) => Promise<TIssue>;
|
||||||
viewId?: string;
|
viewId?: string;
|
||||||
isCompletedCycle?: boolean;
|
isCompletedCycle?: boolean;
|
||||||
@ -46,6 +51,7 @@ const GroupByList: React.FC<IGroupByList> = (props) => {
|
|||||||
issueIds,
|
issueIds,
|
||||||
issuesMap,
|
issuesMap,
|
||||||
group_by,
|
group_by,
|
||||||
|
orderBy,
|
||||||
updateIssue,
|
updateIssue,
|
||||||
quickActions,
|
quickActions,
|
||||||
displayProperties,
|
displayProperties,
|
||||||
@ -56,6 +62,7 @@ const GroupByList: React.FC<IGroupByList> = (props) => {
|
|||||||
viewId,
|
viewId,
|
||||||
disableIssueCreation,
|
disableIssueCreation,
|
||||||
storeType,
|
storeType,
|
||||||
|
handleOnDrop,
|
||||||
addIssuesToView,
|
addIssuesToView,
|
||||||
isCompletedCycle = false,
|
isCompletedCycle = false,
|
||||||
} = props;
|
} = props;
|
||||||
@ -81,46 +88,30 @@ const GroupByList: React.FC<IGroupByList> = (props) => {
|
|||||||
isWorkspaceLevel(storeType)
|
isWorkspaceLevel(storeType)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Enable Auto Scroll for Main Kanban
|
||||||
|
useEffect(() => {
|
||||||
|
const element = containerRef.current;
|
||||||
|
|
||||||
|
if (!element) return;
|
||||||
|
|
||||||
|
return combine(
|
||||||
|
autoScrollForElements({
|
||||||
|
element,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}, [containerRef]);
|
||||||
|
|
||||||
if (!groups) return null;
|
if (!groups) return null;
|
||||||
|
|
||||||
const prePopulateQuickAddData = (groupByKey: string | null, value: any) => {
|
|
||||||
const defaultState = projectState.projectStates?.find((state) => state.default);
|
|
||||||
let preloadedData: object = { state_id: defaultState?.id };
|
|
||||||
|
|
||||||
if (groupByKey === null) {
|
|
||||||
preloadedData = { ...preloadedData };
|
|
||||||
} else {
|
|
||||||
if (groupByKey === "state") {
|
|
||||||
preloadedData = { ...preloadedData, state_id: value };
|
|
||||||
} else if (groupByKey === "priority") {
|
|
||||||
preloadedData = { ...preloadedData, priority: value };
|
|
||||||
} else if (groupByKey === "labels" && value != "None") {
|
|
||||||
preloadedData = { ...preloadedData, label_ids: [value] };
|
|
||||||
} else if (groupByKey === "assignees" && value != "None") {
|
|
||||||
preloadedData = { ...preloadedData, assignee_ids: [value] };
|
|
||||||
} else if (groupByKey === "cycle" && value != "None") {
|
|
||||||
preloadedData = { ...preloadedData, cycle_id: value };
|
|
||||||
} else if (groupByKey === "module" && value != "None") {
|
|
||||||
preloadedData = { ...preloadedData, module_ids: [value] };
|
|
||||||
} else if (groupByKey === "created_by") {
|
|
||||||
preloadedData = { ...preloadedData };
|
|
||||||
} else {
|
|
||||||
preloadedData = { ...preloadedData, [groupByKey]: value };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return preloadedData;
|
|
||||||
};
|
|
||||||
|
|
||||||
const validateEmptyIssueGroups = (issues: TIssue[]) => {
|
const validateEmptyIssueGroups = (issues: TIssue[]) => {
|
||||||
const issuesCount = issues?.length || 0;
|
const issuesCount = issues?.length || 0;
|
||||||
if (!showEmptyGroup && issuesCount <= 0) return false;
|
if (!showEmptyGroup && issuesCount <= 0) return false;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const is_list = group_by === null ? true : false;
|
const getGroupIndex = (groupId: string | undefined) => groups.findIndex(({ id }) => id === groupId);
|
||||||
|
|
||||||
const isGroupByCreatedBy = group_by === "created_by";
|
const is_list = group_by === null ? true : false;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -130,43 +121,30 @@ const GroupByList: React.FC<IGroupByList> = (props) => {
|
|||||||
{groups &&
|
{groups &&
|
||||||
groups.length > 0 &&
|
groups.length > 0 &&
|
||||||
groups.map(
|
groups.map(
|
||||||
(_list: IGroupByColumn) =>
|
(group: IGroupByColumn) =>
|
||||||
validateEmptyIssueGroups(is_list ? issueIds : issueIds?.[_list.id]) && (
|
validateEmptyIssueGroups(is_list ? issueIds : issueIds?.[group.id]) && (
|
||||||
<div key={_list.id} className={`flex flex-shrink-0 flex-col`}>
|
<ListGroup
|
||||||
<div className="sticky top-0 z-[2] w-full flex-shrink-0 border-b border-custom-border-200 bg-custom-background-90 px-3 pl-5 py-1">
|
key={group.id}
|
||||||
<HeaderGroupByCard
|
group={group}
|
||||||
icon={_list.icon}
|
getGroupIndex={getGroupIndex}
|
||||||
title={_list.name || ""}
|
issueIds={issueIds}
|
||||||
count={is_list ? issueIds?.length || 0 : issueIds?.[_list.id]?.length || 0}
|
issuesMap={issuesMap}
|
||||||
issuePayload={_list.payload}
|
group_by={group_by}
|
||||||
disableIssueCreation={disableIssueCreation || isGroupByCreatedBy || isCompletedCycle}
|
orderBy={orderBy}
|
||||||
storeType={storeType}
|
updateIssue={updateIssue}
|
||||||
addIssuesToView={addIssuesToView}
|
quickActions={quickActions}
|
||||||
/>
|
displayProperties={displayProperties}
|
||||||
</div>
|
enableIssueQuickAdd={enableIssueQuickAdd}
|
||||||
|
canEditProperties={canEditProperties}
|
||||||
{issueIds && (
|
storeType={storeType}
|
||||||
<IssueBlocksList
|
containerRef={containerRef}
|
||||||
issueIds={is_list ? issueIds || 0 : issueIds?.[_list.id] || 0}
|
quickAddCallback={quickAddCallback}
|
||||||
issuesMap={issuesMap}
|
disableIssueCreation={disableIssueCreation}
|
||||||
updateIssue={updateIssue}
|
addIssuesToView={addIssuesToView}
|
||||||
quickActions={quickActions}
|
handleOnDrop={handleOnDrop}
|
||||||
displayProperties={displayProperties}
|
viewId={viewId}
|
||||||
canEditProperties={canEditProperties}
|
isCompletedCycle={isCompletedCycle}
|
||||||
containerRef={containerRef}
|
/>
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{enableIssueQuickAdd && !disableIssueCreation && !isGroupByCreatedBy && !isCompletedCycle && (
|
|
||||||
<div className="sticky bottom-0 z-[1] w-full flex-shrink-0">
|
|
||||||
<ListQuickAddIssueForm
|
|
||||||
prePopulatedData={prePopulateQuickAddData(group_by, _list.id)}
|
|
||||||
quickAddCallback={quickAddCallback}
|
|
||||||
viewId={viewId}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@ -176,7 +154,8 @@ const GroupByList: React.FC<IGroupByList> = (props) => {
|
|||||||
export interface IList {
|
export interface IList {
|
||||||
issueIds: TGroupedIssues | TUnGroupedIssues | any;
|
issueIds: TGroupedIssues | TUnGroupedIssues | any;
|
||||||
issuesMap: TIssueMap;
|
issuesMap: TIssueMap;
|
||||||
group_by: string | null;
|
group_by: TIssueGroupByOptions | null;
|
||||||
|
orderBy: TIssueOrderByOptions | undefined;
|
||||||
updateIssue: ((projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>) | undefined;
|
updateIssue: ((projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>) | undefined;
|
||||||
quickActions: TRenderQuickActions;
|
quickActions: TRenderQuickActions;
|
||||||
displayProperties: IIssueDisplayProperties | undefined;
|
displayProperties: IIssueDisplayProperties | undefined;
|
||||||
@ -192,6 +171,7 @@ export interface IList {
|
|||||||
viewId?: string;
|
viewId?: string;
|
||||||
disableIssueCreation?: boolean;
|
disableIssueCreation?: boolean;
|
||||||
storeType: EIssuesStoreType;
|
storeType: EIssuesStoreType;
|
||||||
|
handleOnDrop: (source: GroupDropLocation, destination: GroupDropLocation) => Promise<void>;
|
||||||
addIssuesToView?: (issueIds: string[]) => Promise<TIssue>;
|
addIssuesToView?: (issueIds: string[]) => Promise<TIssue>;
|
||||||
isCompletedCycle?: boolean;
|
isCompletedCycle?: boolean;
|
||||||
}
|
}
|
||||||
@ -201,6 +181,7 @@ export const List: React.FC<IList> = (props) => {
|
|||||||
issueIds,
|
issueIds,
|
||||||
issuesMap,
|
issuesMap,
|
||||||
group_by,
|
group_by,
|
||||||
|
orderBy,
|
||||||
updateIssue,
|
updateIssue,
|
||||||
quickActions,
|
quickActions,
|
||||||
quickAddCallback,
|
quickAddCallback,
|
||||||
@ -211,6 +192,7 @@ export const List: React.FC<IList> = (props) => {
|
|||||||
canEditProperties,
|
canEditProperties,
|
||||||
disableIssueCreation,
|
disableIssueCreation,
|
||||||
storeType,
|
storeType,
|
||||||
|
handleOnDrop,
|
||||||
addIssuesToView,
|
addIssuesToView,
|
||||||
isCompletedCycle = false,
|
isCompletedCycle = false,
|
||||||
} = props;
|
} = props;
|
||||||
@ -221,6 +203,7 @@ export const List: React.FC<IList> = (props) => {
|
|||||||
issueIds={issueIds as TUnGroupedIssues}
|
issueIds={issueIds as TUnGroupedIssues}
|
||||||
issuesMap={issuesMap}
|
issuesMap={issuesMap}
|
||||||
group_by={group_by}
|
group_by={group_by}
|
||||||
|
orderBy={orderBy}
|
||||||
updateIssue={updateIssue}
|
updateIssue={updateIssue}
|
||||||
quickActions={quickActions}
|
quickActions={quickActions}
|
||||||
displayProperties={displayProperties}
|
displayProperties={displayProperties}
|
||||||
@ -231,6 +214,7 @@ export const List: React.FC<IList> = (props) => {
|
|||||||
viewId={viewId}
|
viewId={viewId}
|
||||||
disableIssueCreation={disableIssueCreation}
|
disableIssueCreation={disableIssueCreation}
|
||||||
storeType={storeType}
|
storeType={storeType}
|
||||||
|
handleOnDrop={handleOnDrop}
|
||||||
addIssuesToView={addIssuesToView}
|
addIssuesToView={addIssuesToView}
|
||||||
isCompletedCycle={isCompletedCycle}
|
isCompletedCycle={isCompletedCycle}
|
||||||
/>
|
/>
|
||||||
|
242
web/components/issues/issue-layouts/list/list-group.tsx
Normal file
242
web/components/issues/issue-layouts/list/list-group.tsx
Normal file
@ -0,0 +1,242 @@
|
|||||||
|
import { MutableRefObject, useEffect, useRef, useState } from "react";
|
||||||
|
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
||||||
|
import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
||||||
|
import { observer } from "mobx-react";
|
||||||
|
import { cn } from "@plane/editor-core";
|
||||||
|
// plane
|
||||||
|
import {
|
||||||
|
IGroupByColumn,
|
||||||
|
IIssueDisplayProperties,
|
||||||
|
TGroupedIssues,
|
||||||
|
TIssue,
|
||||||
|
TIssueGroupByOptions,
|
||||||
|
TIssueMap,
|
||||||
|
TIssueOrderByOptions,
|
||||||
|
TUnGroupedIssues,
|
||||||
|
} from "@plane/types";
|
||||||
|
import { TOAST_TYPE, setToast } from "@plane/ui";
|
||||||
|
// constants
|
||||||
|
import { DRAG_ALLOWED_GROUPS, EIssuesStoreType } from "@/constants/issue";
|
||||||
|
// hooks
|
||||||
|
import { useProjectState } from "@/hooks/store";
|
||||||
|
// components
|
||||||
|
import { GroupDragOverlay } from "../group-drag-overlay";
|
||||||
|
import {
|
||||||
|
GroupDropLocation,
|
||||||
|
getDestinationFromDropPayload,
|
||||||
|
getIssueBlockId,
|
||||||
|
getSourceFromDropPayload,
|
||||||
|
highlightIssueOnDrop,
|
||||||
|
} from "../utils";
|
||||||
|
import { IssueBlocksList } from "./blocks-list";
|
||||||
|
import { HeaderGroupByCard } from "./headers/group-by-card";
|
||||||
|
import { TRenderQuickActions } from "./list-view-types";
|
||||||
|
import { ListQuickAddIssueForm } from "./quick-add-issue-form";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
issueIds: TGroupedIssues | TUnGroupedIssues | any;
|
||||||
|
group: IGroupByColumn;
|
||||||
|
issuesMap: TIssueMap;
|
||||||
|
group_by: TIssueGroupByOptions | null;
|
||||||
|
orderBy: TIssueOrderByOptions | undefined;
|
||||||
|
getGroupIndex: (groupId: string | undefined) => number;
|
||||||
|
updateIssue: ((projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>) | undefined;
|
||||||
|
quickActions: TRenderQuickActions;
|
||||||
|
displayProperties: IIssueDisplayProperties | undefined;
|
||||||
|
enableIssueQuickAdd: boolean;
|
||||||
|
canEditProperties: (projectId: string | undefined) => boolean;
|
||||||
|
storeType: EIssuesStoreType;
|
||||||
|
containerRef: MutableRefObject<HTMLDivElement | null>;
|
||||||
|
quickAddCallback?: (
|
||||||
|
workspaceSlug: string,
|
||||||
|
projectId: string,
|
||||||
|
data: TIssue,
|
||||||
|
viewId?: string
|
||||||
|
) => Promise<TIssue | undefined>;
|
||||||
|
handleOnDrop: (source: GroupDropLocation, destination: GroupDropLocation) => Promise<void>;
|
||||||
|
disableIssueCreation?: boolean;
|
||||||
|
addIssuesToView?: (issueIds: string[]) => Promise<TIssue>;
|
||||||
|
viewId?: string;
|
||||||
|
isCompletedCycle?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ListGroup = observer((props: Props) => {
|
||||||
|
const {
|
||||||
|
group,
|
||||||
|
issueIds,
|
||||||
|
group_by,
|
||||||
|
orderBy,
|
||||||
|
issuesMap,
|
||||||
|
getGroupIndex,
|
||||||
|
disableIssueCreation,
|
||||||
|
addIssuesToView,
|
||||||
|
updateIssue,
|
||||||
|
quickActions,
|
||||||
|
displayProperties,
|
||||||
|
canEditProperties,
|
||||||
|
quickAddCallback,
|
||||||
|
containerRef,
|
||||||
|
viewId,
|
||||||
|
handleOnDrop,
|
||||||
|
enableIssueQuickAdd,
|
||||||
|
isCompletedCycle,
|
||||||
|
storeType,
|
||||||
|
} = props;
|
||||||
|
|
||||||
|
const [isDraggingOverColumn, setIsDraggingOverColumn] = useState(false);
|
||||||
|
const [dragColumnOrientation, setDragColumnOrientation] = useState<"justify-start" | "justify-end">("justify-start");
|
||||||
|
const groupRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
|
const projectState = useProjectState();
|
||||||
|
|
||||||
|
const prePopulateQuickAddData = (groupByKey: string | null, value: any) => {
|
||||||
|
const defaultState = projectState.projectStates?.find((state) => state.default);
|
||||||
|
let preloadedData: object = { state_id: defaultState?.id };
|
||||||
|
|
||||||
|
if (groupByKey === null) {
|
||||||
|
preloadedData = { ...preloadedData };
|
||||||
|
} else {
|
||||||
|
if (groupByKey === "state") {
|
||||||
|
preloadedData = { ...preloadedData, state_id: value };
|
||||||
|
} else if (groupByKey === "priority") {
|
||||||
|
preloadedData = { ...preloadedData, priority: value };
|
||||||
|
} else if (groupByKey === "labels" && value != "None") {
|
||||||
|
preloadedData = { ...preloadedData, label_ids: [value] };
|
||||||
|
} else if (groupByKey === "assignees" && value != "None") {
|
||||||
|
preloadedData = { ...preloadedData, assignee_ids: [value] };
|
||||||
|
} else if (groupByKey === "cycle" && value != "None") {
|
||||||
|
preloadedData = { ...preloadedData, cycle_id: value };
|
||||||
|
} else if (groupByKey === "module" && value != "None") {
|
||||||
|
preloadedData = { ...preloadedData, module_ids: [value] };
|
||||||
|
} else if (groupByKey === "created_by") {
|
||||||
|
preloadedData = { ...preloadedData };
|
||||||
|
} else {
|
||||||
|
preloadedData = { ...preloadedData, [groupByKey]: value };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return preloadedData;
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const element = groupRef.current;
|
||||||
|
|
||||||
|
if (!element) return;
|
||||||
|
|
||||||
|
return combine(
|
||||||
|
dropTargetForElements({
|
||||||
|
element,
|
||||||
|
getData: () => ({ groupId: group.id, type: "COLUMN" }),
|
||||||
|
onDragEnter: () => {
|
||||||
|
setIsDraggingOverColumn(true);
|
||||||
|
},
|
||||||
|
onDragLeave: () => {
|
||||||
|
setIsDraggingOverColumn(false);
|
||||||
|
},
|
||||||
|
onDragStart: () => {
|
||||||
|
setIsDraggingOverColumn(true);
|
||||||
|
},
|
||||||
|
onDrag: ({ source }) => {
|
||||||
|
const sourceGroupId = source?.data?.groupId as string | undefined;
|
||||||
|
const currentGroupId = group.id;
|
||||||
|
|
||||||
|
const sourceIndex = getGroupIndex(sourceGroupId);
|
||||||
|
const currentIndex = getGroupIndex(currentGroupId);
|
||||||
|
|
||||||
|
if (sourceIndex > currentIndex) {
|
||||||
|
setDragColumnOrientation("justify-end");
|
||||||
|
} else {
|
||||||
|
setDragColumnOrientation("justify-start");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onDrop: (payload) => {
|
||||||
|
setIsDraggingOverColumn(false);
|
||||||
|
const source = getSourceFromDropPayload(payload);
|
||||||
|
const destination = getDestinationFromDropPayload(payload);
|
||||||
|
|
||||||
|
if (!source || !destination) return;
|
||||||
|
|
||||||
|
if (group.isDropDisabled) {
|
||||||
|
group.dropErrorMessage &&
|
||||||
|
setToast({
|
||||||
|
type: TOAST_TYPE.WARNING,
|
||||||
|
title: "Warning!",
|
||||||
|
message: group.dropErrorMessage,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleOnDrop(source, destination);
|
||||||
|
|
||||||
|
highlightIssueOnDrop(getIssueBlockId(source.id, destination?.groupId), orderBy !== "sort_order");
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}, [groupRef?.current, group, orderBy, getGroupIndex, setDragColumnOrientation, setIsDraggingOverColumn]);
|
||||||
|
|
||||||
|
const is_list = group_by === null ? true : false;
|
||||||
|
const isDragAllowed = !!group_by && DRAG_ALLOWED_GROUPS.includes(group_by);
|
||||||
|
const canDropOverIssue = orderBy === "sort_order";
|
||||||
|
|
||||||
|
const issueCount: number = is_list ? issueIds?.length ?? 0 : issueIds?.[group.id]?.length ?? 0;
|
||||||
|
|
||||||
|
const isGroupByCreatedBy = group_by === "created_by";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={groupRef}
|
||||||
|
className={cn(`relative flex flex-shrink-0 flex-col border-[1px] border-transparent`, {
|
||||||
|
"border-custom-primary-100 ": isDraggingOverColumn,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<div className="sticky top-0 z-[3] w-full flex-shrink-0 border-b border-custom-border-200 bg-custom-background-90 px-3 pl-5 py-1">
|
||||||
|
<HeaderGroupByCard
|
||||||
|
icon={group.icon}
|
||||||
|
title={group.name || ""}
|
||||||
|
count={issueCount}
|
||||||
|
issuePayload={group.payload}
|
||||||
|
disableIssueCreation={disableIssueCreation || isGroupByCreatedBy || isCompletedCycle}
|
||||||
|
storeType={storeType}
|
||||||
|
addIssuesToView={addIssuesToView}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{!!issueCount && (
|
||||||
|
<div className="relative">
|
||||||
|
<GroupDragOverlay
|
||||||
|
dragColumnOrientation={dragColumnOrientation}
|
||||||
|
canDropOverIssue={canDropOverIssue}
|
||||||
|
isDropDisabled={!!group.isDropDisabled}
|
||||||
|
dropErrorMessage={group.dropErrorMessage}
|
||||||
|
orderBy={orderBy}
|
||||||
|
isDraggingOverColumn={isDraggingOverColumn}
|
||||||
|
/>
|
||||||
|
{issueIds && (
|
||||||
|
<IssueBlocksList
|
||||||
|
issueIds={is_list ? issueIds : issueIds?.[group.id]}
|
||||||
|
groupId={group.id}
|
||||||
|
issuesMap={issuesMap}
|
||||||
|
updateIssue={updateIssue}
|
||||||
|
quickActions={quickActions}
|
||||||
|
displayProperties={displayProperties}
|
||||||
|
canEditProperties={canEditProperties}
|
||||||
|
containerRef={containerRef}
|
||||||
|
isDragAllowed={isDragAllowed}
|
||||||
|
canDropOverIssue={canDropOverIssue}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{enableIssueQuickAdd && !disableIssueCreation && !isGroupByCreatedBy && !isCompletedCycle && (
|
||||||
|
<div className="sticky bottom-0 z-[1] w-full flex-shrink-0">
|
||||||
|
<ListQuickAddIssueForm
|
||||||
|
prePopulatedData={prePopulateQuickAddData(group_by, group.id)}
|
||||||
|
quickAddCallback={quickAddCallback}
|
||||||
|
viewId={viewId}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
});
|
@ -1,3 +1,4 @@
|
|||||||
|
import { extractInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
|
||||||
import clone from "lodash/clone";
|
import clone from "lodash/clone";
|
||||||
import concat from "lodash/concat";
|
import concat from "lodash/concat";
|
||||||
import pull from "lodash/pull";
|
import pull from "lodash/pull";
|
||||||
@ -37,6 +38,7 @@ export type GroupDropLocation = {
|
|||||||
groupId: string;
|
groupId: string;
|
||||||
subGroupId?: string;
|
subGroupId?: string;
|
||||||
id: string | undefined;
|
id: string | undefined;
|
||||||
|
canAddIssueBelow?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type IssueUpdates = {
|
export type IssueUpdates = {
|
||||||
@ -353,11 +355,15 @@ export const getDestinationFromDropPayload = (payload: IPragmaticDropPayload): G
|
|||||||
|
|
||||||
if (!destinationColumnData?.groupId) return;
|
if (!destinationColumnData?.groupId) return;
|
||||||
|
|
||||||
|
// extract instruction from destination issue
|
||||||
|
const extractedInstruction = destinationIssueData ? extractInstruction(destinationIssueData)?.type : "";
|
||||||
|
|
||||||
return {
|
return {
|
||||||
groupId: destinationColumnData.groupId as string,
|
groupId: destinationColumnData.groupId as string,
|
||||||
subGroupId: destinationColumnData.subGroupId as string,
|
subGroupId: destinationColumnData.subGroupId as string,
|
||||||
columnId: destinationColumnData.columnId as string,
|
columnId: destinationColumnData.columnId as string,
|
||||||
id: destinationIssueData?.id as string | undefined,
|
id: destinationIssueData?.id as string | undefined,
|
||||||
|
canAddIssueBelow: extractedInstruction === "reorder-below",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -372,17 +378,25 @@ const handleSortOrder = (
|
|||||||
destinationIssues: string[],
|
destinationIssues: string[],
|
||||||
destinationIssueId: string | undefined,
|
destinationIssueId: string | undefined,
|
||||||
getIssueById: (issueId: string) => TIssue | undefined,
|
getIssueById: (issueId: string) => TIssue | undefined,
|
||||||
shouldAddIssueAtTop = false
|
shouldAddIssueAtTop = false,
|
||||||
|
canAddIssueBelow = false
|
||||||
) => {
|
) => {
|
||||||
const sortOrderDefaultValue = 65535;
|
const sortOrderDefaultValue = 65535;
|
||||||
let currentIssueState = {};
|
let currentIssueState = {};
|
||||||
|
|
||||||
const destinationIndex = destinationIssueId
|
let destinationIndex = destinationIssueId
|
||||||
? destinationIssues.indexOf(destinationIssueId)
|
? destinationIssues.indexOf(destinationIssueId)
|
||||||
: shouldAddIssueAtTop
|
: shouldAddIssueAtTop
|
||||||
? 0
|
? 0
|
||||||
: destinationIssues.length;
|
: destinationIssues.length;
|
||||||
|
|
||||||
|
const isDestinationLastChild = destinationIndex === destinationIssues.length - 1;
|
||||||
|
|
||||||
|
// if issue can be added below and if the destination issue is the last child, then add to the end of the list
|
||||||
|
if (canAddIssueBelow && isDestinationLastChild) {
|
||||||
|
destinationIndex = destinationIssues.length;
|
||||||
|
}
|
||||||
|
|
||||||
if (destinationIssues && destinationIssues.length > 0) {
|
if (destinationIssues && destinationIssues.length > 0) {
|
||||||
if (destinationIndex === 0) {
|
if (destinationIndex === 0) {
|
||||||
const destinationIssueId = destinationIssues[0];
|
const destinationIssueId = destinationIssues[0];
|
||||||
@ -428,7 +442,7 @@ const handleSortOrder = (
|
|||||||
export const getIssueBlockId = (
|
export const getIssueBlockId = (
|
||||||
issueId: string | undefined,
|
issueId: string | undefined,
|
||||||
groupId: string | undefined,
|
groupId: string | undefined,
|
||||||
subGroupId: string | undefined
|
subGroupId?: string | undefined
|
||||||
) => `issue_${issueId}_${groupId}_${subGroupId}`;
|
) => `issue_${issueId}_${groupId}_${subGroupId}`;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -469,7 +483,13 @@ export const handleGroupDragDrop = async (
|
|||||||
// for both horizontal and vertical dnd
|
// for both horizontal and vertical dnd
|
||||||
updatedIssue = {
|
updatedIssue = {
|
||||||
...updatedIssue,
|
...updatedIssue,
|
||||||
...handleSortOrder(destinationIssues, destination.id, getIssueById, shouldAddIssueAtTop),
|
...handleSortOrder(
|
||||||
|
destinationIssues,
|
||||||
|
destination.id,
|
||||||
|
getIssueById,
|
||||||
|
shouldAddIssueAtTop,
|
||||||
|
!!destination.canAddIssueBelow
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
// update updatedIssue values based on the source and destination groupIds
|
// update updatedIssue values based on the source and destination groupIds
|
||||||
|
@ -2,12 +2,11 @@ import { MutableRefObject, useRef, useState } from "react";
|
|||||||
import { LucideIcon, X } from "lucide-react";
|
import { LucideIcon, X } from "lucide-react";
|
||||||
import { IIssueLabel } from "@plane/types";
|
import { IIssueLabel } from "@plane/types";
|
||||||
//ui
|
//ui
|
||||||
import { CustomMenu } from "@plane/ui";
|
import { CustomMenu, DragHandle } from "@plane/ui";
|
||||||
//types
|
//types
|
||||||
import useOutsideClickDetector from "@/hooks/use-outside-click-detector";
|
import useOutsideClickDetector from "@/hooks/use-outside-click-detector";
|
||||||
//hooks
|
//hooks
|
||||||
//components
|
//components
|
||||||
import { DragHandle } from "./drag-handle";
|
|
||||||
import { LabelName } from "./label-name";
|
import { LabelName } from "./label-name";
|
||||||
|
|
||||||
//types
|
//types
|
||||||
|
@ -12,6 +12,15 @@ import {
|
|||||||
TIssueTypeFilters,
|
TIssueTypeFilters,
|
||||||
} from "@plane/types";
|
} from "@plane/types";
|
||||||
|
|
||||||
|
export const DRAG_ALLOWED_GROUPS: TIssueGroupByOptions[] = [
|
||||||
|
"state",
|
||||||
|
"priority",
|
||||||
|
"assignees",
|
||||||
|
"labels",
|
||||||
|
"module",
|
||||||
|
"cycle",
|
||||||
|
];
|
||||||
|
|
||||||
export enum EIssuesStoreType {
|
export enum EIssuesStoreType {
|
||||||
GLOBAL = "GLOBAL",
|
GLOBAL = "GLOBAL",
|
||||||
PROFILE = "PROFILE",
|
PROFILE = "PROFILE",
|
||||||
@ -422,3 +431,4 @@ export const groupReactionEmojis = (reactions: any) => {
|
|||||||
|
|
||||||
return groupedEmojis;
|
return groupedEmojis;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
124
web/hooks/use-group-dragndrop.ts
Normal file
124
web/hooks/use-group-dragndrop.ts
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
import { useRouter } from "next/router";
|
||||||
|
import { TIssue, TIssueGroupByOptions, TIssueOrderByOptions } from "@plane/types";
|
||||||
|
import { TOAST_TYPE, setToast } from "@plane/ui";
|
||||||
|
import { GroupDropLocation, handleGroupDragDrop } from "@/components/issues/issue-layouts/utils";
|
||||||
|
import { EIssuesStoreType } from "@/constants/issue";
|
||||||
|
import { ISSUE_FILTER_DEFAULT_DATA } from "@/store/issue/helpers/issue-helper.store";
|
||||||
|
import { useIssueDetail, useIssues } from "./store";
|
||||||
|
import { useIssuesActions } from "./use-issues-actions";
|
||||||
|
|
||||||
|
type DNDStoreType =
|
||||||
|
| EIssuesStoreType.PROJECT
|
||||||
|
| EIssuesStoreType.MODULE
|
||||||
|
| EIssuesStoreType.CYCLE
|
||||||
|
| EIssuesStoreType.PROJECT_VIEW
|
||||||
|
| EIssuesStoreType.DRAFT
|
||||||
|
| EIssuesStoreType.PROFILE
|
||||||
|
| EIssuesStoreType.ARCHIVED;
|
||||||
|
|
||||||
|
export const useGroupIssuesDragNDrop = (
|
||||||
|
storeType: DNDStoreType,
|
||||||
|
orderBy: TIssueOrderByOptions | undefined,
|
||||||
|
groupBy: TIssueGroupByOptions | undefined,
|
||||||
|
subGroupBy?: TIssueGroupByOptions
|
||||||
|
) => {
|
||||||
|
const router = useRouter();
|
||||||
|
const { workspaceSlug } = router.query;
|
||||||
|
|
||||||
|
const {
|
||||||
|
issue: { getIssueById },
|
||||||
|
} = useIssueDetail();
|
||||||
|
const { updateIssue } = useIssuesActions(storeType);
|
||||||
|
const {
|
||||||
|
issues: { getIssueIds },
|
||||||
|
} = useIssues(storeType);
|
||||||
|
const {
|
||||||
|
issues: { addCycleToIssue, removeCycleFromIssue },
|
||||||
|
} = useIssues(EIssuesStoreType.CYCLE);
|
||||||
|
const {
|
||||||
|
issues: { changeModulesInIssue },
|
||||||
|
} = useIssues(EIssuesStoreType.MODULE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update Issue on Drop, checks if modules or cycles are changed and then calls appropriate functions
|
||||||
|
* @param projectId
|
||||||
|
* @param issueId
|
||||||
|
* @param data
|
||||||
|
* @param issueUpdates
|
||||||
|
*/
|
||||||
|
const updateIssueOnDrop = async (
|
||||||
|
projectId: string,
|
||||||
|
issueId: string,
|
||||||
|
data: Partial<TIssue>,
|
||||||
|
issueUpdates: {
|
||||||
|
[groupKey: string]: {
|
||||||
|
ADD: string[];
|
||||||
|
REMOVE: string[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
) => {
|
||||||
|
const errorToastProps = {
|
||||||
|
type: TOAST_TYPE.ERROR,
|
||||||
|
title: "Error!",
|
||||||
|
message: "Error while updating issue",
|
||||||
|
};
|
||||||
|
const moduleKey = ISSUE_FILTER_DEFAULT_DATA["module"];
|
||||||
|
const cycleKey = ISSUE_FILTER_DEFAULT_DATA["cycle"];
|
||||||
|
|
||||||
|
const isModuleChanged = Object.keys(data).includes(moduleKey);
|
||||||
|
const isCycleChanged = Object.keys(data).includes(cycleKey);
|
||||||
|
|
||||||
|
if (isCycleChanged && workspaceSlug) {
|
||||||
|
if (data[cycleKey]) {
|
||||||
|
addCycleToIssue(workspaceSlug.toString(), projectId, data[cycleKey], issueId).catch(() =>
|
||||||
|
setToast(errorToastProps)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
removeCycleFromIssue(workspaceSlug.toString(), projectId, issueId).catch(() => setToast(errorToastProps));
|
||||||
|
}
|
||||||
|
delete data[cycleKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isModuleChanged && workspaceSlug && issueUpdates[moduleKey]) {
|
||||||
|
changeModulesInIssue(
|
||||||
|
workspaceSlug.toString(),
|
||||||
|
projectId,
|
||||||
|
issueId,
|
||||||
|
issueUpdates[moduleKey].ADD,
|
||||||
|
issueUpdates[moduleKey].REMOVE
|
||||||
|
).catch(() => setToast(errorToastProps));
|
||||||
|
delete data[moduleKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
updateIssue && updateIssue(projectId, issueId, data).catch(() => setToast(errorToastProps));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleOnDrop = async (source: GroupDropLocation, destination: GroupDropLocation) => {
|
||||||
|
if (
|
||||||
|
source.columnId &&
|
||||||
|
destination.columnId &&
|
||||||
|
destination.columnId === source.columnId &&
|
||||||
|
destination.id === source.id
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
|
await handleGroupDragDrop(
|
||||||
|
source,
|
||||||
|
destination,
|
||||||
|
getIssueById,
|
||||||
|
getIssueIds,
|
||||||
|
updateIssueOnDrop,
|
||||||
|
groupBy,
|
||||||
|
subGroupBy,
|
||||||
|
orderBy !== "sort_order"
|
||||||
|
).catch((err) => {
|
||||||
|
setToast({
|
||||||
|
title: "Error!",
|
||||||
|
type: TOAST_TYPE.ERROR,
|
||||||
|
message: err?.detail ?? "Failed to perform this action",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return handleOnDrop;
|
||||||
|
};
|
@ -17,6 +17,7 @@ export interface IArchivedIssues {
|
|||||||
// computed
|
// computed
|
||||||
groupedIssueIds: TGroupedIssues | TSubGroupedIssues | TUnGroupedIssues | undefined;
|
groupedIssueIds: TGroupedIssues | TSubGroupedIssues | TUnGroupedIssues | undefined;
|
||||||
// actions
|
// actions
|
||||||
|
getIssueIds: (groupId?: string) => string[] | undefined;
|
||||||
fetchIssues: (workspaceSlug: string, projectId: string, loadType: TLoader) => Promise<TIssue[]>;
|
fetchIssues: (workspaceSlug: string, projectId: string, loadType: TLoader) => Promise<TIssue[]>;
|
||||||
removeIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise<void>;
|
removeIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise<void>;
|
||||||
restoreIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise<void>;
|
restoreIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise<void>;
|
||||||
@ -84,6 +85,26 @@ export class ArchivedIssues extends IssueHelperStore implements IArchivedIssues
|
|||||||
return issues;
|
return issues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getIssueIds = (groupId?: string) => {
|
||||||
|
const groupedIssueIds = this.groupedIssueIds;
|
||||||
|
|
||||||
|
const displayFilters = this.rootStore?.projectIssuesFilter?.issueFilters?.displayFilters;
|
||||||
|
if (!displayFilters || !groupedIssueIds) return undefined;
|
||||||
|
|
||||||
|
const subGroupBy = displayFilters?.sub_group_by;
|
||||||
|
const groupBy = displayFilters?.group_by;
|
||||||
|
|
||||||
|
if (!groupBy && !subGroupBy) {
|
||||||
|
return groupedIssueIds as string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (groupBy && groupId) {
|
||||||
|
return (groupedIssueIds as TGroupedIssues)?.[groupId] as string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
||||||
fetchIssues = async (workspaceSlug: string, projectId: string, loadType: TLoader = "init-loader") => {
|
fetchIssues = async (workspaceSlug: string, projectId: string, loadType: TLoader = "init-loader") => {
|
||||||
try {
|
try {
|
||||||
this.loader = loadType;
|
this.loader = loadType;
|
||||||
|
@ -2,6 +2,7 @@ import { action, computed, makeObservable, observable } from "mobx";
|
|||||||
import { computedFn } from "mobx-utils";
|
import { computedFn } from "mobx-utils";
|
||||||
import { IssueRootStore } from "./root.store";
|
import { IssueRootStore } from "./root.store";
|
||||||
import { TIssueGroupByOptions } from "@plane/types";
|
import { TIssueGroupByOptions } from "@plane/types";
|
||||||
|
import { DRAG_ALLOWED_GROUPS } from "@/constants/issue";
|
||||||
// types
|
// types
|
||||||
|
|
||||||
export interface IIssueKanBanViewStore {
|
export interface IIssueKanBanViewStore {
|
||||||
@ -22,8 +23,6 @@ export interface IIssueKanBanViewStore {
|
|||||||
setIsDragging: (isDragging: boolean) => void;
|
setIsDragging: (isDragging: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DRAG_ALLOWED_GROUPS: TIssueGroupByOptions[] = ["state", "priority", "assignees", "labels", "module", "cycle"];
|
|
||||||
|
|
||||||
export class IssueKanBanViewStore implements IIssueKanBanViewStore {
|
export class IssueKanBanViewStore implements IIssueKanBanViewStore {
|
||||||
kanBanToggle: {
|
kanBanToggle: {
|
||||||
groupByHeaderMinMax: string[];
|
groupByHeaderMinMax: string[];
|
||||||
|
Loading…
Reference in New Issue
Block a user