mirror of
https://github.com/makeplane/plane.git
synced 2026-06-14 03:30:00 +00:00
refactor: migrate hooks (use-timeline-chart) from web/app/ce to web/app/core
This commit is contained in:
@@ -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}`);
|
||||
};
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user