plane/web/store/application/router.store.ts
rahulramesha b3ac9def8d
fix: issue property dropdown data flow (#3425)
* dev: workspace states and estimates

* refactor issue dropdown logic to help work properly with issues on global level

* fix: project labels response change

* fix label type

* change store computed actions to computed functions from mobx-utils

* fix: state response change

* chore: project and workspace state change

* fix state and label types

* chore: state and label serializer change

* modify state and label types

* fix dropdown reset on project id change

* fix label sort order

---------

Co-authored-by: pablohashescobar <nikhilschacko@gmail.com>
Co-authored-by: Rahul R <rahulr@Rahuls-MacBook-Pro.local>
Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
Co-authored-by: Rahul R <rahul.ramesha@plane.so>
2024-01-22 17:07:32 +05:30

146 lines
3.0 KiB
TypeScript

import { action, makeObservable, observable, computed, runInAction } from "mobx";
import { ParsedUrlQuery } from "node:querystring";
export interface IRouterStore {
// observables
query: ParsedUrlQuery;
// actions
setQuery: (query: ParsedUrlQuery) => void;
// computed
workspaceSlug: string | undefined;
projectId: string | undefined;
cycleId: string | undefined;
moduleId: string | undefined;
viewId: string | undefined;
globalViewId: string | undefined;
userId: string | undefined;
peekId: string | undefined;
issueId: string | undefined;
inboxId: string | undefined;
webhookId: string | undefined;
}
export class RouterStore implements IRouterStore {
// observables
query: ParsedUrlQuery = {};
constructor() {
makeObservable(this, {
// observables
query: observable,
// actions
setQuery: action.bound,
//computed
workspaceSlug: computed,
projectId: computed,
cycleId: computed,
moduleId: computed,
viewId: computed,
globalViewId: computed,
userId: computed,
peekId: computed,
issueId: computed,
inboxId: computed,
webhookId: computed,
});
}
/**
* Sets the query
* @param query
*/
setQuery = (query: ParsedUrlQuery) => {
runInAction(() => {
this.query = query;
});
};
/**
* Returns the workspace slug from the query
* @returns string|undefined
*/
get workspaceSlug() {
return this.query?.workspaceSlug?.toString();
}
/**
* Returns the project id from the query
* @returns string|undefined
*/
get projectId() {
return this.query?.projectId?.toString();
}
/**
* Returns the module id from the query
* @returns string|undefined
*/
get moduleId() {
return this.query?.moduleId?.toString();
}
/**
* Returns the cycle id from the query
* @returns string|undefined
*/
get cycleId() {
return this.query?.cycleId?.toString();
}
/**
* Returns the view id from the query
* @returns string|undefined
*/
get viewId() {
return this.query?.viewId?.toString();
}
/**
* Returns the global view id from the query
* @returns string|undefined
*/
get globalViewId() {
return this.query?.globalViewId?.toString();
}
/**
* Returns the user id from the query
* @returns string|undefined
*/
get userId() {
return this.query?.userId?.toString();
}
/**
* Returns the peek id from the query
* @returns string|undefined
*/
get peekId() {
return this.query?.peekId?.toString();
}
/**
* Returns the issue id from the query
* @returns string|undefined
*/
get issueId() {
return this.query?.issueId?.toString();
}
/**
* Returns the inbox id from the query
* @returns string|undefined
*/
get inboxId() {
return this.query?.inboxId?.toString();
}
/**
* Returns the webhook id from the query
* @returns string|undefined
*/
get webhookId() {
return this.query?.webhookId?.toString();
}
}