mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
ddb07dbe5f
* chore: removed inbox id * fix: inbox changes * chore: resolved merge conflicts * chore: inbox issue response changes * chore: inbox issue filters * fix: inbox implementation revamp * fix: type fixes * fix: pagination implementation * fix: inbox fixes * fix: pagination fixes * fix: inbox Issues pagination fixes * chore: triage state change * fix: inbox fixes * chore: filtering using boolean * chore: total results in the pagination * fix: inbox main content changes * fix: develop pull fixes * chore: resolved build erros in inbox issues * dev: fix migrations * chore: module, labels and assignee in inbox * chore: inbox issue order by * chore: inbox filters * chore: inbox ui revamp * chore: inbox type updated * chore: updated filters * chore: updated filter menmbers and date types in inbox issue filter * chore: inbox issue filter updated * chore: updated date filter in the inbox issue filter * chore: moved the current tab state from local state to store * chore: updated the filter and fetch request in the inbox issues * chore: updated tab change handler * chore: handled isEmpty in the issue filters query params * chore: inbox sidebar updated * chore: enabled create inbox issue in mobx * chore: replaced the key inbox_status to status * chore: inbox sidebar pagination * chore: updated inbox issue services * chore: inbox sidebar total count indicator * chore: create inbox issue updated * chore: updated inbox issue sidebar layout * chore: rendering issue detail in inbox issue * chore: inbox issue content updated * chore: create inbox issue modal description improvement * fix: updated delete functionality in inbox store * chore: updated multiple inbox issue creation * chore: handled loading, empty states and inbox user access permissions * chore: updated rendering issues in the sidebar * chore: inbox sidebar label improvement * chore: handled empty states * chore: disabled inbox empty state added * chore: module, labels and assignee in list endpoint * chore: labels in list endpoint * chore: inboc issue serializer * chore: representation in serializer * chore: super function * chore: inbox empty state updated * chore: implemented applied filters * chore: inbox empty state updated * chore: update date formats in applied filters * chore: inbox skeleton updated * chore: ui changes in the siebar list item * chore: removed the module and cycle ids * chore: inbox sidebar tab * chore: inbox actions * chore: updated inbox issue header actions * chore: updated inbox issue code cleanup * chore: loader improvement * chore: inbox sidebar improvement * chore: inbox sidebar empty state flicker * fix: inbox issue delete operation * chore: inbox issue title and description update indicator added * fix: resolved issue property rendering in initial load * chore: inbox sidebar and detail header improvement * fix: handling selected filter in the issue filters and applied filters * chore: inbox issue detail improvement * chore: inbox issue label updated * chore: inbox issue sidebar improvement * fix: handling issue description update when we move between the issues in inbox * chore: removed inbox issue helpers file * chore: boolean checked * chore: resolved file change requests --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com> Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: Anmol Singh Bhatia <anmolsinghbhatia@plane.so>
140 lines
4.5 KiB
TypeScript
140 lines
4.5 KiB
TypeScript
import set from "lodash/set";
|
|
import { makeObservable, observable, runInAction, action } from "mobx";
|
|
// services
|
|
// types
|
|
import { TIssue, TInboxIssue, TInboxIssueStatus } from "@plane/types";
|
|
import { InboxIssueService } from "@/services/inbox";
|
|
|
|
export interface IInboxIssueStore {
|
|
isLoading: boolean;
|
|
id: string;
|
|
status: TInboxIssueStatus;
|
|
issue: Partial<TIssue>;
|
|
snoozed_till: Date | undefined;
|
|
duplicate_to: string | undefined;
|
|
created_by: string | undefined;
|
|
// actions
|
|
updateInboxIssueStatus: (status: TInboxIssueStatus) => Promise<void>; // accept, decline
|
|
updateInboxIssueDuplicateTo: (issueId: string) => Promise<void>; // connecting the inbox issue to the project existing issue
|
|
updateInboxIssueSnoozeTill: (date: Date) => Promise<void>; // snooze the issue
|
|
updateIssue: (issue: Partial<TIssue>) => Promise<void>; // updating the issue
|
|
}
|
|
|
|
export class InboxIssueStore implements IInboxIssueStore {
|
|
// observables
|
|
isLoading: boolean = false;
|
|
id: string;
|
|
status: TInboxIssueStatus = -2;
|
|
issue: Partial<TIssue> = {};
|
|
snoozed_till: Date | undefined;
|
|
duplicate_to: string | undefined;
|
|
created_by: string | undefined;
|
|
workspaceSlug: string;
|
|
projectId: string;
|
|
// services
|
|
inboxIssueService;
|
|
|
|
constructor(workspaceSlug: string, projectId: string, data: TInboxIssue) {
|
|
this.id = data.id;
|
|
this.status = data.status;
|
|
this.issue = data?.issue;
|
|
this.snoozed_till = data?.snoozed_till ? new Date(data.snoozed_till) : undefined;
|
|
this.duplicate_to = data?.duplicate_to || undefined;
|
|
this.created_by = data?.created_by || undefined;
|
|
this.workspaceSlug = workspaceSlug;
|
|
this.projectId = projectId;
|
|
// services
|
|
this.inboxIssueService = new InboxIssueService();
|
|
// observable variables should be defined after the initialization of the values
|
|
makeObservable(this, {
|
|
id: observable,
|
|
status: observable,
|
|
issue: observable,
|
|
snoozed_till: observable,
|
|
duplicate_to: observable,
|
|
created_by: observable,
|
|
// actions
|
|
updateInboxIssueStatus: action,
|
|
updateInboxIssueDuplicateTo: action,
|
|
updateInboxIssueSnoozeTill: action,
|
|
updateIssue: action,
|
|
});
|
|
}
|
|
|
|
updateInboxIssueStatus = async (status: TInboxIssueStatus) => {
|
|
const previousData: Partial<TInboxIssue> = {
|
|
status: this.status,
|
|
};
|
|
try {
|
|
if (!this.issue.id) return;
|
|
set(this, "status", status);
|
|
await this.inboxIssueService.update(this.workspaceSlug, this.projectId, this.issue.id, {
|
|
status: status,
|
|
});
|
|
} catch {
|
|
runInAction(() => set(this, "status", previousData.status));
|
|
}
|
|
};
|
|
|
|
updateInboxIssueDuplicateTo = async (issueId: string) => {
|
|
const inboxStatus = 2;
|
|
const previousData: Partial<TInboxIssue> = {
|
|
status: this.status,
|
|
duplicate_to: this.duplicate_to,
|
|
};
|
|
try {
|
|
if (!this.issue.id) return;
|
|
set(this, "status", inboxStatus);
|
|
set(this, "duplicate_to", issueId);
|
|
await this.inboxIssueService.update(this.workspaceSlug, this.projectId, this.issue.id, {
|
|
status: inboxStatus,
|
|
duplicate_to: issueId,
|
|
});
|
|
} catch {
|
|
runInAction(() => {
|
|
set(this, "status", previousData.status);
|
|
set(this, "duplicate_to", previousData.duplicate_to);
|
|
});
|
|
}
|
|
};
|
|
|
|
updateInboxIssueSnoozeTill = async (date: Date) => {
|
|
const inboxStatus = 0;
|
|
const previousData: Partial<TInboxIssue> = {
|
|
status: this.status,
|
|
snoozed_till: this.snoozed_till,
|
|
};
|
|
try {
|
|
if (!this.issue.id) return;
|
|
set(this, "status", inboxStatus);
|
|
set(this, "snoozed_till", date);
|
|
await this.inboxIssueService.update(this.workspaceSlug, this.projectId, this.issue.id, {
|
|
status: inboxStatus,
|
|
snoozed_till: new Date(date),
|
|
});
|
|
} catch {
|
|
runInAction(() => {
|
|
set(this, "status", previousData.status);
|
|
set(this, "snoozed_till", previousData.snoozed_till);
|
|
});
|
|
}
|
|
};
|
|
|
|
updateIssue = async (issue: Partial<TIssue>) => {
|
|
const inboxIssue = this.issue;
|
|
try {
|
|
if (!this.issue.id) return;
|
|
Object.keys(issue).forEach((key) => {
|
|
const issueKey = key as keyof TIssue;
|
|
set(inboxIssue, issueKey, issue[issueKey]);
|
|
});
|
|
await this.inboxIssueService.updateIssue(this.workspaceSlug, this.projectId, this.issue.id, issue);
|
|
} catch {
|
|
Object.keys(issue).forEach((key) => {
|
|
const issueKey = key as keyof TIssue;
|
|
set(inboxIssue, issueKey, inboxIssue[issueKey]);
|
|
});
|
|
}
|
|
};
|
|
}
|