[WEB-1301] chore: handled issues count in project, module, and cycle issues (#4538)
* chore: handled issues count in project, module, and cycle issues * chore: changed the typo from getIssuesCount to issuesCount
This commit is contained in:
parent
e2ac60e259
commit
4feec35773
7 changed files with 127 additions and 40 deletions
|
|
@ -6,6 +6,8 @@ import update from "lodash/update";
|
|||
import { action, observable, makeObservable, computed, runInAction } from "mobx";
|
||||
// types
|
||||
import { TIssue, TSubGroupedIssues, TGroupedIssues, TLoader, TUnGroupedIssues, ViewFlags } from "@plane/types";
|
||||
// helpers
|
||||
import { issueCountBasedOnFilters } from "@/helpers/issue.helper";
|
||||
// services
|
||||
import { CycleService } from "@/services/cycle.service";
|
||||
import { IssueService } from "@/services/issue";
|
||||
|
|
@ -21,6 +23,7 @@ export interface ICycleIssues {
|
|||
issues: { [cycle_id: string]: string[] };
|
||||
viewFlags: ViewFlags;
|
||||
// computed
|
||||
issuesCount: number;
|
||||
groupedIssueIds: TGroupedIssues | TSubGroupedIssues | TUnGroupedIssues | undefined;
|
||||
// actions
|
||||
getIssueIds: (groupId?: string, subGroupId?: string) => string[] | undefined;
|
||||
|
|
@ -60,7 +63,7 @@ export interface ICycleIssues {
|
|||
) => Promise<void>;
|
||||
removeIssueFromCycle: (workspaceSlug: string, projectId: string, cycleId: string, issueId: string) => Promise<void>;
|
||||
addCycleToIssue: (workspaceSlug: string, projectId: string, cycleId: string, issueId: string) => Promise<void>;
|
||||
removeCycleFromIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise<void>
|
||||
removeCycleFromIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise<void>;
|
||||
transferIssuesFromCycle: (
|
||||
workspaceSlug: string,
|
||||
projectId: string,
|
||||
|
|
@ -93,6 +96,7 @@ export class CycleIssues extends IssueHelperStore implements ICycleIssues {
|
|||
loader: observable.ref,
|
||||
issues: observable,
|
||||
// computed
|
||||
issuesCount: computed,
|
||||
groupedIssueIds: computed,
|
||||
// action
|
||||
fetchIssues: action,
|
||||
|
|
@ -113,6 +117,22 @@ export class CycleIssues extends IssueHelperStore implements ICycleIssues {
|
|||
this.cycleService = new CycleService();
|
||||
}
|
||||
|
||||
get issuesCount() {
|
||||
let issuesCount = 0;
|
||||
|
||||
const displayFilters = this.rootStore?.cycleIssuesFilter?.issueFilters?.displayFilters;
|
||||
const groupedIssueIds = this.groupedIssueIds;
|
||||
if (!displayFilters || !groupedIssueIds) return issuesCount;
|
||||
|
||||
const layout = displayFilters?.layout || undefined;
|
||||
const groupBy = displayFilters?.group_by || undefined;
|
||||
const subGroupBy = displayFilters?.sub_group_by || undefined;
|
||||
|
||||
if (!layout) return issuesCount;
|
||||
issuesCount = issueCountBasedOnFilters(groupedIssueIds, layout, groupBy, subGroupBy);
|
||||
return issuesCount;
|
||||
}
|
||||
|
||||
get groupedIssueIds() {
|
||||
const cycleId = this.rootIssueStore?.cycleId;
|
||||
if (!cycleId) return undefined;
|
||||
|
|
@ -336,14 +356,14 @@ export class CycleIssues extends IssueHelperStore implements ICycleIssues {
|
|||
|
||||
/**
|
||||
* Remove a cycle from issue
|
||||
* @param workspaceSlug
|
||||
* @param projectId
|
||||
* @param issueId
|
||||
* @returns
|
||||
* @param workspaceSlug
|
||||
* @param projectId
|
||||
* @param issueId
|
||||
* @returns
|
||||
*/
|
||||
removeCycleFromIssue = async (workspaceSlug: string, projectId: string, issueId: string) => {
|
||||
const issueCycleId = this.rootIssueStore.issues.getIssueById(issueId)?.cycle_id;
|
||||
if(!issueCycleId) return;
|
||||
if (!issueCycleId) return;
|
||||
try {
|
||||
// perform optimistic update, update store
|
||||
runInAction(() => {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import update from "lodash/update";
|
|||
import { action, observable, makeObservable, computed, runInAction } from "mobx";
|
||||
// types
|
||||
import { TIssue, TLoader, TGroupedIssues, TSubGroupedIssues, TUnGroupedIssues, ViewFlags } from "@plane/types";
|
||||
// helpers
|
||||
import { issueCountBasedOnFilters } from "@/helpers/issue.helper";
|
||||
// services
|
||||
import { IssueService } from "@/services/issue";
|
||||
import { ModuleService } from "@/services/module.service";
|
||||
|
|
@ -21,6 +23,7 @@ export interface IModuleIssues {
|
|||
issues: { [module_id: string]: string[] };
|
||||
viewFlags: ViewFlags;
|
||||
// computed
|
||||
issuesCount: number;
|
||||
groupedIssueIds: TGroupedIssues | TSubGroupedIssues | TUnGroupedIssues | undefined;
|
||||
// actions
|
||||
getIssueIds: (groupId?: string, subGroupId?: string) => string[] | undefined;
|
||||
|
|
@ -95,6 +98,7 @@ export class ModuleIssues extends IssueHelperStore implements IModuleIssues {
|
|||
loader: observable.ref,
|
||||
issues: observable,
|
||||
// computed
|
||||
issuesCount: computed,
|
||||
groupedIssueIds: computed,
|
||||
// action
|
||||
fetchIssues: action,
|
||||
|
|
@ -113,6 +117,22 @@ export class ModuleIssues extends IssueHelperStore implements IModuleIssues {
|
|||
this.moduleService = new ModuleService();
|
||||
}
|
||||
|
||||
get issuesCount() {
|
||||
let issuesCount = 0;
|
||||
|
||||
const displayFilters = this.rootIssueStore?.moduleIssuesFilter?.issueFilters?.displayFilters;
|
||||
const groupedIssueIds = this.groupedIssueIds;
|
||||
if (!displayFilters || !groupedIssueIds) return issuesCount;
|
||||
|
||||
const layout = displayFilters?.layout || undefined;
|
||||
const groupBy = displayFilters?.group_by || undefined;
|
||||
const subGroupBy = displayFilters?.sub_group_by || undefined;
|
||||
|
||||
if (!layout) return issuesCount;
|
||||
issuesCount = issueCountBasedOnFilters(groupedIssueIds, layout, groupBy, subGroupBy);
|
||||
return issuesCount;
|
||||
}
|
||||
|
||||
get groupedIssueIds() {
|
||||
const moduleId = this.rootIssueStore?.moduleId;
|
||||
if (!moduleId) return undefined;
|
||||
|
|
@ -370,9 +390,9 @@ export class ModuleIssues extends IssueHelperStore implements IModuleIssues {
|
|||
|
||||
/**
|
||||
* change modules array in issue
|
||||
* @param workspaceSlug
|
||||
* @param projectId
|
||||
* @param issueId
|
||||
* @param workspaceSlug
|
||||
* @param projectId
|
||||
* @param issueId
|
||||
* @param addModuleIds array of modules to be added
|
||||
* @param removeModuleIds array of modules to be removed
|
||||
*/
|
||||
|
|
@ -404,7 +424,7 @@ export class ModuleIssues extends IssueHelperStore implements IModuleIssues {
|
|||
});
|
||||
});
|
||||
});
|
||||
if(originalModuleIds){
|
||||
if (originalModuleIds) {
|
||||
// update the root issue map with the new module ids
|
||||
let currentModuleIds = concat([...originalModuleIds], addModuleIds);
|
||||
currentModuleIds = pull(currentModuleIds, ...removeModuleIds);
|
||||
|
|
@ -420,7 +440,6 @@ export class ModuleIssues extends IssueHelperStore implements IModuleIssues {
|
|||
if (!isEmpty(removeModuleIds)) {
|
||||
await this.moduleService.removeModulesFromIssueBulk(workspaceSlug, projectId, issueId, removeModuleIds);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
// revert the issue back to its original module ids
|
||||
set(this.rootStore.issues.issuesMap, [issueId, "module_ids"], originalModuleIds);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import update from "lodash/update";
|
|||
import { action, makeObservable, observable, runInAction, computed } from "mobx";
|
||||
// types
|
||||
import { TIssue, TGroupedIssues, TSubGroupedIssues, TLoader, TUnGroupedIssues, ViewFlags } from "@plane/types";
|
||||
// helpers
|
||||
import { issueCountBasedOnFilters } from "@/helpers/issue.helper";
|
||||
// base class
|
||||
import { IssueService, IssueArchiveService } from "@/services/issue";
|
||||
import { IssueHelperStore } from "../helpers/issue-helper.store";
|
||||
|
|
@ -17,6 +19,7 @@ export interface IProjectIssues {
|
|||
issues: Record<string, string[]>; // Record of project_id as key and issue_ids as value
|
||||
viewFlags: ViewFlags;
|
||||
// computed
|
||||
issuesCount: number;
|
||||
groupedIssueIds: TGroupedIssues | TSubGroupedIssues | TUnGroupedIssues | undefined;
|
||||
getIssueIds: (groupId?: string, subGroupId?: string) => string[] | undefined;
|
||||
// action
|
||||
|
|
@ -51,6 +54,7 @@ export class ProjectIssues extends IssueHelperStore implements IProjectIssues {
|
|||
loader: observable.ref,
|
||||
issues: observable,
|
||||
// computed
|
||||
issuesCount: computed,
|
||||
groupedIssueIds: computed,
|
||||
// action
|
||||
fetchIssues: action,
|
||||
|
|
@ -68,6 +72,22 @@ export class ProjectIssues extends IssueHelperStore implements IProjectIssues {
|
|||
this.issueArchiveService = new IssueArchiveService();
|
||||
}
|
||||
|
||||
get issuesCount() {
|
||||
let issuesCount = 0;
|
||||
|
||||
const displayFilters = this.rootStore?.projectIssuesFilter?.issueFilters?.displayFilters;
|
||||
const groupedIssueIds = this.groupedIssueIds;
|
||||
if (!displayFilters || !groupedIssueIds) return issuesCount;
|
||||
|
||||
const layout = displayFilters?.layout || undefined;
|
||||
const groupBy = displayFilters?.group_by || undefined;
|
||||
const subGroupBy = displayFilters?.sub_group_by || undefined;
|
||||
|
||||
if (!layout) return issuesCount;
|
||||
issuesCount = issueCountBasedOnFilters(groupedIssueIds, layout, groupBy, subGroupBy);
|
||||
return issuesCount;
|
||||
}
|
||||
|
||||
get groupedIssueIds() {
|
||||
const projectId = this.rootStore?.projectId;
|
||||
if (!projectId) return undefined;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue