[WEB-1492] fix: resolved issue creation error in layouts while group_by and sub_group_by filters applied in quick add (#4682)

* fix: resolved issue creation error in layouts while group_by and sub_group_by filters applied in quick add

* fix: updated braces in conditions
This commit is contained in:
guru_sainath 2024-06-03 14:27:39 +05:30 committed by GitHub
parent 5322c0e57b
commit a428bc16c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 82 additions and 65 deletions

View File

@ -148,20 +148,20 @@ export class CycleIssues extends IssueHelperStore implements ICycleIssues {
const cycleIssueIds = this.issues[cycleId]; const cycleIssueIds = this.issues[cycleId];
if (!cycleIssueIds) return; if (!cycleIssueIds) return;
const _issues = this.rootIssueStore.issues.getIssuesByIds(cycleIssueIds, "un-archived"); const currentIssues = this.rootIssueStore.issues.getIssuesByIds(cycleIssueIds, "un-archived");
if (!_issues) return []; if (!currentIssues) return [];
let issues: TGroupedIssues | TSubGroupedIssues | TUnGroupedIssues = []; let issues: TGroupedIssues | TSubGroupedIssues | TUnGroupedIssues = [];
if (layout === "list" && orderBy) { if (layout === "list" && orderBy) {
if (groupBy) issues = this.groupedIssues(groupBy, orderBy, _issues); if (groupBy) issues = this.groupedIssues(groupBy, orderBy, currentIssues);
else issues = this.unGroupedIssues(orderBy, _issues); else issues = this.unGroupedIssues(orderBy, currentIssues);
} else if (layout === "kanban" && groupBy && orderBy) { } else if (layout === "kanban" && groupBy && orderBy) {
if (subGroupBy) issues = this.subGroupedIssues(subGroupBy, groupBy, orderBy, _issues); if (subGroupBy) issues = this.subGroupedIssues(subGroupBy, groupBy, orderBy, currentIssues);
else issues = this.groupedIssues(groupBy, orderBy, _issues); else issues = this.groupedIssues(groupBy, orderBy, currentIssues);
} else if (layout === "calendar") issues = this.groupedIssues("target_date", "target_date", _issues, true); } else if (layout === "calendar") issues = this.groupedIssues("target_date", "target_date", currentIssues, true);
else if (layout === "spreadsheet") issues = this.unGroupedIssues(orderBy ?? "-created_at", _issues); else if (layout === "spreadsheet") issues = this.unGroupedIssues(orderBy ?? "-created_at", currentIssues);
else if (layout === "gantt_chart") issues = this.unGroupedIssues(orderBy ?? "sort_order", _issues); else if (layout === "gantt_chart") issues = this.unGroupedIssues(orderBy ?? "sort_order", currentIssues);
return issues; return issues;
} }
@ -301,14 +301,17 @@ export class CycleIssues extends IssueHelperStore implements ICycleIssues {
}); });
} }
if (data.module_ids && data.module_ids.length > 0) { const currentModuleIds =
data.module_ids && data.module_ids.length > 0 ? data.module_ids.filter((moduleId) => moduleId != "None") : [];
if (currentModuleIds.length > 0) {
await this.rootStore.moduleIssues.changeModulesInIssue( await this.rootStore.moduleIssues.changeModulesInIssue(
workspaceSlug, workspaceSlug,
projectId, projectId,
response.id, response.id,
data.module_ids, currentModuleIds,
[] []
) );
} }
this.rootIssueStore.rootStore.cycle.fetchCycleDetails(workspaceSlug, projectId, cycleId); this.rootIssueStore.rootStore.cycle.fetchCycleDetails(workspaceSlug, projectId, cycleId);

View File

@ -1,6 +1,5 @@
import concat from "lodash/concat"; import concat from "lodash/concat";
import pull from "lodash/pull"; import pull from "lodash/pull";
import isEmpty from "lodash/isEmpty";
import set from "lodash/set"; import set from "lodash/set";
import uniq from "lodash/uniq"; import uniq from "lodash/uniq";
import update from "lodash/update"; import update from "lodash/update";
@ -148,20 +147,20 @@ export class ModuleIssues extends IssueHelperStore implements IModuleIssues {
const moduleIssueIds = this.issues[moduleId]; const moduleIssueIds = this.issues[moduleId];
if (!moduleIssueIds) return; if (!moduleIssueIds) return;
const _issues = this.rootIssueStore.issues.getIssuesByIds(moduleIssueIds, "un-archived"); const currentIssues = this.rootIssueStore.issues.getIssuesByIds(moduleIssueIds, "un-archived");
if (!_issues) return []; if (!currentIssues) return [];
let issues: TGroupedIssues | TSubGroupedIssues | TUnGroupedIssues = []; let issues: TGroupedIssues | TSubGroupedIssues | TUnGroupedIssues = [];
if (layout === "list" && orderBy) { if (layout === "list" && orderBy) {
if (groupBy) issues = this.groupedIssues(groupBy, orderBy, _issues); if (groupBy) issues = this.groupedIssues(groupBy, orderBy, currentIssues);
else issues = this.unGroupedIssues(orderBy, _issues); else issues = this.unGroupedIssues(orderBy, currentIssues);
} else if (layout === "kanban" && groupBy && orderBy) { } else if (layout === "kanban" && groupBy && orderBy) {
if (subGroupBy) issues = this.subGroupedIssues(subGroupBy, groupBy, orderBy, _issues); if (subGroupBy) issues = this.subGroupedIssues(subGroupBy, groupBy, orderBy, currentIssues);
else issues = this.groupedIssues(groupBy, orderBy, _issues); else issues = this.groupedIssues(groupBy, orderBy, currentIssues);
} else if (layout === "calendar") issues = this.groupedIssues("target_date", "target_date", _issues, true); } else if (layout === "calendar") issues = this.groupedIssues("target_date", "target_date", currentIssues, true);
else if (layout === "spreadsheet") issues = this.unGroupedIssues(orderBy ?? "-created_at", _issues); else if (layout === "spreadsheet") issues = this.unGroupedIssues(orderBy ?? "-created_at", currentIssues);
else if (layout === "gantt_chart") issues = this.unGroupedIssues(orderBy ?? "sort_order", _issues); else if (layout === "gantt_chart") issues = this.unGroupedIssues(orderBy ?? "sort_order", currentIssues);
return issues; return issues;
} }
@ -302,8 +301,9 @@ export class ModuleIssues extends IssueHelperStore implements IModuleIssues {
}); });
} }
if (data.cycle_id && data.cycle_id !== "") { const currentCycleId = data.cycle_id !== "" && data.cycle_id === "None" ? undefined : data.cycle_id;
await this.rootStore.cycleIssues.addCycleToIssue(workspaceSlug, projectId, data.cycle_id, response.id) if (currentCycleId) {
await this.rootStore.cycleIssues.addCycleToIssue(workspaceSlug, projectId, currentCycleId, response.id);
} }
this.rootIssueStore.rootStore.module.fetchModuleDetails(workspaceSlug, projectId, moduleId); this.rootIssueStore.rootStore.module.fetchModuleDetails(workspaceSlug, projectId, moduleId);

View File

@ -1,9 +1,9 @@
import pull from "lodash/pull"; import pull from "lodash/pull";
import set from "lodash/set"; import set from "lodash/set";
import { action, observable, makeObservable, computed, runInAction } from "mobx"; import { action, observable, makeObservable, computed, runInAction } from "mobx";
import { TIssue, TLoader, TGroupedIssues, TSubGroupedIssues, TUnGroupedIssues, ViewFlags } from "@plane/types";
// base class // base class
import { IssueService } from "@/services/issue/issue.service"; import { IssueService } from "@/services/issue/issue.service";
import { TIssue, TLoader, TGroupedIssues, TSubGroupedIssues, TUnGroupedIssues, ViewFlags } from "@plane/types";
import { IssueHelperStore } from "../helpers/issue-helper.store"; import { IssueHelperStore } from "../helpers/issue-helper.store";
// services // services
// types // types
@ -97,20 +97,20 @@ export class ProjectViewIssues extends IssueHelperStore implements IProjectViewI
const viewIssueIds = this.issues[viewId]; const viewIssueIds = this.issues[viewId];
if (!viewIssueIds) return; if (!viewIssueIds) return;
const _issues = this.rootStore.issues.getIssuesByIds(viewIssueIds, "un-archived"); const currentIssues = this.rootStore.issues.getIssuesByIds(viewIssueIds, "un-archived");
if (!_issues) return []; if (!currentIssues) return [];
let issues: TGroupedIssues | TSubGroupedIssues | TUnGroupedIssues = []; let issues: TGroupedIssues | TSubGroupedIssues | TUnGroupedIssues = [];
if (layout === "list" && orderBy) { if (layout === "list" && orderBy) {
if (groupBy) issues = this.groupedIssues(groupBy, orderBy, _issues); if (groupBy) issues = this.groupedIssues(groupBy, orderBy, currentIssues);
else issues = this.unGroupedIssues(orderBy, _issues); else issues = this.unGroupedIssues(orderBy, currentIssues);
} else if (layout === "kanban" && groupBy && orderBy) { } else if (layout === "kanban" && groupBy && orderBy) {
if (subGroupBy) issues = this.subGroupedIssues(subGroupBy, groupBy, orderBy, _issues); if (subGroupBy) issues = this.subGroupedIssues(subGroupBy, groupBy, orderBy, currentIssues);
else issues = this.groupedIssues(groupBy, orderBy, _issues); else issues = this.groupedIssues(groupBy, orderBy, currentIssues);
} else if (layout === "calendar") issues = this.groupedIssues("target_date", "target_date", _issues, true); } else if (layout === "calendar") issues = this.groupedIssues("target_date", "target_date", currentIssues, true);
else if (layout === "spreadsheet") issues = this.unGroupedIssues(orderBy ?? "-created_at", _issues); else if (layout === "spreadsheet") issues = this.unGroupedIssues(orderBy ?? "-created_at", currentIssues);
else if (layout === "gantt_chart") issues = this.unGroupedIssues(orderBy ?? "sort_order", _issues); else if (layout === "gantt_chart") issues = this.unGroupedIssues(orderBy ?? "sort_order", currentIssues);
return issues; return issues;
} }
@ -247,18 +247,25 @@ export class ProjectViewIssues extends IssueHelperStore implements IProjectViewI
}); });
} }
if (data.cycle_id && data.cycle_id !== "") { const currentCycleId = data.cycle_id !== "" && data.cycle_id === "None" ? undefined : data.cycle_id;
await this.rootStore.cycleIssues.addCycleToIssue(workspaceSlug, projectId, data.cycle_id, response.id) const currentModuleIds =
data.module_ids && data.module_ids.length > 0 ? data.module_ids.filter((moduleId) => moduleId != "None") : [];
const multipleIssuePromises = [];
if (currentCycleId) {
multipleIssuePromises.push(
this.rootStore.cycleIssues.addCycleToIssue(workspaceSlug, projectId, currentCycleId, response.id)
);
} }
if (data.module_ids && data.module_ids.length > 0) { if (currentModuleIds.length > 0) {
await this.rootStore.moduleIssues.changeModulesInIssue( multipleIssuePromises.push(
workspaceSlug, this.rootStore.moduleIssues.changeModulesInIssue(workspaceSlug, projectId, response.id, currentModuleIds, [])
projectId, );
response.id, }
data.module_ids,
[] if (multipleIssuePromises && multipleIssuePromises.length > 0) {
) await Promise.all(multipleIssuePromises);
} }
return response; return response;

View File

@ -103,20 +103,20 @@ export class ProjectIssues extends IssueHelperStore implements IProjectIssues {
const projectIssueIds = this.issues[projectId]; const projectIssueIds = this.issues[projectId];
if (!projectIssueIds) return; if (!projectIssueIds) return;
const _issues = this.rootStore.issues.getIssuesByIds(projectIssueIds, "un-archived"); const currentIssues = this.rootStore.issues.getIssuesByIds(projectIssueIds, "un-archived");
if (!_issues) return []; if (!currentIssues) return [];
let issues: TGroupedIssues | TSubGroupedIssues | TUnGroupedIssues = []; let issues: TGroupedIssues | TSubGroupedIssues | TUnGroupedIssues = [];
if (layout === "list" && orderBy) { if (layout === "list" && orderBy) {
if (groupBy) issues = this.groupedIssues(groupBy, orderBy, _issues); if (groupBy) issues = this.groupedIssues(groupBy, orderBy, currentIssues);
else issues = this.unGroupedIssues(orderBy, _issues); else issues = this.unGroupedIssues(orderBy, currentIssues);
} else if (layout === "kanban" && groupBy && orderBy) { } else if (layout === "kanban" && groupBy && orderBy) {
if (subGroupBy) issues = this.subGroupedIssues(subGroupBy, groupBy, orderBy, _issues); if (subGroupBy) issues = this.subGroupedIssues(subGroupBy, groupBy, orderBy, currentIssues);
else issues = this.groupedIssues(groupBy, orderBy, _issues); else issues = this.groupedIssues(groupBy, orderBy, currentIssues);
} else if (layout === "calendar") issues = this.groupedIssues("target_date", "target_date", _issues, true); } else if (layout === "calendar") issues = this.groupedIssues("target_date", "target_date", currentIssues, true);
else if (layout === "spreadsheet") issues = this.unGroupedIssues(orderBy ?? "-created_at", _issues); else if (layout === "spreadsheet") issues = this.unGroupedIssues(orderBy ?? "-created_at", currentIssues);
else if (layout === "gantt_chart") issues = this.unGroupedIssues(orderBy ?? "sort_order", _issues); else if (layout === "gantt_chart") issues = this.unGroupedIssues(orderBy ?? "sort_order", currentIssues);
return issues; return issues;
} }
@ -252,20 +252,27 @@ export class ProjectIssues extends IssueHelperStore implements IProjectIssues {
}); });
} }
//TODO: error handling needs to be improved for rare cases const currentCycleId = data.cycle_id !== "" && data.cycle_id === "None" ? undefined : data.cycle_id;
if (data.cycle_id && data.cycle_id !== "") { const currentModuleIds =
await this.rootStore.cycleIssues.addCycleToIssue(workspaceSlug, projectId, data.cycle_id, response.id) data.module_ids && data.module_ids.length > 0 ? data.module_ids.filter((moduleId) => moduleId != "None") : [];
const multipleIssuePromises = [];
if (currentCycleId) {
multipleIssuePromises.push(
this.rootStore.cycleIssues.addCycleToIssue(workspaceSlug, projectId, currentCycleId, response.id)
);
} }
if (data.module_ids && data.module_ids.length > 0) { if (currentModuleIds.length > 0) {
await this.rootStore.moduleIssues.changeModulesInIssue( multipleIssuePromises.push(
workspaceSlug, this.rootStore.moduleIssues.changeModulesInIssue(workspaceSlug, projectId, response.id, currentModuleIds, [])
projectId, );
response.id,
data.module_ids,
[]
)
} }
if (multipleIssuePromises && multipleIssuePromises.length > 0) {
await Promise.all(multipleIssuePromises);
}
return response; return response;
} catch (error) { } catch (error) {
this.fetchIssues(workspaceSlug, projectId, "mutation"); this.fetchIssues(workspaceSlug, projectId, "mutation");