feat: init
This commit is contained in:
16
apps/web/ce/store/issue/epic/filter.store.ts
Normal file
16
apps/web/ce/store/issue/epic/filter.store.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { IProjectIssuesFilter } from "@/store/issue/project";
|
||||
import { ProjectIssuesFilter } from "@/store/issue/project";
|
||||
import type { IIssueRootStore } from "@/store/issue/root.store";
|
||||
|
||||
// @ts-nocheck - This class will never be used, extending similar class to avoid type errors
|
||||
export type IProjectEpicsFilter = IProjectIssuesFilter;
|
||||
|
||||
// @ts-nocheck - This class will never be used, extending similar class to avoid type errors
|
||||
export class ProjectEpicsFilter extends ProjectIssuesFilter implements IProjectEpicsFilter {
|
||||
constructor(_rootStore: IIssueRootStore) {
|
||||
super(_rootStore);
|
||||
|
||||
// root store
|
||||
this.rootIssueStore = _rootStore;
|
||||
}
|
||||
}
|
||||
2
apps/web/ce/store/issue/epic/index.ts
Normal file
2
apps/web/ce/store/issue/epic/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./filter.store";
|
||||
export * from "./issue.store";
|
||||
15
apps/web/ce/store/issue/epic/issue.store.ts
Normal file
15
apps/web/ce/store/issue/epic/issue.store.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { IProjectIssues } from "@/store/issue/project";
|
||||
import { ProjectIssues } from "@/store/issue/project";
|
||||
import type { IIssueRootStore } from "@/store/issue/root.store";
|
||||
import type { IProjectEpicsFilter } from "./filter.store";
|
||||
|
||||
// @ts-nocheck - This class will never be used, extending similar class to avoid type errors
|
||||
|
||||
export type IProjectEpics = IProjectIssues;
|
||||
|
||||
// @ts-nocheck - This class will never be used, extending similar class to avoid type errors
|
||||
export class ProjectEpics extends ProjectIssues implements IProjectEpics {
|
||||
constructor(_rootStore: IIssueRootStore, issueFilterStore: IProjectEpicsFilter) {
|
||||
super(_rootStore, issueFilterStore);
|
||||
}
|
||||
}
|
||||
4
apps/web/ce/store/issue/helpers/base-issue-store.ts
Normal file
4
apps/web/ce/store/issue/helpers/base-issue-store.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { TIssue } from "@plane/types";
|
||||
import { getIssueIds } from "@/store/issue/helpers/base-issues-utils";
|
||||
|
||||
export const workItemSortWithOrderByExtended = (array: TIssue[], key?: string) => getIssueIds(array);
|
||||
4
apps/web/ce/store/issue/helpers/base-issue.store.ts
Normal file
4
apps/web/ce/store/issue/helpers/base-issue.store.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { TIssue } from "@plane/types";
|
||||
import { getIssueIds } from "@/store/issue/helpers/base-issues-utils";
|
||||
|
||||
export const workItemSortWithOrderByExtended = (array: TIssue[], key?: string) => getIssueIds(array);
|
||||
173
apps/web/ce/store/issue/issue-details/activity.store.ts
Normal file
173
apps/web/ce/store/issue/issue-details/activity.store.ts
Normal file
@@ -0,0 +1,173 @@
|
||||
import { concat, orderBy, set, uniq, update } from "lodash-es";
|
||||
import { action, makeObservable, observable, runInAction } from "mobx";
|
||||
import { computedFn } from "mobx-utils";
|
||||
// plane package imports
|
||||
import type { E_SORT_ORDER } from "@plane/constants";
|
||||
import { EActivityFilterType } from "@plane/constants";
|
||||
import type {
|
||||
TIssueActivityComment,
|
||||
TIssueActivity,
|
||||
TIssueActivityMap,
|
||||
TIssueActivityIdMap,
|
||||
TIssueServiceType,
|
||||
} from "@plane/types";
|
||||
import { EIssueServiceType } from "@plane/types";
|
||||
// plane web constants
|
||||
// services
|
||||
import { IssueActivityService } from "@/services/issue";
|
||||
// store
|
||||
import type { CoreRootStore } from "@/store/root.store";
|
||||
|
||||
export type TActivityLoader = "fetch" | "mutate" | undefined;
|
||||
|
||||
export interface IIssueActivityStoreActions {
|
||||
// actions
|
||||
fetchActivities: (
|
||||
workspaceSlug: string,
|
||||
projectId: string,
|
||||
issueId: string,
|
||||
loaderType?: TActivityLoader
|
||||
) => Promise<TIssueActivity[]>;
|
||||
}
|
||||
|
||||
export interface IIssueActivityStore extends IIssueActivityStoreActions {
|
||||
// observables
|
||||
loader: TActivityLoader;
|
||||
activities: TIssueActivityIdMap;
|
||||
activityMap: TIssueActivityMap;
|
||||
// helper methods
|
||||
getActivitiesByIssueId: (issueId: string) => string[] | undefined;
|
||||
getActivityById: (activityId: string) => TIssueActivity | undefined;
|
||||
getActivityAndCommentsByIssueId: (issueId: string, sortOrder: E_SORT_ORDER) => TIssueActivityComment[] | undefined;
|
||||
}
|
||||
|
||||
export class IssueActivityStore implements IIssueActivityStore {
|
||||
// observables
|
||||
loader: TActivityLoader = "fetch";
|
||||
activities: TIssueActivityIdMap = {};
|
||||
activityMap: TIssueActivityMap = {};
|
||||
// services
|
||||
serviceType;
|
||||
issueActivityService;
|
||||
|
||||
constructor(
|
||||
protected store: CoreRootStore,
|
||||
serviceType: TIssueServiceType = EIssueServiceType.ISSUES
|
||||
) {
|
||||
makeObservable(this, {
|
||||
// observables
|
||||
loader: observable.ref,
|
||||
activities: observable,
|
||||
activityMap: observable,
|
||||
// actions
|
||||
fetchActivities: action,
|
||||
});
|
||||
this.serviceType = serviceType;
|
||||
// services
|
||||
this.issueActivityService = new IssueActivityService(this.serviceType);
|
||||
}
|
||||
|
||||
// helper methods
|
||||
getActivitiesByIssueId = (issueId: string) => {
|
||||
if (!issueId) return undefined;
|
||||
return this.activities[issueId] ?? undefined;
|
||||
};
|
||||
|
||||
getActivityById = (activityId: string) => {
|
||||
if (!activityId) return undefined;
|
||||
return this.activityMap[activityId] ?? undefined;
|
||||
};
|
||||
|
||||
protected buildActivityAndCommentItems(issueId: string): TIssueActivityComment[] | undefined {
|
||||
if (!issueId) return undefined;
|
||||
|
||||
const activityComments: TIssueActivityComment[] = [];
|
||||
|
||||
const currentStore =
|
||||
this.serviceType === EIssueServiceType.EPICS ? this.store.issue.epicDetail : this.store.issue.issueDetail;
|
||||
|
||||
const activities = this.getActivitiesByIssueId(issueId);
|
||||
const comments = currentStore.comment.getCommentsByIssueId(issueId);
|
||||
|
||||
if (!activities || !comments) return undefined;
|
||||
|
||||
activities.forEach((activityId) => {
|
||||
const activity = this.getActivityById(activityId);
|
||||
if (!activity) return;
|
||||
const type =
|
||||
activity.field === "state"
|
||||
? EActivityFilterType.STATE
|
||||
: activity.field === "assignees"
|
||||
? EActivityFilterType.ASSIGNEE
|
||||
: activity.field === null
|
||||
? EActivityFilterType.DEFAULT
|
||||
: EActivityFilterType.ACTIVITY;
|
||||
activityComments.push({
|
||||
id: activity.id,
|
||||
activity_type: type,
|
||||
created_at: activity.created_at,
|
||||
});
|
||||
});
|
||||
|
||||
comments.forEach((commentId) => {
|
||||
const comment = currentStore.comment.getCommentById(commentId);
|
||||
if (!comment) return;
|
||||
activityComments.push({
|
||||
id: comment.id,
|
||||
activity_type: EActivityFilterType.COMMENT,
|
||||
created_at: comment.created_at,
|
||||
});
|
||||
});
|
||||
|
||||
return activityComments;
|
||||
}
|
||||
|
||||
protected sortActivityComments(items: TIssueActivityComment[], sortOrder: E_SORT_ORDER): TIssueActivityComment[] {
|
||||
return orderBy(items, (e) => new Date(e.created_at || 0), sortOrder);
|
||||
}
|
||||
|
||||
getActivityAndCommentsByIssueId = computedFn((issueId: string, sortOrder: E_SORT_ORDER) => {
|
||||
const baseItems = this.buildActivityAndCommentItems(issueId);
|
||||
if (!baseItems) return undefined;
|
||||
return this.sortActivityComments(baseItems, sortOrder);
|
||||
});
|
||||
|
||||
// actions
|
||||
public async fetchActivities(
|
||||
workspaceSlug: string,
|
||||
projectId: string,
|
||||
issueId: string,
|
||||
loaderType: TActivityLoader = "fetch"
|
||||
) {
|
||||
try {
|
||||
this.loader = loaderType;
|
||||
|
||||
let props = {};
|
||||
const currentActivityIds = this.getActivitiesByIssueId(issueId);
|
||||
if (currentActivityIds && currentActivityIds.length > 0) {
|
||||
const currentActivity = this.getActivityById(currentActivityIds[currentActivityIds.length - 1]);
|
||||
if (currentActivity) props = { created_at__gt: currentActivity.created_at };
|
||||
}
|
||||
|
||||
const activities = await this.issueActivityService.getIssueActivities(workspaceSlug, projectId, issueId, props);
|
||||
|
||||
const activityIds = activities.map((activity) => activity.id);
|
||||
|
||||
runInAction(() => {
|
||||
update(this.activities, issueId, (currentActivityIds) => {
|
||||
if (!currentActivityIds) return activityIds;
|
||||
return uniq(concat(currentActivityIds, activityIds));
|
||||
});
|
||||
activities.forEach((activity) => {
|
||||
set(this.activityMap, activity.id, activity);
|
||||
});
|
||||
this.loader = undefined;
|
||||
});
|
||||
|
||||
return activities;
|
||||
} catch (error) {
|
||||
this.loader = undefined;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
apps/web/ce/store/issue/issue-details/root.store.ts
Normal file
16
apps/web/ce/store/issue/issue-details/root.store.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { makeObservable } from "mobx";
|
||||
import type { TIssueServiceType } from "@plane/types";
|
||||
import type { IIssueDetail as IIssueDetailCore } from "@/store/issue/issue-details/root.store";
|
||||
import { IssueDetail as IssueDetailCore } from "@/store/issue/issue-details/root.store";
|
||||
import type { IIssueRootStore } from "@/store/issue/root.store";
|
||||
|
||||
export type IIssueDetail = IIssueDetailCore;
|
||||
|
||||
export class IssueDetail extends IssueDetailCore {
|
||||
constructor(rootStore: IIssueRootStore, serviceType: TIssueServiceType) {
|
||||
super(rootStore, serviceType);
|
||||
makeObservable(this, {
|
||||
// observables
|
||||
});
|
||||
}
|
||||
}
|
||||
13
apps/web/ce/store/issue/team-project/filter.store.ts
Normal file
13
apps/web/ce/store/issue/team-project/filter.store.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { IProjectIssuesFilter } from "@/store/issue/project";
|
||||
import { ProjectIssuesFilter } from "@/store/issue/project";
|
||||
import type { IIssueRootStore } from "@/store/issue/root.store";
|
||||
|
||||
// @ts-nocheck - This class will never be used, extending similar class to avoid type errors
|
||||
export type ITeamProjectWorkItemsFilter = IProjectIssuesFilter;
|
||||
|
||||
// @ts-nocheck - This class will never be used, extending similar class to avoid type errors
|
||||
export class TeamProjectWorkItemsFilter extends ProjectIssuesFilter implements ITeamProjectWorkItemsFilter {
|
||||
constructor(_rootStore: IIssueRootStore) {
|
||||
super(_rootStore);
|
||||
}
|
||||
}
|
||||
2
apps/web/ce/store/issue/team-project/index.ts
Normal file
2
apps/web/ce/store/issue/team-project/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./filter.store";
|
||||
export * from "./issue.store";
|
||||
14
apps/web/ce/store/issue/team-project/issue.store.ts
Normal file
14
apps/web/ce/store/issue/team-project/issue.store.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { IProjectIssues } from "@/store/issue/project";
|
||||
import { ProjectIssues } from "@/store/issue/project";
|
||||
import type { IIssueRootStore } from "@/store/issue/root.store";
|
||||
import type { ITeamProjectWorkItemsFilter } from "./filter.store";
|
||||
|
||||
// @ts-nocheck - This class will never be used, extending similar class to avoid type errors
|
||||
export type ITeamProjectWorkItems = IProjectIssues;
|
||||
|
||||
// @ts-nocheck - This class will never be used, extending similar class to avoid type errors
|
||||
export class TeamProjectWorkItems extends ProjectIssues implements ITeamProjectWorkItems {
|
||||
constructor(_rootStore: IIssueRootStore, teamProjectWorkItemsFilterStore: ITeamProjectWorkItemsFilter) {
|
||||
super(_rootStore, teamProjectWorkItemsFilterStore);
|
||||
}
|
||||
}
|
||||
13
apps/web/ce/store/issue/team-views/filter.store.ts
Normal file
13
apps/web/ce/store/issue/team-views/filter.store.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { IProjectViewIssuesFilter } from "@/store/issue/project-views";
|
||||
import { ProjectViewIssuesFilter } from "@/store/issue/project-views";
|
||||
import type { IIssueRootStore } from "@/store/issue/root.store";
|
||||
|
||||
// @ts-nocheck - This class will never be used, extending similar class to avoid type errors
|
||||
export type ITeamViewIssuesFilter = IProjectViewIssuesFilter;
|
||||
|
||||
// @ts-nocheck - This class will never be used, extending similar class to avoid type errors
|
||||
export class TeamViewIssuesFilter extends ProjectViewIssuesFilter implements IProjectViewIssuesFilter {
|
||||
constructor(_rootStore: IIssueRootStore) {
|
||||
super(_rootStore);
|
||||
}
|
||||
}
|
||||
2
apps/web/ce/store/issue/team-views/index.ts
Normal file
2
apps/web/ce/store/issue/team-views/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./filter.store";
|
||||
export * from "./issue.store";
|
||||
14
apps/web/ce/store/issue/team-views/issue.store.ts
Normal file
14
apps/web/ce/store/issue/team-views/issue.store.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { IProjectViewIssues } from "@/store/issue/project-views";
|
||||
import { ProjectViewIssues } from "@/store/issue/project-views";
|
||||
import type { IIssueRootStore } from "@/store/issue/root.store";
|
||||
import type { ITeamViewIssuesFilter } from "./filter.store";
|
||||
|
||||
// @ts-nocheck - This class will never be used, extending similar class to avoid type errors
|
||||
export type ITeamViewIssues = IProjectViewIssues;
|
||||
|
||||
// @ts-nocheck - This class will never be used, extending similar class to avoid type errors
|
||||
export class TeamViewIssues extends ProjectViewIssues implements IProjectViewIssues {
|
||||
constructor(_rootStore: IIssueRootStore, teamViewFilterStore: ITeamViewIssuesFilter) {
|
||||
super(_rootStore, teamViewFilterStore);
|
||||
}
|
||||
}
|
||||
13
apps/web/ce/store/issue/team/filter.store.ts
Normal file
13
apps/web/ce/store/issue/team/filter.store.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { IProjectIssuesFilter } from "@/store/issue/project";
|
||||
import { ProjectIssuesFilter } from "@/store/issue/project";
|
||||
import type { IIssueRootStore } from "@/store/issue/root.store";
|
||||
|
||||
// @ts-nocheck - This class will never be used, extending similar class to avoid type errors
|
||||
export type ITeamIssuesFilter = IProjectIssuesFilter;
|
||||
|
||||
// @ts-nocheck - This class will never be used, extending similar class to avoid type errors
|
||||
export class TeamIssuesFilter extends ProjectIssuesFilter implements IProjectIssuesFilter {
|
||||
constructor(_rootStore: IIssueRootStore) {
|
||||
super(_rootStore);
|
||||
}
|
||||
}
|
||||
2
apps/web/ce/store/issue/team/index.ts
Normal file
2
apps/web/ce/store/issue/team/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./filter.store";
|
||||
export * from "./issue.store";
|
||||
14
apps/web/ce/store/issue/team/issue.store.ts
Normal file
14
apps/web/ce/store/issue/team/issue.store.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { IProjectIssues } from "@/store/issue/project";
|
||||
import { ProjectIssues } from "@/store/issue/project";
|
||||
import type { IIssueRootStore } from "@/store/issue/root.store";
|
||||
import type { ITeamIssuesFilter } from "./filter.store";
|
||||
|
||||
// @ts-nocheck - This class will never be used, extending similar class to avoid type errors
|
||||
export type ITeamIssues = IProjectIssues;
|
||||
|
||||
// @ts-nocheck - This class will never be used, extending similar class to avoid type errors
|
||||
export class TeamIssues extends ProjectIssues implements IProjectIssues {
|
||||
constructor(_rootStore: IIssueRootStore, teamIssueFilterStore: ITeamIssuesFilter) {
|
||||
super(_rootStore, teamIssueFilterStore);
|
||||
}
|
||||
}
|
||||
1
apps/web/ce/store/issue/workspace/issue.store.ts
Normal file
1
apps/web/ce/store/issue/workspace/issue.store.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "@/store/issue/workspace/issue.store";
|
||||
Reference in New Issue
Block a user