refactor: migrate hooks (use-timeline-chart) from web/app/ce to web/app/core

This commit is contained in:
Rahulcheryala
2026-06-05 16:48:14 +05:30
parent 007e8d2768
commit 973ef5e9d4
2 changed files with 23 additions and 34 deletions
-32
View File
@@ -1,32 +0,0 @@
/**
* Copyright (c) 2023-present Plane Software, Inc. and contributors
* SPDX-License-Identifier: AGPL-3.0-only
* See the LICENSE file for details.
*/
// types
import type { TTimelineTypeCore } from "@plane/types";
import { GANTT_TIMELINE_TYPE } from "@plane/types";
// Plane-web
import type { IBaseTimelineStore } from "@/plane-web/store/timeline/base-timeline.store";
import type { ITimelineStore } from "../store/timeline";
export const getTimelineStore = (
timelineStore: ITimelineStore,
timelineType: TTimelineTypeCore
): IBaseTimelineStore => {
if (timelineType === GANTT_TIMELINE_TYPE.ISSUE) {
return timelineStore.issuesTimeLineStore as IBaseTimelineStore;
}
if (timelineType === GANTT_TIMELINE_TYPE.MODULE) {
return timelineStore.modulesTimeLineStore as IBaseTimelineStore;
}
if (timelineType === GANTT_TIMELINE_TYPE.PROJECT) {
return timelineStore.projectTimeLineStore;
}
if (timelineType === GANTT_TIMELINE_TYPE.GROUPED) {
return timelineStore.groupedTimeLineStore;
}
throw new Error(`Unknown timeline type: ${timelineType}`);
};
+23 -2
View File
@@ -6,14 +6,35 @@
import { useContext } from "react";
// types
import type { TTimelineTypeCore } from "@plane/types";
import type { TTimelineType } from "@plane/types";
import { GANTT_TIMELINE_TYPE } from "@plane/types";
// lib
import { StoreContext } from "@/lib/store-context";
// Plane-web
import { getTimelineStore } from "@/plane-web/hooks/use-timeline-chart";
// plane-web store types
import type { IBaseTimelineStore } from "@/plane-web/store/timeline/base-timeline.store";
import type { ITimelineStore } from "@/plane-web/store/timeline";
import { useTimeLineType } from "../components/gantt-chart/contexts";
export const getTimelineStore = (
timelineStore: ITimelineStore,
timelineType: TTimelineTypeCore
): IBaseTimelineStore => {
if (timelineType === GANTT_TIMELINE_TYPE.ISSUE) {
return timelineStore.issuesTimeLineStore as IBaseTimelineStore;
}
if (timelineType === GANTT_TIMELINE_TYPE.MODULE) {
return timelineStore.modulesTimeLineStore as IBaseTimelineStore;
}
if (timelineType === GANTT_TIMELINE_TYPE.PROJECT) {
return timelineStore.projectTimeLineStore;
}
if (timelineType === GANTT_TIMELINE_TYPE.GROUPED) {
return timelineStore.groupedTimeLineStore;
}
throw new Error(`Unknown timeline type: ${timelineType}`);
};
export const useTimeLineChart = (timelineType: TTimelineType): IBaseTimelineStore => {
const context = useContext(StoreContext);
if (!context) throw new Error("useTimeLineChart must be used within StoreProvider");