mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
Merge branch 'refactor/mobx-store' of github.com:makeplane/plane into refactor/mobx-store
This commit is contained in:
commit
91452dc0bc
@ -1,12 +1,10 @@
|
|||||||
// mobx
|
// mobx
|
||||||
import { action, observable, runInAction, makeObservable, computed } from "mobx";
|
import { action, observable, runInAction, makeObservable, computed } from "mobx";
|
||||||
// services
|
// services
|
||||||
import { ProjectMemberService, ProjectService } from "services/project";
|
import { ProjectMemberService } from "services/project";
|
||||||
import { UserService } from "services/user.service";
|
import { UserService } from "services/user.service";
|
||||||
import { WorkspaceService } from "services/workspace.service";
|
import { WorkspaceService } from "services/workspace.service";
|
||||||
import { AuthService } from "services/auth.service";
|
|
||||||
// interfaces
|
// interfaces
|
||||||
import { IUser, IUserSettings } from "types/users";
|
|
||||||
import { IWorkspaceMemberMe, IProjectMember, TUserProjectRole, TUserWorkspaceRole } from "types";
|
import { IWorkspaceMemberMe, IProjectMember, TUserProjectRole, TUserWorkspaceRole } from "types";
|
||||||
import { RootStore } from "../root.store";
|
import { RootStore } from "../root.store";
|
||||||
|
|
||||||
@ -53,14 +51,12 @@ export class UserMembershipStore implements IUserMembershipStore {
|
|||||||
hasPermissionToProject: {
|
hasPermissionToProject: {
|
||||||
[projectId: string]: boolean;
|
[projectId: string]: boolean;
|
||||||
} = {};
|
} = {};
|
||||||
// root store
|
// stores
|
||||||
rootStore;
|
router;
|
||||||
// services
|
// services
|
||||||
userService;
|
userService;
|
||||||
workspaceService;
|
workspaceService;
|
||||||
projectService;
|
|
||||||
projectMemberService;
|
projectMemberService;
|
||||||
authService;
|
|
||||||
|
|
||||||
constructor(_rootStore: RootStore) {
|
constructor(_rootStore: RootStore) {
|
||||||
makeObservable(this, {
|
makeObservable(this, {
|
||||||
@ -83,42 +79,41 @@ export class UserMembershipStore implements IUserMembershipStore {
|
|||||||
hasPermissionToCurrentWorkspace: computed,
|
hasPermissionToCurrentWorkspace: computed,
|
||||||
hasPermissionToCurrentProject: computed,
|
hasPermissionToCurrentProject: computed,
|
||||||
});
|
});
|
||||||
this.rootStore = _rootStore;
|
this.router = _rootStore.app.router;
|
||||||
|
// services
|
||||||
this.userService = new UserService();
|
this.userService = new UserService();
|
||||||
this.workspaceService = new WorkspaceService();
|
this.workspaceService = new WorkspaceService();
|
||||||
this.projectService = new ProjectService();
|
|
||||||
this.projectMemberService = new ProjectMemberService();
|
this.projectMemberService = new ProjectMemberService();
|
||||||
this.authService = new AuthService();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get currentWorkspaceMemberInfo() {
|
get currentWorkspaceMemberInfo() {
|
||||||
if (!this.rootStore.workspace.workspaceSlug) return;
|
if (!this.router.query?.workspaceSlug) return;
|
||||||
return this.workspaceMemberInfo[this.rootStore.workspace.workspaceSlug];
|
return this.workspaceMemberInfo[this.router.query?.workspaceSlug];
|
||||||
}
|
}
|
||||||
|
|
||||||
get currentWorkspaceRole() {
|
get currentWorkspaceRole() {
|
||||||
if (!this.rootStore.workspace.workspaceSlug) return;
|
if (!this.router.query?.workspaceSlug) return;
|
||||||
return this.workspaceMemberInfo[this.rootStore.workspace.workspaceSlug]?.role;
|
return this.workspaceMemberInfo[this.router.query?.workspaceSlug]?.role;
|
||||||
}
|
}
|
||||||
|
|
||||||
get currentProjectMemberInfo() {
|
get currentProjectMemberInfo() {
|
||||||
if (!this.rootStore.project.projectId) return;
|
if (!this.router.query?.projectId) return;
|
||||||
return this.projectMemberInfo[this.rootStore.project.projectId];
|
return this.projectMemberInfo[this.router.query?.projectId];
|
||||||
}
|
}
|
||||||
|
|
||||||
get currentProjectRole() {
|
get currentProjectRole() {
|
||||||
if (!this.rootStore.project.projectId) return;
|
if (!this.router.query?.projectId) return;
|
||||||
return this.projectMemberInfo[this.rootStore.project.projectId]?.role;
|
return this.projectMemberInfo[this.router.query?.projectId]?.role;
|
||||||
}
|
}
|
||||||
|
|
||||||
get hasPermissionToCurrentWorkspace() {
|
get hasPermissionToCurrentWorkspace() {
|
||||||
if (!this.rootStore.workspace.workspaceSlug) return;
|
if (!this.router.query?.workspaceSlug) return;
|
||||||
return this.hasPermissionToWorkspace[this.rootStore.workspace.workspaceSlug];
|
return this.hasPermissionToWorkspace[this.router.query?.workspaceSlug];
|
||||||
}
|
}
|
||||||
|
|
||||||
get hasPermissionToCurrentProject() {
|
get hasPermissionToCurrentProject() {
|
||||||
if (!this.rootStore.project.projectId) return;
|
if (!this.router.query?.projectId) return;
|
||||||
return this.hasPermissionToProject[this.rootStore.project.projectId];
|
return this.hasPermissionToProject[this.router.query?.projectId];
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchUserWorkspaceInfo = async (workspaceSlug: string) => {
|
fetchUserWorkspaceInfo = async (workspaceSlug: string) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user