mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
query params from router as computed
This commit is contained in:
parent
92326def36
commit
2858cbf891
@ -1,21 +1,66 @@
|
||||
import { action, makeObservable, observable } from "mobx";
|
||||
import { ParsedUrlQuery } from "querystring";
|
||||
|
||||
export interface IRouterStore {
|
||||
query: any;
|
||||
setQuery: (query: any) => void;
|
||||
query: ParsedUrlQuery;
|
||||
setQuery: (query: ParsedUrlQuery) => void;
|
||||
|
||||
workspaceSlug: string | undefined;
|
||||
projectId: string | undefined;
|
||||
cycleId: string | undefined;
|
||||
moduleId: string | undefined;
|
||||
viewId: string | undefined;
|
||||
userId: string | undefined;
|
||||
peekId: string | undefined;
|
||||
}
|
||||
|
||||
export class RouterStore implements IRouterStore {
|
||||
query = {};
|
||||
query: ParsedUrlQuery = {};
|
||||
|
||||
constructor() {
|
||||
makeObservable(this, {
|
||||
query: observable,
|
||||
setQuery: action,
|
||||
|
||||
//computed
|
||||
workspaceSlug: action,
|
||||
projectId: action,
|
||||
cycleId: action,
|
||||
moduleId: action,
|
||||
viewId: action,
|
||||
userId: action,
|
||||
peekId: action,
|
||||
});
|
||||
}
|
||||
|
||||
setQuery(query: any) {
|
||||
setQuery(query: ParsedUrlQuery) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
get workspaceSlug() {
|
||||
return this.query?.workspace_slug?.toString();
|
||||
}
|
||||
|
||||
get projectId() {
|
||||
return this.query?.projectId?.toString();
|
||||
}
|
||||
|
||||
get moduleId() {
|
||||
return this.query?.moduleId?.toString();
|
||||
}
|
||||
|
||||
get cycleId() {
|
||||
return this.query?.cycleId?.toString();
|
||||
}
|
||||
|
||||
get viewId() {
|
||||
return this.query?.viewId?.toString();
|
||||
}
|
||||
|
||||
get userId() {
|
||||
return this.query?.userId?.toString();
|
||||
}
|
||||
get peekId() {
|
||||
return this.query?.peekId?.toString();
|
||||
}
|
||||
}
|
||||
|
@ -104,9 +104,9 @@ export class ProjectsStore implements IProjectsStore {
|
||||
}
|
||||
|
||||
get searchedProjects() {
|
||||
if (!this.rootStore.workspace.workspaceSlug) return [];
|
||||
if (!this.rootStore.app.router.query.workspaceSlug) return [];
|
||||
|
||||
const currentProjectsMap = this.projectsMap[this.rootStore.workspace.workspaceSlug];
|
||||
const currentProjectsMap = this.projectsMap[this.rootStore.app.router.query.workspaceSlug.toString()];
|
||||
const projectIds = Object.keys(currentProjectsMap);
|
||||
return this.searchQuery === ""
|
||||
? projectIds
|
||||
@ -117,8 +117,8 @@ export class ProjectsStore implements IProjectsStore {
|
||||
}
|
||||
|
||||
get workspaceProjects() {
|
||||
if (!this.rootStore.workspace.workspaceSlug) return null;
|
||||
const currentProjectsMap = this.projectsMap[this.rootStore.workspace.workspaceSlug];
|
||||
if (!this.rootStore.app.router.workspaceSlug) return null;
|
||||
const currentProjectsMap = this.projectsMap[this.rootStore.app.router.query.workspaceSlug.toString()];
|
||||
|
||||
const projectIds = Object.keys(currentProjectsMap);
|
||||
if (!projectIds) return null;
|
||||
@ -126,8 +126,8 @@ export class ProjectsStore implements IProjectsStore {
|
||||
}
|
||||
|
||||
get currentProjectDetails() {
|
||||
if (!this.projectId || !this.rootStore.workspace.workspaceSlug) return;
|
||||
return this.projectsMap[this.rootStore.workspace.workspaceSlug][this.projectId];
|
||||
if (!this.rootStore.app.router.query.projectId || !this.rootStore.app.router.query.workspaceSlug) return;
|
||||
return this.projectsMap[!this.rootStore.app.router.query.workspaceSlug][this.projectId];
|
||||
}
|
||||
|
||||
get joinedProjects() {
|
||||
|
Loading…
Reference in New Issue
Block a user