2024-02-12 09:38:17 +00:00
|
|
|
import { observer } from "mobx-react";
|
2024-03-19 14:38:35 +00:00
|
|
|
import Link from "next/link";
|
2024-03-06 13:09:14 +00:00
|
|
|
import { useRouter } from "next/router";
|
2024-02-12 09:38:17 +00:00
|
|
|
// hooks
|
2023-08-28 07:55:47 +00:00
|
|
|
// ui
|
2023-10-16 14:57:22 +00:00
|
|
|
import { Tooltip, ContrastIcon } from "@plane/ui";
|
2023-08-28 07:55:47 +00:00
|
|
|
// helpers
|
2024-03-19 14:38:35 +00:00
|
|
|
import { renderFormattedDate } from "@/helpers/date-time.helper";
|
|
|
|
import { useApplication, useCycle } from "@/hooks/store";
|
|
|
|
import { usePlatformOS } from "@/hooks/use-platform-os";
|
2023-08-28 07:55:47 +00:00
|
|
|
|
2024-02-12 09:38:17 +00:00
|
|
|
type Props = {
|
|
|
|
cycleId: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const CycleGanttBlock: React.FC<Props> = observer((props) => {
|
|
|
|
const { cycleId } = props;
|
|
|
|
// router
|
2023-08-28 07:55:47 +00:00
|
|
|
const router = useRouter();
|
2024-02-12 09:38:17 +00:00
|
|
|
// store hooks
|
|
|
|
const {
|
|
|
|
router: { workspaceSlug },
|
|
|
|
} = useApplication();
|
|
|
|
const { getCycleById } = useCycle();
|
|
|
|
// derived values
|
|
|
|
const cycleDetails = getCycleById(cycleId);
|
2024-03-12 15:09:36 +00:00
|
|
|
const { isMobile } = usePlatformOS();
|
2024-02-12 09:38:17 +00:00
|
|
|
const cycleStatus = cycleDetails?.status.toLocaleLowerCase();
|
2023-08-28 07:55:47 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
2023-12-10 10:18:10 +00:00
|
|
|
className="relative flex h-full w-full items-center rounded"
|
2023-08-28 07:55:47 +00:00
|
|
|
style={{
|
|
|
|
backgroundColor:
|
|
|
|
cycleStatus === "current"
|
|
|
|
? "#09a953"
|
|
|
|
: cycleStatus === "upcoming"
|
2024-03-19 14:38:35 +00:00
|
|
|
? "#f7ae59"
|
|
|
|
: cycleStatus === "completed"
|
|
|
|
? "#3f76ff"
|
|
|
|
: cycleStatus === "draft"
|
|
|
|
? "rgb(var(--color-text-200))"
|
|
|
|
: "",
|
2023-08-28 07:55:47 +00:00
|
|
|
}}
|
2024-02-21 11:26:02 +00:00
|
|
|
onClick={() => router.push(`/${workspaceSlug}/projects/${cycleDetails?.project_id}/cycles/${cycleDetails?.id}`)}
|
2023-08-28 07:55:47 +00:00
|
|
|
>
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="absolute left-0 top-0 h-full w-full bg-custom-background-100/50" />
|
2023-08-28 07:55:47 +00:00
|
|
|
<Tooltip
|
2024-03-12 15:09:36 +00:00
|
|
|
isMobile={isMobile}
|
2023-08-28 07:55:47 +00:00
|
|
|
tooltipContent={
|
|
|
|
<div className="space-y-1">
|
2024-02-12 09:38:17 +00:00
|
|
|
<h5>{cycleDetails?.name}</h5>
|
2023-08-28 07:55:47 +00:00
|
|
|
<div>
|
2024-02-12 09:38:17 +00:00
|
|
|
{renderFormattedDate(cycleDetails?.start_date ?? "")} to{" "}
|
|
|
|
{renderFormattedDate(cycleDetails?.end_date ?? "")}
|
2023-08-28 07:55:47 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
position="top-left"
|
|
|
|
>
|
2024-02-12 09:38:17 +00:00
|
|
|
<div className="relative w-full truncate px-2.5 py-1 text-sm text-custom-text-100">{cycleDetails?.name}</div>
|
2023-08-28 07:55:47 +00:00
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
);
|
2024-02-12 09:38:17 +00:00
|
|
|
});
|
2023-08-28 07:55:47 +00:00
|
|
|
|
2024-02-12 09:38:17 +00:00
|
|
|
export const CycleGanttSidebarBlock: React.FC<Props> = observer((props) => {
|
|
|
|
const { cycleId } = props;
|
|
|
|
// store hooks
|
|
|
|
const {
|
|
|
|
router: { workspaceSlug },
|
|
|
|
} = useApplication();
|
|
|
|
const { getCycleById } = useCycle();
|
|
|
|
// derived values
|
|
|
|
const cycleDetails = getCycleById(cycleId);
|
2023-08-28 07:55:47 +00:00
|
|
|
|
2024-02-12 09:38:17 +00:00
|
|
|
const cycleStatus = cycleDetails?.status.toLocaleLowerCase();
|
2023-08-28 07:55:47 +00:00
|
|
|
|
|
|
|
return (
|
2024-03-12 13:37:12 +00:00
|
|
|
<Link
|
2023-12-10 10:18:10 +00:00
|
|
|
className="relative flex h-full w-full items-center gap-2"
|
2024-03-12 13:37:12 +00:00
|
|
|
href={`/${workspaceSlug}/projects/${cycleDetails?.project_id}/cycles/${cycleDetails?.id}`}
|
2023-08-28 07:55:47 +00:00
|
|
|
>
|
|
|
|
<ContrastIcon
|
|
|
|
className="h-5 w-5 flex-shrink-0"
|
|
|
|
color={`${
|
|
|
|
cycleStatus === "current"
|
|
|
|
? "#09a953"
|
|
|
|
: cycleStatus === "upcoming"
|
2024-03-19 14:38:35 +00:00
|
|
|
? "#f7ae59"
|
|
|
|
: cycleStatus === "completed"
|
|
|
|
? "#3f76ff"
|
|
|
|
: cycleStatus === "draft"
|
|
|
|
? "rgb(var(--color-text-200))"
|
|
|
|
: ""
|
2023-08-28 07:55:47 +00:00
|
|
|
}`}
|
|
|
|
/>
|
2024-02-12 09:38:17 +00:00
|
|
|
<h6 className="flex-grow truncate text-sm font-medium">{cycleDetails?.name}</h6>
|
2024-03-12 13:37:12 +00:00
|
|
|
</Link>
|
2023-08-28 07:55:47 +00:00
|
|
|
);
|
2024-02-12 09:38:17 +00:00
|
|
|
});
|