-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[WEB-2442] chore: Refactor timeline store #5926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,13 @@ | ||
| // store | ||
| import { CoreRootStore } from "@/store/root.store"; | ||
| import { ITimelineStore, TimeLineStore } from "./timeline"; | ||
|
|
||
| export class RootStore extends CoreRootStore { | ||
| timelineStore: ITimelineStore; | ||
|
|
||
| constructor() { | ||
| super(); | ||
|
|
||
| this.timelineStore = new TimeLineStore(this); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||||||||||||||||||||||||||||
| import { RootStore } from "@/plane-web/store/root.store"; | ||||||||||||||||||||||||||||||||
| import { IIssuesTimeLineStore, IssuesTimeLineStore } from "@/store/timeline/issues-timeline.store"; | ||||||||||||||||||||||||||||||||
| import { IModulesTimeLineStore, ModulesTimeLineStore } from "@/store/timeline/modules-timeline.store"; | ||||||||||||||||||||||||||||||||
| import { BaseTimeLineStore, IBaseTimelineStore } from "./base-timeline.store"; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| export interface ITimelineStore { | ||||||||||||||||||||||||||||||||
| issuesTimeLineStore: IIssuesTimeLineStore; | ||||||||||||||||||||||||||||||||
| modulesTimeLineStore: IModulesTimeLineStore; | ||||||||||||||||||||||||||||||||
| projectTimeLineStore: IBaseTimelineStore; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| export class TimeLineStore implements ITimelineStore { | ||||||||||||||||||||||||||||||||
| issuesTimeLineStore: IIssuesTimeLineStore; | ||||||||||||||||||||||||||||||||
| modulesTimeLineStore: IModulesTimeLineStore; | ||||||||||||||||||||||||||||||||
| projectTimeLineStore: IBaseTimelineStore; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| constructor(rootStore: RootStore) { | ||||||||||||||||||||||||||||||||
| this.issuesTimeLineStore = new IssuesTimeLineStore(rootStore); | ||||||||||||||||||||||||||||||||
| this.modulesTimeLineStore = new ModulesTimeLineStore(rootStore); | ||||||||||||||||||||||||||||||||
| // Dummy store | ||||||||||||||||||||||||||||||||
| this.projectTimeLineStore = new BaseTimeLineStore(rootStore); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+17
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider adding initialization checks. The constructor instantiates stores without any error handling. Consider adding checks to ensure constructor(rootStore: RootStore) {
+ if (!rootStore) {
+ throw new Error("RootStore is required for TimeLineStore initialization");
+ }
this.issuesTimeLineStore = new IssuesTimeLineStore(rootStore);
this.modulesTimeLineStore = new ModulesTimeLineStore(rootStore);
// Dummy store
this.projectTimeLineStore = new BaseTimeLineStore(rootStore);
}📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ import { createContext, useContext } from "react"; | |
| export enum ETimeLineTypeType { | ||
| ISSUE = "ISSUE", | ||
| MODULE = "MODULE", | ||
| PROJECT = "PROJECT", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Timeline store integration needs attention The verification revealed that while the
This suggests the PROJECT timeline functionality is not fully implemented yet. Action items:
🔗 Analysis chainLGTM! Verify timeline store integration. The addition of Let's verify the integration with timeline stores: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify that PROJECT timeline type is properly integrated with timeline stores
# and that there are no missing implementations.
# Test 1: Check for PROJECT timeline store implementation
ast-grep --pattern 'projectTimeLineStore'
# Test 2: Check for PROJECT case handling in timeline-related code
rg -l "PROJECT.*timeline"
# Test 3: Look for any TODO or unimplemented cases
rg "TODO.*PROJECT.*timeline"
Length of output: 100 Script: #!/bin/bash
# Let's try a more comprehensive search strategy
# Check for PROJECT enum usage in timeline-related files
rg -i "PROJECT.*timeline|timeline.*PROJECT" -A 3 -B 3
# Look for timeline store implementations
ast-grep --pattern 'class $_ extends TimelineStore'
# Check for switch/case statements handling timeline types
ast-grep --pattern 'switch ($timelineType) {
$$$
}'
# Search for timeline type handling in general
rg "ETimeLineTypeType" -A 2 -B 2
# Look for store factory or initialization code
ast-grep --pattern 'new $_TimelineStore'
Length of output: 9402 |
||
| } | ||
|
|
||
| export const TimeLineTypeContext = createContext<ETimeLineTypeType | undefined>(undefined); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| import { useContext } from "react"; | ||
| // mobx store | ||
| // types | ||
| // lib | ||
| import { StoreContext } from "@/lib/store-context"; | ||
| import { IBaseTimelineStore } from "ee/store/timeline/base-timeline.store"; | ||
| // Plane-web | ||
| import { IBaseTimelineStore } from "@/plane-web/store/timeline/base-timeline.store"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Import path change requires attention The import path
The import path should be updated to use the correct path "ce/store/timeline/base-timeline.store" to maintain consistency with other files in the codebase. 🔗 Analysis chainVerify the import path change impact. The import path change from 'ee/store' to '@/plane-web/store' appears to be part of the code splitting objective. Let's verify that this change is consistent across the codebase. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check for any remaining references to the old import path
# and verify the new path exists
# Test 1: Check for any remaining references to the old path
echo "Checking for old import path references..."
rg "from ['\"]ee/store/timeline/base-timeline\.store['\"]"
# Test 2: Verify the new path exists
echo "Verifying new path exists..."
fd "base-timeline.store.ts" "web/plane-web/store/timeline"
Length of output: 399 Script: #!/bin/bash
# Let's try a broader search approach
# Test 1: Find the base-timeline.store.ts file anywhere in the repo
echo "Searching for base-timeline.store.ts..."
fd "base-timeline.store.ts"
# Test 2: Check for any imports of base-timeline.store from any path
echo "Checking all imports of base-timeline.store..."
rg "from.*base-timeline\.store"
# Test 3: List all files in web directory to understand structure
echo "Listing web directory structure..."
fd . web -t d
Length of output: 21793 |
||
| // | ||
| import { ETimeLineTypeType, useTimeLineType } from "../components/gantt-chart/contexts"; | ||
|
|
||
| export const useTimeLineChart = (timeLineType: ETimeLineTypeType): IBaseTimelineStore => { | ||
|
|
@@ -13,7 +14,9 @@ export const useTimeLineChart = (timeLineType: ETimeLineTypeType): IBaseTimeline | |
| case ETimeLineTypeType.ISSUE: | ||
| return context.timelineStore.issuesTimeLineStore; | ||
| case ETimeLineTypeType.MODULE: | ||
| return context.timelineStore.modulesTimeLineStore; | ||
| return context.timelineStore.modulesTimeLineStore as IBaseTimelineStore; | ||
| case ETimeLineTypeType.PROJECT: | ||
| return context.timelineStore.projectTimeLineStore as IBaseTimelineStore; | ||
| } | ||
| }; | ||
|
|
||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add observable decorator for isDependencyEnabled.
The
isDependencyEnabledproperty should be marked as observable since it's part of the store's state and might trigger UI updates when changed.Apply this change to the makeObservable call:
makeObservable(this, { // observables blocksMap: observable, blockIds: observable, isDragging: observable.ref, currentView: observable.ref, currentViewData: observable, activeBlockId: observable.ref, renderView: observable, + isDependencyEnabled: observable, // actions setIsDragging: action, setBlockIds: action.bound,Also applies to: 67-85