refactor: minor store level changes (#6500)
This commit is contained in:
parent
2f2e6626c6
commit
c0b6abc3d5
3 changed files with 12 additions and 13 deletions
|
|
@ -7,7 +7,7 @@ export const IssuesStoreContext = createContext<EIssuesStoreType | undefined>(un
|
||||||
|
|
||||||
export const useIssueStoreType = () => {
|
export const useIssueStoreType = () => {
|
||||||
const storeType = useContext(IssuesStoreContext);
|
const storeType = useContext(IssuesStoreContext);
|
||||||
const { globalViewId, viewId, projectId, cycleId, moduleId, userId, epicId, teamId } = useParams();
|
const { globalViewId, viewId, projectId, cycleId, moduleId, userId, epicId, teamspaceId } = useParams();
|
||||||
|
|
||||||
// If store type exists in context, use that store type
|
// If store type exists in context, use that store type
|
||||||
if (storeType) return storeType;
|
if (storeType) return storeType;
|
||||||
|
|
@ -27,9 +27,9 @@ export const useIssueStoreType = () => {
|
||||||
|
|
||||||
if (projectId) return EIssuesStoreType.PROJECT;
|
if (projectId) return EIssuesStoreType.PROJECT;
|
||||||
|
|
||||||
if (teamId) return EIssuesStoreType.TEAM;
|
if (teamspaceId) return EIssuesStoreType.TEAM;
|
||||||
|
|
||||||
if (teamId && viewId) return EIssuesStoreType.TEAM_VIEW;
|
if (teamspaceId && viewId) return EIssuesStoreType.TEAM_VIEW;
|
||||||
|
|
||||||
return EIssuesStoreType.PROJECT;
|
return EIssuesStoreType.PROJECT;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import {
|
||||||
// root store
|
// root store
|
||||||
import { RootStore } from "@/plane-web/store/root.store";
|
import { RootStore } from "@/plane-web/store/root.store";
|
||||||
import { IWorkspaceMembership } from "@/store/member/workspace-member.store";
|
import { IWorkspaceMembership } from "@/store/member/workspace-member.store";
|
||||||
import { IStateStore, StateStore } from "../state.store";
|
|
||||||
// issues data store
|
// issues data store
|
||||||
import { IArchivedIssuesFilter, ArchivedIssuesFilter, IArchivedIssues, ArchivedIssues } from "./archived";
|
import { IArchivedIssuesFilter, ArchivedIssuesFilter, IArchivedIssues, ArchivedIssues } from "./archived";
|
||||||
import { ICycleIssuesFilter, CycleIssuesFilter, ICycleIssues, CycleIssues } from "./cycle";
|
import { ICycleIssuesFilter, CycleIssuesFilter, ICycleIssues, CycleIssues } from "./cycle";
|
||||||
|
|
@ -44,7 +43,7 @@ import {
|
||||||
export interface IIssueRootStore {
|
export interface IIssueRootStore {
|
||||||
currentUserId: string | undefined;
|
currentUserId: string | undefined;
|
||||||
workspaceSlug: string | undefined;
|
workspaceSlug: string | undefined;
|
||||||
teamId: string | undefined;
|
teamspaceId: string | undefined;
|
||||||
projectId: string | undefined;
|
projectId: string | undefined;
|
||||||
cycleId: string | undefined;
|
cycleId: string | undefined;
|
||||||
moduleId: string | undefined;
|
moduleId: string | undefined;
|
||||||
|
|
@ -112,7 +111,7 @@ export interface IIssueRootStore {
|
||||||
export class IssueRootStore implements IIssueRootStore {
|
export class IssueRootStore implements IIssueRootStore {
|
||||||
currentUserId: string | undefined = undefined;
|
currentUserId: string | undefined = undefined;
|
||||||
workspaceSlug: string | undefined = undefined;
|
workspaceSlug: string | undefined = undefined;
|
||||||
teamId: string | undefined = undefined;
|
teamspaceId: string | undefined = undefined;
|
||||||
projectId: string | undefined = undefined;
|
projectId: string | undefined = undefined;
|
||||||
cycleId: string | undefined = undefined;
|
cycleId: string | undefined = undefined;
|
||||||
moduleId: string | undefined = undefined;
|
moduleId: string | undefined = undefined;
|
||||||
|
|
@ -179,7 +178,7 @@ export class IssueRootStore implements IIssueRootStore {
|
||||||
constructor(rootStore: RootStore, serviceType: TIssueServiceType = EIssueServiceType.ISSUES) {
|
constructor(rootStore: RootStore, serviceType: TIssueServiceType = EIssueServiceType.ISSUES) {
|
||||||
makeObservable(this, {
|
makeObservable(this, {
|
||||||
workspaceSlug: observable.ref,
|
workspaceSlug: observable.ref,
|
||||||
teamId: observable.ref,
|
teamspaceId: observable.ref,
|
||||||
projectId: observable.ref,
|
projectId: observable.ref,
|
||||||
cycleId: observable.ref,
|
cycleId: observable.ref,
|
||||||
moduleId: observable.ref,
|
moduleId: observable.ref,
|
||||||
|
|
@ -203,7 +202,7 @@ export class IssueRootStore implements IIssueRootStore {
|
||||||
autorun(() => {
|
autorun(() => {
|
||||||
if (rootStore?.user?.data?.id) this.currentUserId = rootStore?.user?.data?.id;
|
if (rootStore?.user?.data?.id) this.currentUserId = rootStore?.user?.data?.id;
|
||||||
if (this.workspaceSlug !== rootStore.router.workspaceSlug) this.workspaceSlug = rootStore.router.workspaceSlug;
|
if (this.workspaceSlug !== rootStore.router.workspaceSlug) this.workspaceSlug = rootStore.router.workspaceSlug;
|
||||||
if (this.teamId !== rootStore.router.teamId) this.teamId = rootStore.router.teamId;
|
if (this.teamspaceId !== rootStore.router.teamspaceId) this.teamspaceId = rootStore.router.teamspaceId;
|
||||||
if (this.projectId !== rootStore.router.projectId) this.projectId = rootStore.router.projectId;
|
if (this.projectId !== rootStore.router.projectId) this.projectId = rootStore.router.projectId;
|
||||||
if (this.cycleId !== rootStore.router.cycleId) this.cycleId = rootStore.router.cycleId;
|
if (this.cycleId !== rootStore.router.cycleId) this.cycleId = rootStore.router.cycleId;
|
||||||
if (this.moduleId !== rootStore.router.moduleId) this.moduleId = rootStore.router.moduleId;
|
if (this.moduleId !== rootStore.router.moduleId) this.moduleId = rootStore.router.moduleId;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ export interface IRouterStore {
|
||||||
setQuery: (query: ParsedUrlQuery) => void;
|
setQuery: (query: ParsedUrlQuery) => void;
|
||||||
// computed
|
// computed
|
||||||
workspaceSlug: string | undefined;
|
workspaceSlug: string | undefined;
|
||||||
teamId: string | undefined;
|
teamspaceId: string | undefined;
|
||||||
projectId: string | undefined;
|
projectId: string | undefined;
|
||||||
cycleId: string | undefined;
|
cycleId: string | undefined;
|
||||||
moduleId: string | undefined;
|
moduleId: string | undefined;
|
||||||
|
|
@ -36,7 +36,7 @@ export class RouterStore implements IRouterStore {
|
||||||
setQuery: action.bound,
|
setQuery: action.bound,
|
||||||
//computed
|
//computed
|
||||||
workspaceSlug: computed,
|
workspaceSlug: computed,
|
||||||
teamId: computed,
|
teamspaceId: computed,
|
||||||
projectId: computed,
|
projectId: computed,
|
||||||
cycleId: computed,
|
cycleId: computed,
|
||||||
moduleId: computed,
|
moduleId: computed,
|
||||||
|
|
@ -71,11 +71,11 @@ export class RouterStore implements IRouterStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the team id from the query
|
* Returns the teamspace id from the query
|
||||||
* @returns string|undefined
|
* @returns string|undefined
|
||||||
*/
|
*/
|
||||||
get teamId() {
|
get teamspaceId() {
|
||||||
return this.query?.teamId?.toString();
|
return this.query?.teamspaceId?.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue