fix: merge conflicts resolved

This commit is contained in:
sriram veeraghanta 2023-12-12 17:48:18 +05:30
commit 822ae138dc
7 changed files with 75 additions and 57 deletions

View File

@ -9,7 +9,7 @@ export interface IEventTrackerStore {
postHogEventTracker: ( postHogEventTracker: (
eventName: string, eventName: string,
payload: object | [] | null, payload: object | [] | null,
group?: { isGrouping: boolean | null; groupType: string | null; gorupId: string | null } | null group?: { isGrouping: boolean | null; groupType: string | null; groupId: string | null } | null
) => void; ) => void;
} }
@ -32,16 +32,19 @@ export class EventTrackerStore implements IEventTrackerStore {
postHogEventTracker = ( postHogEventTracker = (
eventName: string, eventName: string,
payload: object | [] | null, payload: object | [] | null,
group?: { isGrouping: boolean | null; groupType: string | null; gorupId: string | null } | null group?: { isGrouping: boolean | null; groupType: string | null; groupId: string | null } | null
) => { ) => {
try { try {
const currentWorkspaceDetails = this.rootStore.workspace.currentWorkspace;
const currentProjectDetails = this.rootStore.project.projects.currentProjectDetails;
let extras: any = { let extras: any = {
workspace_name: this.rootStore.workspace.currentWorkspace?.name ?? "", workspace_name: currentWorkspaceDetails?.name ?? "",
workspace_id: this.rootStore.workspace.currentWorkspace?.id ?? "", workspace_id: currentWorkspaceDetails?.id ?? "",
workspace_slug: this.rootStore.workspace.currentWorkspace?.slug ?? "", workspace_slug: currentWorkspaceDetails?.slug ?? "",
project_name: this.rootStore.project.currentProjectDetails?.name ?? "", project_name: currentProjectDetails?.name ?? "",
project_id: this.rootStore.project.currentProjectDetails?.id ?? "", project_id: currentProjectDetails?.id ?? "",
project_identifier: this.rootStore.project.currentProjectDetails?.identifier ?? "", project_identifier: currentProjectDetails?.identifier ?? "",
}; };
if (["PROJECT_CREATED", "PROJECT_UPDATED"].includes(eventName)) { if (["PROJECT_CREATED", "PROJECT_UPDATED"].includes(eventName)) {
const project_details: any = payload as object; const project_details: any = payload as object;
@ -54,9 +57,9 @@ export class EventTrackerStore implements IEventTrackerStore {
} }
if (group && group!.isGrouping === true) { if (group && group!.isGrouping === true) {
posthog?.group(group!.groupType!, group!.gorupId!, { posthog?.group(group!.groupType!, group!.groupId!, {
date: new Date(), date: new Date(),
workspace_id: group!.gorupId, workspace_id: group!.groupId,
}); });
posthog?.capture(eventName, { posthog?.capture(eventName, {
...payload, ...payload,

View File

@ -1,4 +1,4 @@
import { action, makeObservable, observable } from "mobx"; import { action, makeObservable, observable, computed } from "mobx";
import { ParsedUrlQuery } from "node:querystring"; import { ParsedUrlQuery } from "node:querystring";
export interface IRouterStore { export interface IRouterStore {
@ -12,6 +12,9 @@ export interface IRouterStore {
viewId: string | undefined; viewId: string | undefined;
userId: string | undefined; userId: string | undefined;
peekId: string | undefined; peekId: string | undefined;
issueId: string | undefined;
inboxId: string | undefined;
webhookId: string | undefined;
} }
export class RouterStore implements IRouterStore { export class RouterStore implements IRouterStore {
@ -23,13 +26,16 @@ export class RouterStore implements IRouterStore {
setQuery: action, setQuery: action,
//computed //computed
workspaceSlug: action, workspaceSlug: computed,
projectId: action, projectId: computed,
cycleId: action, cycleId: computed,
moduleId: action, moduleId: computed,
viewId: action, viewId: computed,
userId: action, userId: computed,
peekId: action, peekId: computed,
issueId: computed,
inboxId: computed,
webhookId: computed,
}); });
} }
@ -38,7 +44,7 @@ export class RouterStore implements IRouterStore {
} }
get workspaceSlug() { get workspaceSlug() {
return this.query?.workspace_slug?.toString(); return this.query?.workspaceSlug?.toString();
} }
get projectId() { get projectId() {
@ -60,7 +66,20 @@ export class RouterStore implements IRouterStore {
get userId() { get userId() {
return this.query?.userId?.toString(); return this.query?.userId?.toString();
} }
get peekId() { get peekId() {
return this.query?.peekId?.toString(); return this.query?.peekId?.toString();
} }
get issueId() {
return this.query?.issueId?.toString();
}
get inboxId() {
return this.query?.inboxId?.toString();
}
get webhookId() {
return this.query?.webhookId?.toString();
}
} }

View File

@ -1,10 +1,15 @@
import { ProjectsStore } from "./projects.store"; import { IProjectsStore, ProjectsStore } from "./projects.store";
import { ProjectPublishStore } from "./project-publish.store"; import { IProjectPublishStore, ProjectPublishStore } from "./project-publish.store";
import { RootStore } from "store/root.store"; import { RootStore } from "store/root.store";
export interface IProjectRootStore {
projects: IProjectsStore;
publish: IProjectPublishStore;
}
export class ProjectRootStore { export class ProjectRootStore {
projects: ProjectsStore; projects: IProjectsStore;
publish: ProjectPublishStore; publish: IProjectPublishStore;
constructor(_root: RootStore) { constructor(_root: RootStore) {
this.projects = new ProjectsStore(_root); this.projects = new ProjectsStore(_root);

View File

@ -1,29 +1,30 @@
import { enableStaticRendering } from "mobx-react-lite"; import { enableStaticRendering } from "mobx-react-lite";
// root stores // root stores
import { AppRootStore, IAppRootStore } from "./application"; import { AppRootStore, IAppRootStore } from "./application";
import { ProjectRootStore } from "./project"; import { IProjectRootStore, ProjectRootStore } from "./project";
import { CycleStore } from "./cycle.store"; import { CycleStore, ICycleStore } from "./cycle.store";
import { ProjectViewsStore } from "./project-view.store"; import { IProjectViewsStore, ProjectViewsStore } from "./project-view.store";
import { ModulesStore } from "./module.store"; import { IModuleStore, ModulesStore } from "./module.store";
import { UserStore, IUserStore } from "./user"; import { IUserStore, UserStore } from "./user";
import { LabelStore, ILabelStore } from "./label.store"; import { ILabelStore, LabelStore } from "./label.store";
import { IWorkspaceRootStore, WorkspaceRootStore } from "./workspace";
enableStaticRendering(typeof window === "undefined"); enableStaticRendering(typeof window === "undefined");
export class RootStore { export class RootStore {
app: IAppRootStore; app: IAppRootStore;
user: IUserStore; user: IUserStore;
// workspace; workspace: IWorkspaceRootStore;
project; project: IProjectRootStore;
cycle; cycle: ICycleStore;
module; module: IModuleStore;
projectView; projectView: IProjectViewsStore;
label: ILabelStore; label: ILabelStore;
constructor() { constructor() {
this.app = new AppRootStore(this); this.app = new AppRootStore(this);
this.user = new UserStore(this); this.user = new UserStore(this);
// this.workspace = new WorkspaceRootStore(); this.workspace = new WorkspaceRootStore(this);
this.project = new ProjectRootStore(this); this.project = new ProjectRootStore(this);
this.cycle = new CycleStore(this); this.cycle = new CycleStore(this);
this.module = new ModulesStore(this); this.module = new ModulesStore(this);

View File

@ -1,4 +1,4 @@
import { action, observable, runInAction, makeObservable, computed } from "mobx"; import { action, observable, runInAction, makeObservable } from "mobx";
// services // services
import { UserService } from "services/user.service"; import { UserService } from "services/user.service";
import { AuthService } from "services/auth.service"; import { AuthService } from "services/auth.service";
@ -6,7 +6,7 @@ import { AuthService } from "services/auth.service";
import { IUser, IUserSettings } from "types/users"; import { IUser, IUserSettings } from "types/users";
// store // store
import { RootStore } from "../root.store"; import { RootStore } from "../root.store";
import { UserMembershipStore } from "./user-membership.store"; import { IUserMembershipStore, UserMembershipStore } from "./user-membership.store";
export interface IUserStore { export interface IUserStore {
loader: boolean; loader: boolean;
@ -33,7 +33,7 @@ export interface IUserStore {
deactivateAccount: () => Promise<void>; deactivateAccount: () => Promise<void>;
signOut: () => Promise<void>; signOut: () => Promise<void>;
membership: UserMembershipStore; membership: IUserMembershipStore;
} }
export class UserStore implements IUserStore { export class UserStore implements IUserStore {

View File

@ -5,10 +5,10 @@ import { IWorkspace } from "types";
// services // services
import { WorkspaceService } from "services/workspace.service"; import { WorkspaceService } from "services/workspace.service";
// sub-stores // sub-stores
import { WebhookStore } from "./webhook.store"; import { IWebhookStore, WebhookStore } from "./webhook.store";
import { ApiTokenStore } from "./api-token.store"; import { ApiTokenStore, IApiTokenStore } from "./api-token.store";
export interface IWorkspaceStore { export interface IWorkspaceRootStore {
// states // states
loader: boolean; loader: boolean;
error: any | null; error: any | null;
@ -31,11 +31,11 @@ export interface IWorkspaceStore {
deleteWorkspace: (workspaceSlug: string) => Promise<void>; deleteWorkspace: (workspaceSlug: string) => Promise<void>;
// sub-stores // sub-stores
webhook: WebhookStore; webhook: IWebhookStore;
apiToken: ApiTokenStore; apiToken: IApiTokenStore;
} }
export class WorkspaceStore implements IWorkspaceStore { export class WorkspaceRootStore implements IWorkspaceRootStore {
// states // states
loader: boolean = false; loader: boolean = false;
error: any | null = null; error: any | null = null;
@ -88,11 +88,11 @@ export class WorkspaceStore implements IWorkspaceStore {
* computed value of current workspace based on workspace slug saved in the query store * computed value of current workspace based on workspace slug saved in the query store
*/ */
get currentWorkspace() { get currentWorkspace() {
const workspaceSlug = this.rootStore.app.router.query?.workspaceSlug; const workspaceSlug = this.rootStore.app.router.workspaceSlug;
if (!workspaceSlug) return null; if (!workspaceSlug) return null;
return this.workspaces?.find((workspace) => workspace.slug === workspaceSlug.toString()) || null; return this.workspaces?.find((workspace) => workspace.slug === workspaceSlug) || null;
} }
/** /**

View File

@ -8,17 +8,13 @@ export interface IWebhookStore {
// states // states
loader: boolean; loader: boolean;
error: any | null; error: any | null;
// observables // observables
webhooks: Record<string, IWebhook> | null; webhooks: Record<string, IWebhook> | null;
webhookSecretKey: string | null; webhookSecretKey: string | null;
// computed // computed
currentWebhook: IWebhook | null; currentWebhook: IWebhook | null;
// computed actions // computed actions
getWebhookById: (webhookId: string) => IWebhook | null; getWebhookById: (webhookId: string) => IWebhook | null;
// actions // actions
fetchWebhooks: (workspaceSlug: string) => Promise<IWebhook[]>; fetchWebhooks: (workspaceSlug: string) => Promise<IWebhook[]>;
fetchWebhookById: (workspaceSlug: string, webhookId: string) => Promise<IWebhook>; fetchWebhookById: (workspaceSlug: string, webhookId: string) => Promise<IWebhook>;
@ -39,11 +35,9 @@ export class WebhookStore implements IWebhookStore {
// states // states
loader: boolean = false; loader: boolean = false;
error: any | null = null; error: any | null = null;
// observables // observables
webhooks: Record<string, IWebhook> | null = null; webhooks: Record<string, IWebhook> | null = null;
webhookSecretKey: string | null = null; webhookSecretKey: string | null = null;
// services // services
webhookService; webhookService;
// root store // root store
@ -54,17 +48,13 @@ export class WebhookStore implements IWebhookStore {
// states // states
loader: observable.ref, loader: observable.ref,
error: observable.ref, error: observable.ref,
// observables // observables
webhooks: observable, webhooks: observable,
webhookSecretKey: observable.ref, webhookSecretKey: observable.ref,
// computed // computed
currentWebhook: computed, currentWebhook: computed,
// computed actions // computed actions
getWebhookById: action, getWebhookById: action,
// actions // actions
fetchWebhooks: action, fetchWebhooks: action,
fetchWebhookById: action, fetchWebhookById: action,
@ -85,7 +75,7 @@ export class WebhookStore implements IWebhookStore {
* computed value of current webhook based on webhook id saved in the query store * computed value of current webhook based on webhook id saved in the query store
*/ */
get currentWebhook() { get currentWebhook() {
const webhookId = this.rootStore.app.router.query?.webhookId; const webhookId = this.rootStore.app.router.webhookId;
if (!webhookId) return null; if (!webhookId) return null;