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

90 lines
2.3 KiB
TypeScript

// stores
import { ViewRootStore } from "./view-root.store";
// services
import {
WorkspacePrivateViewService,
WorkspacePublicViewService,
ProjectPublicViewService,
ProjectPrivateViewService,
WorkspaceFiltersService,
ProjectFiltersService,
} from "services/view";
// types
import { RootStore } from "store/root.store";
// constants
import { EViewPageType } from "constants/view";
export class GlobalViewRootStore {
workspacePrivateViewStore: ViewRootStore;
workspacePublicViewStore: ViewRootStore;
projectPrivateViewStore: ViewRootStore;
projectPublicViewStore: ViewRootStore;
constructor(private store: RootStore) {
const workspacePrivateDefaultViews: any[] = [
{
id: "assigned",
name: "Assigned",
filters: {
assignees: store?.user?.currentUser?.id ? [store?.user?.currentUser?.id] : [],
},
is_local_view: true,
},
{
id: "created",
name: "Created",
filters: {
created_by: store?.user?.currentUser?.id ? [store?.user?.currentUser?.id] : [],
},
is_local_view: true,
},
{
id: "subscribed",
name: "Subscribed",
filters: {
subscriber: store?.user?.currentUser?.id ? [store?.user?.currentUser?.id] : [],
},
is_local_view: true,
},
];
const workspacePublicDefaultViews: any[] = [
{
id: "all-issues",
name: "All Issues",
filters: {},
is_local_view: true,
},
];
this.workspacePrivateViewStore = new ViewRootStore(
this.store,
workspacePrivateDefaultViews,
new WorkspacePrivateViewService(),
new WorkspaceFiltersService(),
EViewPageType.ALL
);
this.workspacePublicViewStore = new ViewRootStore(
this.store,
workspacePublicDefaultViews,
new WorkspacePublicViewService(),
new WorkspaceFiltersService(),
EViewPageType.ALL
);
this.projectPrivateViewStore = new ViewRootStore(
this.store,
undefined,
new ProjectPrivateViewService(),
new ProjectFiltersService(),
EViewPageType.PROJECT
);
this.projectPublicViewStore = new ViewRootStore(
this.store,
undefined,
new ProjectPublicViewService(),
new ProjectFiltersService(),
EViewPageType.PROJECT
);
}
}