Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

fix module Quick add (#5039)

rahulrameshaf1496e3144d3
diff --git a/web/core/store/issue/helpers/base-issues.store.ts b/web/core/store/issue/helpers/base-issues.store.ts
index 3e70b66d35..524cda08d2 100644
--- a/web/core/store/issue/helpers/base-issues.store.ts
+++ b/web/core/store/issue/helpers/base-issues.store.ts
@@ -1041,6 +1041,43 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
}
}
+ /*
+ * add Modules to Array in a non optimistic way while creating issues
+ * @param workspaceSlug
+ * @param projectId
+ * @param issueId
+ * @param moduleIds array of modules to be added
+ */
+ async addModulesToIssue(workspaceSlug: string, projectId: string, issueId: string, moduleIds: string[]) {
+ // keep a copy of the original module ids
+ const originalModuleIds = get(this.rootIssueStore.issues.issuesMap, [issueId, "module_ids"]) ?? [];
+ try {
+ //Perform API call
+ await this.moduleService.addModulesToIssue(workspaceSlug, projectId, issueId, {
+ modules: moduleIds,
+ removed_modules: [],
+ });
+
+ runInAction(() => {
+ // get current Module Ids of the issue
+ let currentModuleIds = [...originalModuleIds];
+
+ // If current Module Id is included in the modules list, then add Issue to List
+ if (moduleIds.includes(this.moduleId ?? "")) this.addIssueToList(issueId);
+ currentModuleIds = uniq(concat([...currentModuleIds], moduleIds));
+
+ // For current Issue, update module Ids by calling current store's update Issue, without making an API call
+ this.updateIssue(workspaceSlug, projectId, issueId, { module_ids: currentModuleIds }, false);
+ });
+
+ if (moduleIds.includes(this.moduleId ?? "")) {
+ this.fetchParentStats(workspaceSlug, projectId);
+ }
+ } catch (error) {
+ throw error;
+ }
+ }
+
/*
* change modules array in issue
* @param workspaceSlug
diff --git a/web/core/store/issue/module/issue.store.ts b/web/core/store/issue/module/issue.store.ts
index 4f89f03663..8b592f8aba 100644
--- a/web/core/store/issue/module/issue.store.ts
+++ b/web/core/store/issue/module/issue.store.ts
@@ -209,7 +209,7 @@ export class ModuleIssues extends BaseIssuesStore implements IModuleIssues {
try {
const response = await super.createIssue(workspaceSlug, projectId, data, moduleId, false);
const moduleIds = data.module_ids && data.module_ids.length > 1 ? data.module_ids : [moduleId];
- await this.changeModulesInIssue(workspaceSlug, projectId, response.id, moduleIds, []);
+ await this.addModulesToIssue(workspaceSlug, projectId, response.id, moduleIds);
return response;
} catch (error) {