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, ModuleStatusIcon } from "@plane/ui";
|
2023-08-28 07:55:47 +00:00
|
|
|
// helpers
|
2024-03-19 14:38:35 +00:00
|
|
|
import { MODULE_STATUS } from "@/constants/module";
|
|
|
|
import { renderFormattedDate } from "@/helpers/date-time.helper";
|
2023-08-28 07:55:47 +00:00
|
|
|
// constants
|
2024-03-19 14:38:35 +00:00
|
|
|
import { useApplication, useModule } 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 = {
|
|
|
|
moduleId: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const ModuleGanttBlock: React.FC<Props> = observer((props) => {
|
|
|
|
const { moduleId } = 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 { getModuleById } = useModule();
|
|
|
|
// derived values
|
|
|
|
const moduleDetails = getModuleById(moduleId);
|
2024-03-12 15:09:36 +00:00
|
|
|
// hooks
|
|
|
|
const { isMobile } = usePlatformOS();
|
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"
|
2024-02-12 09:38:17 +00:00
|
|
|
style={{ backgroundColor: MODULE_STATUS.find((s) => s.value === moduleDetails?.status)?.color }}
|
2024-02-21 11:26:02 +00:00
|
|
|
onClick={() =>
|
|
|
|
router.push(`/${workspaceSlug}/projects/${moduleDetails?.project_id}/modules/${moduleDetails?.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-19 14:38:35 +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>{moduleDetails?.name}</h5>
|
2023-08-28 07:55:47 +00:00
|
|
|
<div>
|
2024-02-12 09:38:17 +00:00
|
|
|
{renderFormattedDate(moduleDetails?.start_date ?? "")} to{" "}
|
|
|
|
{renderFormattedDate(moduleDetails?.target_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">{moduleDetails?.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 ModuleGanttSidebarBlock: React.FC<Props> = observer((props) => {
|
|
|
|
const { moduleId } = props;
|
|
|
|
// store hooks
|
|
|
|
const {
|
|
|
|
router: { workspaceSlug },
|
|
|
|
} = useApplication();
|
|
|
|
const { getModuleById } = useModule();
|
|
|
|
// derived values
|
|
|
|
const moduleDetails = getModuleById(moduleId);
|
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/${moduleDetails?.project_id}/modules/${moduleDetails?.id}`}
|
2023-08-28 07:55:47 +00:00
|
|
|
>
|
2024-02-12 09:38:17 +00:00
|
|
|
<ModuleStatusIcon status={moduleDetails?.status ?? "backlog"} height="16px" width="16px" />
|
|
|
|
<h6 className="flex-grow truncate text-sm font-medium">{moduleDetails?.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
|
|
|
});
|