2023-08-28 07:55:47 +00:00
|
|
|
import { useRouter } from "next/router";
|
2024-02-12 09:38:17 +00:00
|
|
|
import { observer } from "mobx-react";
|
|
|
|
// hooks
|
|
|
|
import { useApplication, useModule } from "hooks/store";
|
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-01-02 09:15:51 +00:00
|
|
|
import { renderFormattedDate } from "helpers/date-time.helper";
|
2023-08-28 07:55:47 +00:00
|
|
|
// constants
|
|
|
|
import { MODULE_STATUS } from "constants/module";
|
|
|
|
|
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);
|
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 }}
|
|
|
|
onClick={() => router.push(`/${workspaceSlug}/projects/${moduleDetails?.project}/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
|
|
|
|
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;
|
|
|
|
// 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);
|
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 gap-2"
|
2024-02-12 09:38:17 +00:00
|
|
|
onClick={() => router.push(`/${workspaceSlug}/projects/${moduleDetails?.project}/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>
|
2023-08-28 07:55:47 +00:00
|
|
|
</div>
|
|
|
|
);
|
2024-02-12 09:38:17 +00:00
|
|
|
});
|