plane/web/store/application/router.store.ts

86 lines
1.7 KiB
TypeScript
Raw Normal View History

2023-12-12 08:56:45 +00:00
import { action, computed, makeObservable, observable } from "mobx";
2023-12-12 07:39:30 +00:00
import { ParsedUrlQuery } from "querystring";
2023-12-11 14:45:07 +00:00
export interface IRouterStore {
2023-12-12 07:39:30 +00:00
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;
2023-12-12 08:56:45 +00:00
issueId: string | undefined;
inboxId: string | undefined;
webhookId: string | undefined;
2023-12-11 14:45:07 +00:00
}
export class RouterStore implements IRouterStore {
2023-12-12 07:39:30 +00:00
query: ParsedUrlQuery = {};
2023-12-11 14:45:07 +00:00
constructor() {
makeObservable(this, {
query: observable,
setQuery: action,
2023-12-12 07:39:30 +00:00
//computed
2023-12-12 08:56:45 +00:00
workspaceSlug: computed,
projectId: computed,
cycleId: computed,
moduleId: computed,
viewId: computed,
userId: computed,
peekId: computed,
issueId: computed,
inboxId: computed,
webhookId: computed,
2023-12-11 14:45:07 +00:00
});
}
2023-12-12 07:39:30 +00:00
setQuery(query: ParsedUrlQuery) {
2023-12-11 14:45:07 +00:00
this.query = query;
}
2023-12-12 07:39:30 +00:00
get workspaceSlug() {
2023-12-12 08:56:45 +00:00
return this.query?.workspaceSlug?.toString();
2023-12-12 07:39:30 +00:00
}
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();
}
2023-12-12 08:56:45 +00:00
2023-12-12 07:39:30 +00:00
get peekId() {
return this.query?.peekId?.toString();
}
2023-12-12 08:56:45 +00:00
get issueId() {
return this.query?.issueId?.toString();
}
get inboxId() {
return this.query?.inboxId?.toString();
}
get webhookId() {
return this.query?.webhookId?.toString();
}
2023-12-11 14:45:07 +00:00
}