chore: archived issues restructure. (#3469)

* chore: archived issues restructure.

* fix issue detail functionalities

---------

Co-authored-by: rahulramesha <rahulramesham@gmail.com>
This commit is contained in:
Prateek Shourya 2024-01-25 18:09:01 +05:30 committed by GitHub
parent f8208b1b5e
commit 60b5589c48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 72 additions and 133 deletions

View file

@ -1,13 +1,13 @@
import { makeObservable } from "mobx";
// services
import { IssueService } from "services/issue";
import { IssueArchiveService, IssueService } from "services/issue";
// types
import { IIssueDetail } from "./root.store";
import { TIssue } from "@plane/types";
export interface IIssueStoreActions {
// actions
fetchIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise<TIssue>;
fetchIssue: (workspaceSlug: string, projectId: string, issueId: string, isArchived?: boolean) => Promise<TIssue>;
updateIssue: (workspaceSlug: string, projectId: string, issueId: string, data: Partial<TIssue>) => Promise<TIssue>;
removeIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise<TIssue>;
addIssueToCycle: (workspaceSlug: string, projectId: string, cycleId: string, issueIds: string[]) => Promise<TIssue>;
@ -31,6 +31,7 @@ export class IssueStore implements IIssueStore {
rootIssueDetailStore: IIssueDetail;
// services
issueService;
issueArchiveService;
constructor(rootStore: IIssueDetail) {
makeObservable(this, {});
@ -38,6 +39,7 @@ export class IssueStore implements IIssueStore {
this.rootIssueDetailStore = rootStore;
// services
this.issueService = new IssueService();
this.issueArchiveService = new IssueArchiveService();
}
// helper methods
@ -47,12 +49,17 @@ export class IssueStore implements IIssueStore {
};
// actions
fetchIssue = async (workspaceSlug: string, projectId: string, issueId: string) => {
fetchIssue = async (workspaceSlug: string, projectId: string, issueId: string, isArchived = false) => {
try {
const query = {
expand: "state,assignees,labels,parent",
};
const issue = (await this.issueService.retrieve(workspaceSlug, projectId, issueId, query)) as any;
let issue: any;
if (isArchived) issue = await this.issueArchiveService.retrieveArchivedIssue(workspaceSlug, projectId, issueId);
else issue = await this.issueService.retrieve(workspaceSlug, projectId, issueId, query);
if (!issue) throw new Error("Issue not found");
this.rootIssueDetailStore.rootIssueStore.issues.addIssue([issue]);

View file

@ -133,8 +133,8 @@ export class IssueDetail implements IIssueDetail {
toggleRelationModal = (value: TIssueRelationTypes | null) => (this.isRelationModalOpen = value);
// issue
fetchIssue = async (workspaceSlug: string, projectId: string, issueId: string) =>
this.issue.fetchIssue(workspaceSlug, projectId, issueId);
fetchIssue = async (workspaceSlug: string, projectId: string, issueId: string, isArchived = false) =>
this.issue.fetchIssue(workspaceSlug, projectId, issueId, isArchived);
updateIssue = async (workspaceSlug: string, projectId: string, issueId: string, data: Partial<TIssue>) =>
this.issue.updateIssue(workspaceSlug, projectId, issueId, data);
removeIssue = async (workspaceSlug: string, projectId: string, issueId: string) =>