code refactor and improvement (#6203)
* chore: package code refactoring * chore: component restructuring and refactor * chore: comment create improvement
This commit is contained in:
parent
442b0fd7e5
commit
438cc33046
134 changed files with 1336 additions and 506 deletions
1
web/ce/components/epics/epic-modal/index.ts
Normal file
1
web/ce/components/epics/epic-modal/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from "./modal";
|
||||
19
web/ce/components/epics/epic-modal/modal.tsx
Normal file
19
web/ce/components/epics/epic-modal/modal.tsx
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
"use client";
|
||||
import React, { FC } from "react";
|
||||
import { TIssue } from "@plane/types";
|
||||
|
||||
export interface EpicModalProps {
|
||||
data?: Partial<TIssue>;
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
beforeFormSubmit?: () => Promise<void>;
|
||||
onSubmit?: (res: TIssue) => Promise<void>;
|
||||
fetchIssueDetails?: boolean;
|
||||
primaryButtonText?: {
|
||||
default: string;
|
||||
loading: string;
|
||||
};
|
||||
isProjectSelectionDisabled?: boolean;
|
||||
}
|
||||
|
||||
export const CreateUpdateEpicModal: FC<EpicModalProps> = (props) => <></>;
|
||||
1
web/ce/components/epics/index.ts
Normal file
1
web/ce/components/epics/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from "./epic-modal";
|
||||
|
|
@ -1 +1,9 @@
|
|||
export const TimelineDependencyPaths = () => <></>;
|
||||
import { FC } from "react";
|
||||
|
||||
type Props = {
|
||||
isEpic?: boolean;
|
||||
};
|
||||
export const TimelineDependencyPaths: FC<Props> = (props) => {
|
||||
const { isEpic = false } = props;
|
||||
return <></>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
import { TIssueServiceType } from "@plane/types";
|
||||
|
||||
export type TIssueAdditionalPropertyValuesUpdateProps = {
|
||||
issueId: string;
|
||||
issueTypeId: string;
|
||||
projectId: string;
|
||||
workspaceSlug: string;
|
||||
isDisabled: boolean;
|
||||
issueServiceType?: TIssueServiceType;
|
||||
};
|
||||
|
||||
export const IssueAdditionalPropertyValuesUpdate: React.FC<TIssueAdditionalPropertyValuesUpdateProps> = () => <></>;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { TDeDupeIssue } from "@plane/types";
|
||||
|
||||
export const useDebouncedDuplicateIssues = (
|
||||
workspaceSlug: string | undefined,
|
||||
workspaceId: string | undefined,
|
||||
projectId: string | undefined,
|
||||
formData: { name: string | undefined; description_html?: string | undefined; issueId?: string | undefined }
|
||||
|
|
|
|||
15
web/ce/store/issue/epic/filter.store.ts
Normal file
15
web/ce/store/issue/epic/filter.store.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { IProjectIssuesFilter, ProjectIssuesFilter } from "@/store/issue/project";
|
||||
import { 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
web/ce/store/issue/epic/index.ts
Normal file
2
web/ce/store/issue/epic/index.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export * from "./filter.store";
|
||||
export * from "./issue.store";
|
||||
14
web/ce/store/issue/epic/issue.store.ts
Normal file
14
web/ce/store/issue/epic/issue.store.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { IProjectIssues, ProjectIssues } from "@/store/issue/project";
|
||||
import { IIssueRootStore } from "@/store/issue/root.store";
|
||||
import { 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);
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,14 @@ import uniq from "lodash/uniq";
|
|||
import update from "lodash/update";
|
||||
import { action, makeObservable, observable, runInAction } from "mobx";
|
||||
import { computedFn } from "mobx-utils";
|
||||
import { TIssueActivityComment, TIssueActivity, TIssueActivityMap, TIssueActivityIdMap } from "@plane/types";
|
||||
import { EIssueServiceType } from "@plane/constants";
|
||||
import {
|
||||
TIssueActivityComment,
|
||||
TIssueActivity,
|
||||
TIssueActivityMap,
|
||||
TIssueActivityIdMap,
|
||||
TIssueServiceType,
|
||||
} from "@plane/types";
|
||||
// plane web constants
|
||||
import { EActivityFilterType } from "@/plane-web/constants/issues";
|
||||
// services
|
||||
|
|
@ -29,7 +36,7 @@ export interface IIssueActivityStoreActions {
|
|||
|
||||
export interface IIssueActivityStore extends IIssueActivityStoreActions {
|
||||
// observables
|
||||
sortOrder: 'asc' | 'desc'
|
||||
sortOrder: "asc" | "desc";
|
||||
loader: TActivityLoader;
|
||||
activities: TIssueActivityIdMap;
|
||||
activityMap: TIssueActivityMap;
|
||||
|
|
@ -37,20 +44,24 @@ export interface IIssueActivityStore extends IIssueActivityStoreActions {
|
|||
getActivitiesByIssueId: (issueId: string) => string[] | undefined;
|
||||
getActivityById: (activityId: string) => TIssueActivity | undefined;
|
||||
getActivityCommentByIssueId: (issueId: string) => TIssueActivityComment[] | undefined;
|
||||
toggleSortOrder: ()=>void;
|
||||
toggleSortOrder: () => void;
|
||||
}
|
||||
|
||||
export class IssueActivityStore implements IIssueActivityStore {
|
||||
// observables
|
||||
sortOrder: "asc" | "desc" = 'asc';
|
||||
sortOrder: "asc" | "desc" = "asc";
|
||||
loader: TActivityLoader = "fetch";
|
||||
activities: TIssueActivityIdMap = {};
|
||||
activityMap: TIssueActivityMap = {};
|
||||
|
||||
// services
|
||||
serviceType;
|
||||
issueActivityService;
|
||||
|
||||
constructor(protected store: CoreRootStore) {
|
||||
constructor(
|
||||
protected store: CoreRootStore,
|
||||
serviceType: TIssueServiceType = EIssueServiceType.ISSUES
|
||||
) {
|
||||
makeObservable(this, {
|
||||
// observables
|
||||
sortOrder: observable.ref,
|
||||
|
|
@ -59,10 +70,11 @@ export class IssueActivityStore implements IIssueActivityStore {
|
|||
activityMap: observable,
|
||||
// actions
|
||||
fetchActivities: action,
|
||||
toggleSortOrder: action
|
||||
toggleSortOrder: action,
|
||||
});
|
||||
this.serviceType = serviceType;
|
||||
// services
|
||||
this.issueActivityService = new IssueActivityService();
|
||||
this.issueActivityService = new IssueActivityService(this.serviceType);
|
||||
}
|
||||
|
||||
// helper methods
|
||||
|
|
@ -81,8 +93,10 @@ export class IssueActivityStore implements IIssueActivityStore {
|
|||
|
||||
let activityComments: TIssueActivityComment[] = [];
|
||||
|
||||
const currentStore = this.serviceType === EIssueServiceType.EPICS ? this.store.epic : this.store.issue;
|
||||
|
||||
const activities = this.getActivitiesByIssueId(issueId) || [];
|
||||
const comments = this.store.issue.issueDetail.comment.getCommentsByIssueId(issueId) || [];
|
||||
const comments = currentStore.issueDetail.comment.getCommentsByIssueId(issueId) || [];
|
||||
|
||||
activities.forEach((activityId) => {
|
||||
const activity = this.getActivityById(activityId);
|
||||
|
|
@ -95,7 +109,7 @@ export class IssueActivityStore implements IIssueActivityStore {
|
|||
});
|
||||
|
||||
comments.forEach((commentId) => {
|
||||
const comment = this.store.issue.issueDetail.comment.getCommentById(commentId);
|
||||
const comment = currentStore.issueDetail.comment.getCommentById(commentId);
|
||||
if (!comment) return;
|
||||
activityComments.push({
|
||||
id: comment.id,
|
||||
|
|
@ -104,14 +118,14 @@ export class IssueActivityStore implements IIssueActivityStore {
|
|||
});
|
||||
});
|
||||
|
||||
activityComments = orderBy(activityComments, (e)=>new Date(e.created_at || 0), this.sortOrder);
|
||||
activityComments = orderBy(activityComments, (e) => new Date(e.created_at || 0), this.sortOrder);
|
||||
|
||||
return activityComments;
|
||||
});
|
||||
|
||||
toggleSortOrder = ()=>{
|
||||
this.sortOrder = this.sortOrder === 'asc' ? 'desc' : 'asc';
|
||||
}
|
||||
toggleSortOrder = () => {
|
||||
this.sortOrder = this.sortOrder === "asc" ? "desc" : "asc";
|
||||
};
|
||||
|
||||
// actions
|
||||
public async fetchActivities(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue