plane/web/store/view/root.store.ts

85 lines
2.2 KiB
TypeScript
Raw Normal View History

// stores
import { autorun, makeObservable, observable } from "mobx";
import { ViewRootStore } from "./view-root.store";
2024-01-30 08:56:59 +00:00
// services
2024-02-02 08:22:38 +00:00
import {
WorkspacePrivateViewService,
WorkspacePublicViewService,
ProjectPublicViewService,
ProjectPrivateViewService,
2024-02-02 08:22:38 +00:00
WorkspaceFiltersService,
ProjectFiltersService,
} from "services/view";
2024-01-30 08:56:59 +00:00
// types
import { RootStore } from "store/root.store";
2024-02-02 08:22:38 +00:00
export class GlobalViewRootStore {
workspacePrivateViewStore: ViewRootStore;
workspacePublicViewStore: ViewRootStore;
projectPrivateViewStore: ViewRootStore;
projectPublicViewStore: ViewRootStore;
2024-01-30 08:56:59 +00:00
constructor(private store: RootStore) {
const workspacePrivateDefaultViews: any[] = [
2024-02-05 14:39:17 +00:00
{
id: "assigned",
name: "Assigned",
filters: {
assignees: store?.user?.currentUser?.id ? [store?.user?.currentUser?.id] : [],
2024-02-05 14:39:17 +00:00
},
is_local_view: true,
},
{
id: "created",
name: "Created",
filters: {
created_by: store?.user?.currentUser?.id ? [store?.user?.currentUser?.id] : [],
2024-02-05 14:39:17 +00:00
},
is_local_view: true,
},
{
id: "subscribed",
name: "Subscribed",
filters: {
subscriber: store?.user?.currentUser?.id ? [store?.user?.currentUser?.id] : [],
2024-02-05 14:39:17 +00:00
},
is_local_view: true,
},
];
const workspacePublicDefaultViews: any[] = [
{
id: "all-issues",
name: "All Issues",
filters: {},
is_local_view: true,
},
];
2024-02-05 14:39:17 +00:00
this.workspacePrivateViewStore = new ViewRootStore(
this.store,
workspacePrivateDefaultViews,
new WorkspacePrivateViewService(),
new WorkspaceFiltersService()
2024-02-02 08:22:38 +00:00
);
this.workspacePublicViewStore = new ViewRootStore(
this.store,
workspacePublicDefaultViews,
new WorkspacePublicViewService(),
new WorkspaceFiltersService()
2024-02-02 08:22:38 +00:00
);
this.projectPrivateViewStore = new ViewRootStore(
this.store,
undefined,
new ProjectPrivateViewService(),
new ProjectFiltersService()
2024-02-02 08:22:38 +00:00
);
this.projectPublicViewStore = new ViewRootStore(
this.store,
undefined,
new ProjectPublicViewService(),
new ProjectFiltersService()
2024-02-02 08:22:38 +00:00
);
2024-01-30 08:56:59 +00:00
}
}