[WEB-581] fix: issue editing functionality enhancement in Create/Edit modal (#3809)
* chore: draft issue update request * chore: changed the serializer * chore: handled issue description in issue modal, inbox issues mutation and draft issue mutaion and changed the endpoints * chore: handled draft toggle in make a issue payload in issues * chore: handled issue labels in the inbox issues --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
This commit is contained in:
parent
c858b76054
commit
34d6b135f2
16 changed files with 250 additions and 156 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { makeObservable } from "mobx";
|
||||
// services
|
||||
import { IssueArchiveService, IssueService } from "services/issue";
|
||||
import { IssueArchiveService, IssueDraftService, IssueService } from "services/issue";
|
||||
// types
|
||||
import { TIssue } from "@plane/types";
|
||||
import { computedFn } from "mobx-utils";
|
||||
|
|
@ -8,7 +8,12 @@ import { IIssueDetail } from "./root.store";
|
|||
|
||||
export interface IIssueStoreActions {
|
||||
// actions
|
||||
fetchIssue: (workspaceSlug: string, projectId: string, issueId: string, isArchived?: boolean) => Promise<TIssue>;
|
||||
fetchIssue: (
|
||||
workspaceSlug: string,
|
||||
projectId: string,
|
||||
issueId: string,
|
||||
issueType?: "DEFAULT" | "DRAFT" | "ARCHIVED"
|
||||
) => Promise<TIssue>;
|
||||
updateIssue: (workspaceSlug: string, projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>;
|
||||
removeIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise<void>;
|
||||
addIssueToCycle: (workspaceSlug: string, projectId: string, cycleId: string, issueIds: string[]) => Promise<void>;
|
||||
|
|
@ -34,6 +39,7 @@ export class IssueStore implements IIssueStore {
|
|||
// services
|
||||
issueService;
|
||||
issueArchiveService;
|
||||
issueDraftService;
|
||||
|
||||
constructor(rootStore: IIssueDetail) {
|
||||
makeObservable(this, {});
|
||||
|
|
@ -42,6 +48,7 @@ export class IssueStore implements IIssueStore {
|
|||
// services
|
||||
this.issueService = new IssueService();
|
||||
this.issueArchiveService = new IssueArchiveService();
|
||||
this.issueDraftService = new IssueDraftService();
|
||||
}
|
||||
|
||||
// helper methods
|
||||
|
|
@ -51,21 +58,54 @@ export class IssueStore implements IIssueStore {
|
|||
});
|
||||
|
||||
// actions
|
||||
fetchIssue = async (workspaceSlug: string, projectId: string, issueId: string, isArchived = false) => {
|
||||
fetchIssue = async (workspaceSlug: string, projectId: string, issueId: string, issueType = "DEFAULT") => {
|
||||
try {
|
||||
const query = {
|
||||
expand: "issue_reactions,issue_attachment,issue_link,parent",
|
||||
};
|
||||
|
||||
let issue: TIssue;
|
||||
let issuePayload: TIssue;
|
||||
|
||||
if (isArchived)
|
||||
if (issueType === "ARCHIVED")
|
||||
issue = await this.issueArchiveService.retrieveArchivedIssue(workspaceSlug, projectId, issueId, query);
|
||||
else if (issueType === "DRAFT")
|
||||
issue = await this.issueDraftService.getDraftIssueById(workspaceSlug, projectId, issueId, query);
|
||||
else issue = await this.issueService.retrieve(workspaceSlug, projectId, issueId, query);
|
||||
|
||||
if (!issue) throw new Error("Issue not found");
|
||||
|
||||
this.rootIssueDetailStore.rootIssueStore.issues.addIssue([issue], true);
|
||||
issuePayload = {
|
||||
id: issue?.id,
|
||||
sequence_id: issue?.sequence_id,
|
||||
name: issue?.name,
|
||||
description_html: issue?.description_html,
|
||||
sort_order: issue?.sort_order,
|
||||
state_id: issue?.state_id,
|
||||
priority: issue?.priority,
|
||||
label_ids: issue?.label_ids,
|
||||
assignee_ids: issue?.assignee_ids,
|
||||
estimate_point: issue?.estimate_point,
|
||||
sub_issues_count: issue?.sub_issues_count,
|
||||
attachment_count: issue?.attachment_count,
|
||||
link_count: issue?.link_count,
|
||||
project_id: issue?.project_id,
|
||||
parent_id: issue?.parent_id,
|
||||
cycle_id: issue?.cycle_id,
|
||||
module_ids: issue?.module_ids,
|
||||
created_at: issue?.created_at,
|
||||
updated_at: issue?.updated_at,
|
||||
start_date: issue?.start_date,
|
||||
target_date: issue?.target_date,
|
||||
completed_at: issue?.completed_at,
|
||||
archived_at: issue?.archived_at,
|
||||
created_by: issue?.created_by,
|
||||
updated_by: issue?.updated_by,
|
||||
is_draft: issue?.is_draft,
|
||||
is_subscribed: issue?.is_subscribed,
|
||||
};
|
||||
|
||||
this.rootIssueDetailStore.rootIssueStore.issues.addIssue([issuePayload], true);
|
||||
|
||||
// store handlers from issue detail
|
||||
// parent
|
||||
|
|
|
|||
|
|
@ -140,8 +140,12 @@ export class IssueDetail implements IIssueDetail {
|
|||
toggleRelationModal = (value: TIssueRelationTypes | null) => (this.isRelationModalOpen = value);
|
||||
|
||||
// issue
|
||||
fetchIssue = async (workspaceSlug: string, projectId: string, issueId: string, isArchived = false) =>
|
||||
this.issue.fetchIssue(workspaceSlug, projectId, issueId, isArchived);
|
||||
fetchIssue = async (
|
||||
workspaceSlug: string,
|
||||
projectId: string,
|
||||
issueId: string,
|
||||
issueType: "DEFAULT" | "ARCHIVED" | "DRAFT" = "DEFAULT"
|
||||
) => this.issue.fetchIssue(workspaceSlug, projectId, issueId, issueType);
|
||||
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) =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue