Merge branch 'chore/project-entities' of github.com:makeplane/plane into chore/project-entities

This commit is contained in:
NarayanBavisetti 2024-01-22 14:44:09 +05:30
commit 6be2b3b8c5
21 changed files with 64 additions and 90 deletions

View File

@ -109,17 +109,10 @@ export type IssuePriorities = {
export interface IIssueLabel { export interface IIssueLabel {
id: string; id: string;
created_at: Date;
updated_at: Date;
name: string; name: string;
description: string;
color: string; color: string;
created_by: string; project_id: string;
updated_by: string; workspace__slug: string;
project: string;
project_detail: IProjectLite;
workspace: string;
workspace_detail: IWorkspaceLite;
parent: string | null; parent: string | null;
sort_order: number; sort_order: number;
} }

View File

@ -5,20 +5,13 @@ export type TStateGroups = "backlog" | "unstarted" | "started" | "completed" | "
export interface IState { export interface IState {
readonly id: string; readonly id: string;
color: string; color: string;
readonly created_at: Date;
readonly created_by: string;
default: boolean; default: boolean;
description: string; description: string;
group: TStateGroups; group: TStateGroups;
name: string; name: string;
project: string; project_id: string;
readonly project_detail: IProjectLite;
sequence: number; sequence: number;
readonly slug: string; workspace__slug: string;
readonly updated_at: Date;
readonly updated_by: string;
workspace: string;
workspace_detail: IWorkspaceLite;
} }
export interface IStateLite { export interface IStateLite {

View File

@ -58,9 +58,10 @@ export const IssuePropertyLabels: React.FC<IIssuePropertyLabels> = observer((pro
const storeLabels = getProjectLabels(projectId); const storeLabels = getProjectLabels(projectId);
const openDropDown = () => { const openDropDown = () => {
if (!storeLabels && workspaceSlug && projectId) {
setIsLoading(true); setIsLoading(true);
if (!storeLabels && workspaceSlug && projectId)
fetchProjectLabels(workspaceSlug, projectId).then(() => setIsLoading(false)); fetchProjectLabels(workspaceSlug, projectId).then(() => setIsLoading(false));
}
}; };
const { styles, attributes } = usePopper(referenceElement, popperElement, { const { styles, attributes } = usePopper(referenceElement, popperElement, {

View File

@ -42,7 +42,7 @@ export const DeleteStateModal: React.FC<Props> = observer((props) => {
setIsDeleteLoading(true); setIsDeleteLoading(true);
await deleteState(workspaceSlug.toString(), data.project, data.id) await deleteState(workspaceSlug.toString(), data.project_id, data.id)
.then(() => { .then(() => {
postHogEventTracker("STATE_DELETE", { postHogEventTracker("STATE_DELETE", {
state: "SUCCESS", state: "SUCCESS",

View File

@ -19,7 +19,7 @@ export class EventTrackerStore implements IEventTrackerStore {
constructor(_rootStore: RootStore) { constructor(_rootStore: RootStore) {
makeObservable(this, { makeObservable(this, {
trackElement: observable, trackElement: observable,
setTrackElement: action, setTrackElement: action.bound,
postHogEventTracker: action, postHogEventTracker: action,
}); });
this.rootStore = _rootStore; this.rootStore = _rootStore;

View File

@ -29,7 +29,7 @@ export class RouterStore implements IRouterStore {
// observables // observables
query: observable, query: observable,
// actions // actions
setQuery: action, setQuery: action.bound,
//computed //computed
workspaceSlug: computed, workspaceSlug: computed,
projectId: computed, projectId: computed,

View File

@ -1,4 +1,5 @@
import { action, computed, observable, makeObservable, runInAction } from "mobx"; import { action, computed, observable, makeObservable, runInAction } from "mobx";
import { computedFn } from "mobx-utils";
import { isFuture, isPast } from "date-fns"; import { isFuture, isPast } from "date-fns";
import set from "lodash/set"; import set from "lodash/set";
import sortBy from "lodash/sortBy"; import sortBy from "lodash/sortBy";
@ -74,10 +75,6 @@ export class CycleStore implements ICycleStore {
currentProjectIncompleteCycleIds: computed, currentProjectIncompleteCycleIds: computed,
currentProjectDraftCycleIds: computed, currentProjectDraftCycleIds: computed,
currentProjectActiveCycleId: computed, currentProjectActiveCycleId: computed,
// computed actions
getCycleById: action,
getActiveCycleById: action,
getProjectCycleIds: action,
// actions // actions
fetchAllCycles: action, fetchAllCycles: action,
fetchActiveCycle: action, fetchActiveCycle: action,
@ -184,28 +181,29 @@ export class CycleStore implements ICycleStore {
* @param cycleId * @param cycleId
* @returns * @returns
*/ */
getCycleById = (cycleId: string): ICycle | null => this.cycleMap?.[cycleId] ?? null; getCycleById = computedFn((cycleId: string): ICycle | null => this.cycleMap?.[cycleId] ?? null);
/** /**
* @description returns active cycle details by cycle id * @description returns active cycle details by cycle id
* @param cycleId * @param cycleId
* @returns * @returns
*/ */
getActiveCycleById = (cycleId: string): ICycle | null => getActiveCycleById = computedFn((cycleId: string): ICycle | null =>
this.activeCycleIdMap?.[cycleId] && this.cycleMap?.[cycleId] ? this.cycleMap?.[cycleId] : null; this.activeCycleIdMap?.[cycleId] && this.cycleMap?.[cycleId] ? this.cycleMap?.[cycleId] : null
);
/** /**
* @description returns list of cycle ids of the project id passed as argument * @description returns list of cycle ids of the project id passed as argument
* @param projectId * @param projectId
*/ */
getProjectCycleIds = (projectId: string): string[] | null => { getProjectCycleIds = computedFn((projectId: string): string[] | null => {
if (!this.fetchedMap[projectId]) return null; if (!this.fetchedMap[projectId]) return null;
let cycles = Object.values(this.cycleMap ?? {}).filter((c) => c.project === projectId); let cycles = Object.values(this.cycleMap ?? {}).filter((c) => c.project === projectId);
cycles = sortBy(cycles, [(c) => !c.is_favorite, (c) => c.name.toLowerCase()]); cycles = sortBy(cycles, [(c) => !c.is_favorite, (c) => c.name.toLowerCase()]);
const cycleIds = cycles.map((c) => c.id); const cycleIds = cycles.map((c) => c.id);
return cycleIds || null; return cycleIds || null;
}; });
/** /**
* @description validates cycle dates * @description validates cycle dates

View File

@ -1,4 +1,5 @@
import { action, computed, makeObservable, observable, runInAction } from "mobx"; import { action, computed, makeObservable, observable, runInAction } from "mobx";
import { computedFn } from "mobx-utils";
import set from "lodash/set"; import set from "lodash/set";
// services // services
import { DashboardService } from "services/dashboard.service"; import { DashboardService } from "services/dashboard.service";
@ -74,8 +75,6 @@ export class DashboardStore implements IDashboardStore {
widgetStats: observable, widgetStats: observable,
// computed // computed
homeDashboardWidgets: computed, homeDashboardWidgets: computed,
// computed actions
getWidgetDetails: action,
// fetch actions // fetch actions
fetchHomeDashboardWidgets: action, fetchHomeDashboardWidgets: action,
fetchWidgetStats: action, fetchWidgetStats: action,
@ -109,11 +108,11 @@ export class DashboardStore implements IDashboardStore {
* @param widgetId * @param widgetId
* @returns widget details * @returns widget details
*/ */
getWidgetDetails = (workspaceSlug: string, dashboardId: string, widgetKey: TWidgetKeys) => { getWidgetDetails = computedFn((workspaceSlug: string, dashboardId: string, widgetKey: TWidgetKeys) => {
const widgets = this.widgetDetails?.[workspaceSlug]?.[dashboardId]; const widgets = this.widgetDetails?.[workspaceSlug]?.[dashboardId];
if (!widgets) return undefined; if (!widgets) return undefined;
return widgets.find((widget) => widget.key === widgetKey); return widgets.find((widget) => widget.key === widgetKey);
}; });
/** /**
* @description fetch home dashboard details and widgets * @description fetch home dashboard details and widgets

View File

@ -1,4 +1,5 @@
import { observable, action, makeObservable, runInAction, computed } from "mobx"; import { observable, action, makeObservable, runInAction, computed } from "mobx";
import { computedFn } from "mobx-utils";
import { set } from "lodash"; import { set } from "lodash";
// services // services
import { WorkspaceService } from "services/workspace.service"; import { WorkspaceService } from "services/workspace.service";
@ -37,9 +38,6 @@ export class GlobalViewStore implements IGlobalViewStore {
globalViewMap: observable, globalViewMap: observable,
// computed // computed
currentWorkspaceViews: computed, currentWorkspaceViews: computed,
// computed actions
getSearchedViews: action,
getViewDetailsById: action,
// actions // actions
fetchAllGlobalViews: action, fetchAllGlobalViews: action,
fetchGlobalViewDetails: action, fetchGlobalViewDetails: action,
@ -73,7 +71,7 @@ export class GlobalViewStore implements IGlobalViewStore {
* @param searchQuery * @param searchQuery
* @returns * @returns
*/ */
getSearchedViews = (searchQuery: string) => { getSearchedViews = computedFn((searchQuery: string) => {
const currentWorkspaceDetails = this.rootStore.workspaceRoot.currentWorkspace; const currentWorkspaceDetails = this.rootStore.workspaceRoot.currentWorkspace;
if (!currentWorkspaceDetails) return null; if (!currentWorkspaceDetails) return null;
@ -84,13 +82,13 @@ export class GlobalViewStore implements IGlobalViewStore {
this.globalViewMap[viewId]?.name?.toLowerCase().includes(searchQuery.toLowerCase()) this.globalViewMap[viewId]?.name?.toLowerCase().includes(searchQuery.toLowerCase())
) ?? null ) ?? null
); );
}; });
/** /**
* @description returns view details for given viewId * @description returns view details for given viewId
* @param viewId * @param viewId
*/ */
getViewDetailsById = (viewId: string): IWorkspaceView | null => this.globalViewMap[viewId] ?? null; getViewDetailsById = computedFn((viewId: string): IWorkspaceView | null => this.globalViewMap[viewId] ?? null);
/** /**
* @description fetch all global views for given workspace * @description fetch all global views for given workspace

View File

@ -1,4 +1,5 @@
import { observable, action, makeObservable, runInAction, computed } from "mobx"; import { observable, action, makeObservable, runInAction, computed } from "mobx";
import { computedFn } from "mobx-utils";
import { set } from "lodash"; import { set } from "lodash";
// services // services
import { InboxService } from "services/inbox.service"; import { InboxService } from "services/inbox.service";
@ -43,8 +44,6 @@ export class InboxStore implements IInboxStore {
inboxDetails: observable, inboxDetails: observable,
// computed // computed
isInboxEnabled: computed, isInboxEnabled: computed,
// computed actions
getInboxId: action,
// actions // actions
fetchInboxesList: action, fetchInboxesList: action,
}); });
@ -69,11 +68,11 @@ export class InboxStore implements IInboxStore {
/** /**
* Returns the inbox Id belongs to a specific project * Returns the inbox Id belongs to a specific project
*/ */
getInboxId = (projectId: string) => { getInboxId = computedFn((projectId: string) => {
const projectDetails = this.rootStore.projectRoot.project.getProjectById(projectId); const projectDetails = this.rootStore.projectRoot.project.getProjectById(projectId);
if (!projectDetails || !projectDetails.inbox_view) return null; if (!projectDetails || !projectDetails.inbox_view) return null;
return this.inboxesList[projectId]?.[0]?.id ?? null; return this.inboxesList[projectId]?.[0]?.id ?? null;
}; });
/** /**
* Fetches the inboxes list belongs to a specific project * Fetches the inboxes list belongs to a specific project

View File

@ -1,4 +1,5 @@
import { observable, action, makeObservable, runInAction, autorun, computed } from "mobx"; import { observable, action, makeObservable, runInAction, autorun, computed } from "mobx";
import { computedFn } from "mobx-utils";
import { set } from "lodash"; import { set } from "lodash";
// services // services
import { InboxService } from "services/inbox.service"; import { InboxService } from "services/inbox.service";
@ -61,8 +62,6 @@ export class InboxIssuesStore implements IInboxIssuesStore {
issueMap: observable, issueMap: observable,
// computed // computed
currentInboxIssueIds: computed, currentInboxIssueIds: computed,
// computed actions
getIssueById: action,
// fetch actions // fetch actions
fetchIssues: action, fetchIssues: action,
fetchIssueDetails: action, fetchIssueDetails: action,
@ -99,7 +98,9 @@ export class InboxIssuesStore implements IInboxIssuesStore {
/** /**
* Returns the issue details belongs to a specific inbox issue * Returns the issue details belongs to a specific inbox issue
*/ */
getIssueById = (inboxId: string, issueId: string): IInboxIssue | null => this.issueMap?.[inboxId]?.[issueId] ?? null; getIssueById = computedFn(
(inboxId: string, issueId: string): IInboxIssue | null => this.issueMap?.[inboxId]?.[issueId] ?? null
);
/** /**
* Fetches issues of a specific inbox and adds it to the store * Fetches issues of a specific inbox and adds it to the store

View File

@ -2,6 +2,7 @@ import set from "lodash/set";
import isEmpty from "lodash/isEmpty"; import isEmpty from "lodash/isEmpty";
// store // store
import { action, makeObservable, observable, runInAction } from "mobx"; import { action, makeObservable, observable, runInAction } from "mobx";
import { computedFn } from "mobx-utils";
// types // types
import { TIssue } from "@plane/types"; import { TIssue } from "@plane/types";
@ -80,17 +81,17 @@ export class IssueStore implements IIssueStore {
* @param {string} issueId * @param {string} issueId
* @returns {TIssue | undefined} * @returns {TIssue | undefined}
*/ */
getIssueById = (issueId: string) => { getIssueById = computedFn((issueId: string) => {
if (!issueId || isEmpty(this.issuesMap) || !this.issuesMap[issueId]) return undefined; if (!issueId || isEmpty(this.issuesMap) || !this.issuesMap[issueId]) return undefined;
return this.issuesMap[issueId]; return this.issuesMap[issueId];
}; });
/** /**
* @description This method will return the issues from the issuesMap * @description This method will return the issues from the issuesMap
* @param {string[]} issueIds * @param {string[]} issueIds
* @returns {Record<string, TIssue> | undefined} * @returns {Record<string, TIssue> | undefined}
*/ */
getIssuesByIds = (issueIds: string[]) => { getIssuesByIds = computedFn((issueIds: string[]) => {
if (!issueIds || issueIds.length <= 0 || isEmpty(this.issuesMap)) return undefined; if (!issueIds || issueIds.length <= 0 || isEmpty(this.issuesMap)) return undefined;
const filteredIssues: { [key: string]: TIssue } = {}; const filteredIssues: { [key: string]: TIssue } = {};
Object.values(this.issuesMap).forEach((issue) => { Object.values(this.issuesMap).forEach((issue) => {
@ -99,5 +100,5 @@ export class IssueStore implements IIssueStore {
} }
}); });
return isEmpty(filteredIssues) ? undefined : filteredIssues; return isEmpty(filteredIssues) ? undefined : filteredIssues;
}; });
} }

View File

@ -142,7 +142,7 @@ export class IssueRootStore implements IIssueRootStore {
if (rootStore.app.router.userId) this.userId = rootStore.app.router.userId; if (rootStore.app.router.userId) this.userId = rootStore.app.router.userId;
if (!isEmpty(rootStore?.state?.stateMap)) this.states = Object.keys(rootStore?.state?.stateMap); if (!isEmpty(rootStore?.state?.stateMap)) this.states = Object.keys(rootStore?.state?.stateMap);
if (!isEmpty(rootStore?.state?.projectStates)) this.stateDetails = rootStore?.state?.projectStates; if (!isEmpty(rootStore?.state?.projectStates)) this.stateDetails = rootStore?.state?.projectStates;
if (!isEmpty(rootStore?.labelRoot?.labelMap)) this.labels = Object.keys(rootStore?.labelRoot?.labelMap); if (!isEmpty(rootStore?.label?.labelMap)) this.labels = Object.keys(rootStore?.label?.labelMap);
if (!isEmpty(rootStore?.memberRoot?.workspace?.workspaceMemberMap)) if (!isEmpty(rootStore?.memberRoot?.workspace?.workspaceMemberMap))
this.members = Object.keys(rootStore?.memberRoot?.workspace?.workspaceMemberMap); this.members = Object.keys(rootStore?.memberRoot?.workspace?.workspaceMemberMap);
if (!isEmpty(rootStore?.projectRoot?.project?.projectMap)) if (!isEmpty(rootStore?.projectRoot?.project?.projectMap))

View File

@ -82,7 +82,7 @@ export class LabelStore implements ILabelStore {
const currentWorkspaceDetails = this.rootStore.workspaceRoot.currentWorkspace; const currentWorkspaceDetails = this.rootStore.workspaceRoot.currentWorkspace;
const worksapceSlug = this.rootStore.app.router.workspaceSlug || ""; const worksapceSlug = this.rootStore.app.router.workspaceSlug || "";
if (!currentWorkspaceDetails || !this.fetchedMap[worksapceSlug]) return; if (!currentWorkspaceDetails || !this.fetchedMap[worksapceSlug]) return;
return Object.values(this.labelMap).filter((label) => label.workspace === currentWorkspaceDetails.id); return Object.values(this.labelMap).filter((label) => label.workspace__slug === currentWorkspaceDetails.slug);
} }
/** /**
@ -92,7 +92,7 @@ export class LabelStore implements ILabelStore {
const projectId = this.rootStore.app.router.projectId; const projectId = this.rootStore.app.router.projectId;
const worksapceSlug = this.rootStore.app.router.workspaceSlug || ""; const worksapceSlug = this.rootStore.app.router.workspaceSlug || "";
if (!projectId || !(this.fetchedMap[projectId] || this.fetchedMap[worksapceSlug])) return; if (!projectId || !(this.fetchedMap[projectId] || this.fetchedMap[worksapceSlug])) return;
return Object.values(this.labelMap ?? {}).filter((label) => label.project === projectId); return Object.values(this.labelMap ?? {}).filter((label) => label.project_id === projectId);
} }
/** /**
@ -106,7 +106,7 @@ export class LabelStore implements ILabelStore {
getProjectLabels = computedFn((projectId: string | null) => { getProjectLabels = computedFn((projectId: string | null) => {
const worksapceSlug = this.rootStore.app.router.workspaceSlug || ""; const worksapceSlug = this.rootStore.app.router.workspaceSlug || "";
if (!projectId || !(this.fetchedMap[projectId] || this.fetchedMap[worksapceSlug])) return; if (!projectId || !(this.fetchedMap[projectId] || this.fetchedMap[worksapceSlug])) return;
return Object.values(this.labelMap ?? {}).filter((label) => label.project === projectId); return Object.values(this.labelMap ?? {}).filter((label) => label.project_id === projectId);
}); });
/** /**

View File

@ -1,4 +1,5 @@
import { action, computed, makeObservable, observable, runInAction } from "mobx"; import { action, computed, makeObservable, observable, runInAction } from "mobx";
import { computedFn } from "mobx-utils";
import set from "lodash/set"; import set from "lodash/set";
import sortBy from "lodash/sortBy"; import sortBy from "lodash/sortBy";
// services // services
@ -67,11 +68,6 @@ export class WorkspaceMemberStore implements IWorkspaceMemberStore {
// computed // computed
workspaceMemberIds: computed, workspaceMemberIds: computed,
workspaceMemberInvitationIds: computed, workspaceMemberInvitationIds: computed,
// computed actions
getSearchedWorkspaceMemberIds: action,
getSearchedWorkspaceInvitationIds: action,
getWorkspaceMemberDetails: action,
getWorkspaceInvitationDetails: action,
// actions // actions
fetchWorkspaceMembers: action, fetchWorkspaceMembers: action,
updateMember: action, updateMember: action,
@ -114,7 +110,7 @@ export class WorkspaceMemberStore implements IWorkspaceMemberStore {
* @description get the list of all the user ids that match the search query of all the members of the current workspace * @description get the list of all the user ids that match the search query of all the members of the current workspace
* @param searchQuery * @param searchQuery
*/ */
getSearchedWorkspaceMemberIds = (searchQuery: string) => { getSearchedWorkspaceMemberIds = computedFn((searchQuery: string) => {
const workspaceSlug = this.routerStore.workspaceSlug; const workspaceSlug = this.routerStore.workspaceSlug;
if (!workspaceSlug) return null; if (!workspaceSlug) return null;
const workspaceMemberIds = this.workspaceMemberIds; const workspaceMemberIds = this.workspaceMemberIds;
@ -128,13 +124,13 @@ export class WorkspaceMemberStore implements IWorkspaceMemberStore {
return memberSearchQuery.toLowerCase()?.includes(searchQuery.toLowerCase()); return memberSearchQuery.toLowerCase()?.includes(searchQuery.toLowerCase());
}); });
return searchedWorkspaceMemberIds; return searchedWorkspaceMemberIds;
}; });
/** /**
* @description get the list of all the invitation ids that match the search query of all the member invitations of the current workspace * @description get the list of all the invitation ids that match the search query of all the member invitations of the current workspace
* @param searchQuery * @param searchQuery
*/ */
getSearchedWorkspaceInvitationIds = (searchQuery: string) => { getSearchedWorkspaceInvitationIds = computedFn((searchQuery: string) => {
const workspaceSlug = this.routerStore.workspaceSlug; const workspaceSlug = this.routerStore.workspaceSlug;
if (!workspaceSlug) return null; if (!workspaceSlug) return null;
const workspaceMemberInvitationIds = this.workspaceMemberInvitationIds; const workspaceMemberInvitationIds = this.workspaceMemberInvitationIds;
@ -146,13 +142,13 @@ export class WorkspaceMemberStore implements IWorkspaceMemberStore {
return invitationSearchQuery.toLowerCase()?.includes(searchQuery.toLowerCase()); return invitationSearchQuery.toLowerCase()?.includes(searchQuery.toLowerCase());
}); });
return searchedWorkspaceMemberInvitationIds; return searchedWorkspaceMemberInvitationIds;
}; });
/** /**
* @description get the details of a workspace member * @description get the details of a workspace member
* @param userId * @param userId
*/ */
getWorkspaceMemberDetails = (userId: string) => { getWorkspaceMemberDetails = computedFn((userId: string) => {
const workspaceSlug = this.routerStore.workspaceSlug; const workspaceSlug = this.routerStore.workspaceSlug;
if (!workspaceSlug) return null; if (!workspaceSlug) return null;
const workspaceMember = this.workspaceMemberMap?.[workspaceSlug]?.[userId]; const workspaceMember = this.workspaceMemberMap?.[workspaceSlug]?.[userId];
@ -164,14 +160,14 @@ export class WorkspaceMemberStore implements IWorkspaceMemberStore {
member: this.memberRoot?.memberMap?.[workspaceMember.member], member: this.memberRoot?.memberMap?.[workspaceMember.member],
}; };
return memberDetails; return memberDetails;
}; });
/** /**
* @description get the details of a workspace member invitation * @description get the details of a workspace member invitation
* @param workspaceSlug * @param workspaceSlug
* @param memberId * @param memberId
*/ */
getWorkspaceInvitationDetails = (invitationId: string) => { getWorkspaceInvitationDetails = computedFn((invitationId: string) => {
const workspaceSlug = this.routerStore.workspaceSlug; const workspaceSlug = this.routerStore.workspaceSlug;
if (!workspaceSlug) return null; if (!workspaceSlug) return null;
const invitationsList = this.workspaceMemberInvitations?.[workspaceSlug]; const invitationsList = this.workspaceMemberInvitations?.[workspaceSlug];
@ -179,7 +175,7 @@ export class WorkspaceMemberStore implements IWorkspaceMemberStore {
const invitation = invitationsList.find((inv) => inv.id === invitationId); const invitation = invitationsList.find((inv) => inv.id === invitationId);
return invitation ?? null; return invitation ?? null;
}; });
/** /**
* @description fetch all the members of a workspace * @description fetch all the members of a workspace

View File

@ -1,4 +1,5 @@
import { action, computed, observable, makeObservable, runInAction } from "mobx"; import { action, computed, observable, makeObservable, runInAction } from "mobx";
import { computedFn } from "mobx-utils";
import set from "lodash/set"; import set from "lodash/set";
import sortBy from "lodash/sortBy"; import sortBy from "lodash/sortBy";
// services // services
@ -68,9 +69,6 @@ export class ModulesStore implements IModuleStore {
fetchedMap: observable, fetchedMap: observable,
// computed // computed
projectModuleIds: computed, projectModuleIds: computed,
// computed actions
getModuleById: action,
getProjectModuleIds: action,
// actions // actions
fetchModules: action, fetchModules: action,
fetchModuleDetails: action, fetchModuleDetails: action,
@ -109,20 +107,20 @@ export class ModulesStore implements IModuleStore {
* @param moduleId * @param moduleId
* @returns IModule | null * @returns IModule | null
*/ */
getModuleById = (moduleId: string) => this.moduleMap?.[moduleId] || null; getModuleById = computedFn((moduleId: string) => this.moduleMap?.[moduleId] || null);
/** /**
* @description returns list of module ids of the project id passed as argument * @description returns list of module ids of the project id passed as argument
* @param projectId * @param projectId
*/ */
getProjectModuleIds = (projectId: string) => { getProjectModuleIds = computedFn((projectId: string) => {
if (!this.fetchedMap[projectId]) return null; if (!this.fetchedMap[projectId]) return null;
let projectModules = Object.values(this.moduleMap).filter((m) => m.project === projectId); let projectModules = Object.values(this.moduleMap).filter((m) => m.project === projectId);
projectModules = sortBy(projectModules, [(m) => !m.is_favorite, (m) => m.name.toLowerCase()]); projectModules = sortBy(projectModules, [(m) => !m.is_favorite, (m) => m.name.toLowerCase()]);
const projectModuleIds = projectModules.map((m) => m.id); const projectModuleIds = projectModules.map((m) => m.id);
return projectModuleIds; return projectModuleIds;
}; });
/** /**
* @description fetch all modules * @description fetch all modules

View File

@ -1,5 +1,6 @@
import { set } from "lodash"; import { set } from "lodash";
import { observable, action, makeObservable, runInAction, computed } from "mobx"; import { observable, action, makeObservable, runInAction, computed } from "mobx";
import { computedFn } from "mobx-utils";
// services // services
import { ViewService } from "services/view.service"; import { ViewService } from "services/view.service";
import { RootStore } from "store/root.store"; import { RootStore } from "store/root.store";
@ -49,8 +50,6 @@ export class ProjectViewStore implements IProjectViewStore {
fetchedMap: observable, fetchedMap: observable,
// computed // computed
projectViewIds: computed, projectViewIds: computed,
// computed actions
getViewById: action,
// fetch actions // fetch actions
fetchViews: action, fetchViews: action,
fetchViewDetails: action, fetchViewDetails: action,
@ -81,7 +80,7 @@ export class ProjectViewStore implements IProjectViewStore {
/** /**
* Returns view details by id * Returns view details by id
*/ */
getViewById = (viewId: string) => this.viewMap?.[viewId] ?? null; getViewById = computedFn((viewId: string) => this.viewMap?.[viewId] ?? null);
/** /**
* Fetches views for current project * Fetches views for current project

View File

@ -64,7 +64,7 @@ export class ProjectStore implements IProjectStore {
joinedProjectIds: computed, joinedProjectIds: computed,
favoriteProjectIds: computed, favoriteProjectIds: computed,
// actions // actions
setSearchQuery: action, setSearchQuery: action.bound,
// fetch actions // fetch actions
fetchProjects: action, fetchProjects: action,
fetchProjectDetails: action, fetchProjectDetails: action,

View File

@ -78,7 +78,7 @@ export class StateStore implements IStateStore {
const projectId = this.router.projectId; const projectId = this.router.projectId;
const worksapceSlug = this.router.workspaceSlug || ""; const worksapceSlug = this.router.workspaceSlug || "";
if (!projectId || !(this.fetchedMap[projectId] || this.fetchedMap[worksapceSlug])) return; if (!projectId || !(this.fetchedMap[projectId] || this.fetchedMap[worksapceSlug])) return;
return Object.values(this.stateMap).filter((state) => state.project === this.router.query.projectId); return Object.values(this.stateMap).filter((state) => state.project_id === projectId);
} }
/** /**
@ -106,7 +106,7 @@ export class StateStore implements IStateStore {
getProjectStates = computedFn((projectId: string) => { getProjectStates = computedFn((projectId: string) => {
const worksapceSlug = this.router.workspaceSlug || ""; const worksapceSlug = this.router.workspaceSlug || "";
if (!projectId || !(this.fetchedMap[projectId] || this.fetchedMap[worksapceSlug])) return; if (!projectId || !(this.fetchedMap[projectId] || this.fetchedMap[worksapceSlug])) return;
return Object.values(this.stateMap).filter((state) => state.project === projectId); return Object.values(this.stateMap).filter((state) => state.project_id === projectId);
}); });
/** /**
@ -208,7 +208,7 @@ export class StateStore implements IStateStore {
markStateAsDefault = async (workspaceSlug: string, projectId: string, stateId: string) => { markStateAsDefault = async (workspaceSlug: string, projectId: string, stateId: string) => {
const originalStates = this.stateMap; const originalStates = this.stateMap;
const currentDefaultState = Object.values(this.stateMap).find( const currentDefaultState = Object.values(this.stateMap).find(
(state) => state.project === projectId && state.default (state) => state.project_id === projectId && state.default
); );
try { try {
runInAction(() => { runInAction(() => {

View File

@ -1,5 +1,6 @@
// mobx // mobx
import { action, observable, makeObservable, runInAction } from "mobx"; import { action, observable, makeObservable, runInAction } from "mobx";
import { computedFn } from "mobx-utils";
import { APITokenService } from "services/api_token.service"; import { APITokenService } from "services/api_token.service";
import { RootStore } from "../root.store"; import { RootStore } from "../root.store";
// types // types
@ -30,8 +31,6 @@ export class ApiTokenStore implements IApiTokenStore {
makeObservable(this, { makeObservable(this, {
// observables // observables
apiTokens: observable, apiTokens: observable,
// computed actions
getApiTokenById: action,
// fetch actions // fetch actions
fetchApiTokens: action, fetchApiTokens: action,
fetchApiTokenDetails: action, fetchApiTokenDetails: action,
@ -49,10 +48,10 @@ export class ApiTokenStore implements IApiTokenStore {
* get API token by id * get API token by id
* @param apiTokenId * @param apiTokenId
*/ */
getApiTokenById = (apiTokenId: string) => { getApiTokenById = computedFn((apiTokenId: string) => {
if (!this.apiTokens) return null; if (!this.apiTokens) return null;
return this.apiTokens[apiTokenId] || null; return this.apiTokens[apiTokenId] || null;
}; });
/** /**
* fetch all the API tokens for a workspace * fetch all the API tokens for a workspace

View File

@ -1,5 +1,6 @@
// mobx // mobx
import { action, observable, makeObservable, computed, runInAction } from "mobx"; import { action, observable, makeObservable, computed, runInAction } from "mobx";
import { computedFn } from "mobx-utils";
import { IWebhook } from "@plane/types"; import { IWebhook } from "@plane/types";
import { WebhookService } from "services/webhook.service"; import { WebhookService } from "services/webhook.service";
import { RootStore } from "../root.store"; import { RootStore } from "../root.store";
@ -46,8 +47,6 @@ export class WebhookStore implements IWebhookStore {
webhookSecretKey: observable.ref, webhookSecretKey: observable.ref,
// computed // computed
currentWebhook: computed, currentWebhook: computed,
// computed actions
getWebhookById: action,
// fetch actions // fetch actions
fetchWebhooks: action, fetchWebhooks: action,
fetchWebhookById: action, fetchWebhookById: action,
@ -80,7 +79,7 @@ export class WebhookStore implements IWebhookStore {
* get webhook info from the object of webhooks in the store using webhook id * get webhook info from the object of webhooks in the store using webhook id
* @param webhookId * @param webhookId
*/ */
getWebhookById = (webhookId: string) => this.webhooks?.[webhookId] || null; getWebhookById = computedFn((webhookId: string) => this.webhooks?.[webhookId] || null);
/** /**
* fetch all the webhooks for a workspace * fetch all the webhooks for a workspace