2024-05-21 10:55:57 +00:00
|
|
|
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";
|
2024-05-22 11:45:37 +00:00
|
|
|
canOverlayBeVisible: boolean;
|
2024-05-21 10:55:57 +00:00
|
|
|
isDropDisabled: boolean;
|
|
|
|
dropErrorMessage?: string;
|
|
|
|
orderBy: TIssueOrderByOptions | undefined;
|
|
|
|
isDraggingOverColumn: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const GroupDragOverlay = (props: Props) => {
|
2024-05-22 11:45:37 +00:00
|
|
|
const {
|
|
|
|
dragColumnOrientation,
|
|
|
|
canOverlayBeVisible,
|
|
|
|
isDropDisabled,
|
|
|
|
dropErrorMessage,
|
|
|
|
orderBy,
|
|
|
|
isDraggingOverColumn,
|
|
|
|
} = props;
|
2024-05-21 10:55:57 +00:00
|
|
|
|
2024-05-22 11:45:37 +00:00
|
|
|
const shouldOverlayBeVisible = isDraggingOverColumn && canOverlayBeVisible;
|
2024-05-21 10:55:57 +00:00
|
|
|
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}`,
|
|
|
|
{
|
2024-05-22 11:45:37 +00:00
|
|
|
"flex flex-col border-[1px] border-custom-border-300 z-[2]": shouldOverlayBeVisible,
|
2024-05-21 10:55:57 +00:00
|
|
|
},
|
2024-05-22 11:45:37 +00:00
|
|
|
{ hidden: !shouldOverlayBeVisible }
|
2024-05-21 10:55:57 +00:00
|
|
|
)}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
className={cn(
|
2024-05-22 11:45:37 +00:00
|
|
|
"p-3 my-8 flex flex-col rounded items-center",
|
2024-05-21 10:55:57 +00:00
|
|
|
{
|
2024-05-22 11:45:37 +00:00
|
|
|
"text-custom-text-200": shouldOverlayBeVisible,
|
2024-05-21 10:55:57 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"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>
|
|
|
|
);
|
|
|
|
};
|