plane/web/store/issue.ts
Aaryan Khandelwal daa3094911
chore: update issue detail store to handle peek overview (#2237)
* chore: dynamic position dropdown (#2138)

* chore: dynamic position state dropdown for issue view

* style: state select dropdown styling

* fix: state icon attribute names

* chore: state select dynamic dropdown

* chore: member select dynamic dropdown

* chore: label select dynamic dropdown

* chore: priority select dynamic dropdown

* chore: label select dropdown improvement

* refactor: state dropdown location

* chore: dropdown improvement and code refactor

* chore: dynamic dropdown hook type added

---------

Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com>

* fix: fields not getting selected in the create issue form (#2212)

* fix: hydration error and draft issue workflow

* fix: build error

* fix: properties getting de-selected after create, module & cycle not getting auto-select on the form

* fix: display layout, props being updated directly

* chore: sub issues count in individual issue (#2221)

* Implemented nested issues in the sub issues section in issue detail page (#2233)

* feat: subissues infinte level

* feat: updated UI for sub issues

* feat: subissues new ui and nested sub issues in issue detail

* chore: removed repeated code

* refactor: product updates modal layout (#2225)

* fix: handle no issues in custom analytics (#2226)

* fix: activity label color (#2227)

* fix: profile issues layout switch (#2228)

* chore: update service imports

* chore: update issue detail store to handle peek overview

---------

Co-authored-by: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com>
Co-authored-by: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com>
Co-authored-by: Bavisetti Narayan <72156168+NarayanBavisetti@users.noreply.github.com>
Co-authored-by: guru_sainath <gurusainath007@gmail.com>
2023-09-21 17:50:43 +05:30

96 lines
2.4 KiB
TypeScript

import { observable, action, computed, makeObservable, runInAction } from "mobx";
import { IIssue } from "types";
import { RootStore } from "./root";
export interface IIssueStore {
loader: boolean;
error: any | null;
issues: {
[project_id: string]: {
grouped: {
[issueId: string]: IIssue[];
};
ungrouped: IIssue[];
};
};
addIssueToIssuesStore: (projectId: string, issue: IIssue) => void;
updateIssueInIssuesStore: (projectId: string, issue: IIssue) => void;
deleteIssueFromIssuesStore: (projectId: string, issueId: string) => void;
}
class IssueStore implements IIssueStore {
loader: boolean = false;
error: any | null = null;
issues: {
[project_id: string]: {
grouped: {
[issueId: string]: IIssue[];
};
ungrouped: IIssue[];
};
} = {};
rootStore;
constructor(_rootStore: RootStore) {
makeObservable(this, {
// observable
loader: observable.ref,
error: observable.ref,
issues: observable.ref,
addIssueToIssuesStore: action,
updateIssueInIssuesStore: action,
deleteIssueFromIssuesStore: action,
});
this.rootStore = _rootStore;
}
addIssueToIssuesStore = (projectId: string, issue: IIssue) => {
runInAction(() => {
this.rootStore.issue.issues = {
...this.rootStore.issue.issues,
[projectId]: {
...this.rootStore.issue.issues[projectId],
ungrouped: [...this.rootStore.issue.issues[projectId].ungrouped, issue],
},
};
});
};
updateIssueInIssuesStore = (projectId: string, issue: IIssue) => {
const newUngroupedIssues = this.rootStore.issue.issues[projectId].ungrouped.map((i) => ({
...i,
...(i.id === issue.id ? issue : {}),
}));
runInAction(() => {
this.rootStore.issue.issues = {
...this.rootStore.issue.issues,
[projectId]: {
...this.rootStore.issue.issues[projectId],
ungrouped: newUngroupedIssues,
},
};
});
};
deleteIssueFromIssuesStore = (projectId: string, issueId: string) => {
const newUngroupedIssues = this.rootStore.issue.issues[projectId].ungrouped.filter((i) => i.id !== issueId);
runInAction(() => {
this.rootStore.issue.issues = {
...this.rootStore.issue.issues,
[projectId]: {
...this.rootStore.issue.issues[projectId],
ungrouped: newUngroupedIssues,
},
};
});
};
}
export default IssueStore;