From 95b1e5977464f654a1ee3c2f3d4017f5014dfbde Mon Sep 17 00:00:00 2001 From: Prateek Shourya Date: Mon, 9 Jun 2025 21:36:47 +0530 Subject: [PATCH 1/2] fix: update group key handling in issue store utilities for state groups - Introduced a new function to determine the default group key based on the provided groupByKey. - Updated references to use the new function for improved clarity and maintainability. - Adjusted the mapping for "state_detail.group" in the ISSUE_GROUP_BY_KEY to ensure consistency. - Enhanced the getArrayStringArray method to handle group values more effectively. --- .../store/issue/helpers/base-issues-utils.ts | 17 ++++++-- .../store/issue/helpers/base-issues.store.ts | 41 +++++++++++++------ 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/web/core/store/issue/helpers/base-issues-utils.ts b/web/core/store/issue/helpers/base-issues-utils.ts index dcb4e86adb4..33171594900 100644 --- a/web/core/store/issue/helpers/base-issues-utils.ts +++ b/web/core/store/issue/helpers/base-issues-utils.ts @@ -5,7 +5,6 @@ import isEmpty from "lodash/isEmpty"; import orderBy from "lodash/orderBy"; import set from "lodash/set"; import uniq from "lodash/uniq"; -import { runInAction } from "mobx"; import { ALL_ISSUES, EIssueFilterType, FILTER_TO_ISSUE_MAP, ISSUE_PRIORITIES } from "@plane/constants"; import { IIssueDisplayFilterOptions, @@ -318,10 +317,22 @@ export const getGroupedWorkItemIds = ( }; } + // Get the default key for the group by key + const getDefaultGroupKey = (groupByKey: TIssueGroupByOptions) => { + switch (groupByKey) { + case "state_detail.group": + return "state__group"; + case null: + return null; + default: + return ISSUE_GROUP_BY_KEY[groupByKey]; + } + }; + // Group work items - const groupKey = ISSUE_GROUP_BY_KEY[groupByKey]; + const groupKey = getDefaultGroupKey(groupByKey); const groupedWorkItems = groupBy(workItems, (item) => { - const value = item[groupKey]; + const value = groupKey ? item[groupKey] : null; if (Array.isArray(value)) { if (value.length === 0) return "None"; // Sort & join to build deterministic set-like key diff --git a/web/core/store/issue/helpers/base-issues.store.ts b/web/core/store/issue/helpers/base-issues.store.ts index b28ff13faad..30ac6fb04d4 100644 --- a/web/core/store/issue/helpers/base-issues.store.ts +++ b/web/core/store/issue/helpers/base-issues.store.ts @@ -121,7 +121,7 @@ export interface IBaseIssuesStore { export const ISSUE_GROUP_BY_KEY: Record = { project: "project_id", state: "state_id", - "state_detail.group": "state__group" as keyof TIssue, // state_detail.group is only being used for state_group display, + "state_detail.group": "state_id", // state_detail.group is only being used for state_group display, priority: "priority", labels: "label_ids", created_by: "created_by", @@ -137,7 +137,7 @@ export const ISSUE_FILTER_DEFAULT_DATA: Record | undefined, value: string | string[] | undefined | null, @@ -1708,9 +1709,23 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore { // if array return the array if (Array.isArray(value)) return value; - // if the groupKey is state group then return the group based on state_id + return this.getDefaultGroupValue(issueObject, value, groupByKey); + }; + + // /** + // * Gets the default value for a group when the primary value is empty + // * @param issueObject - The issue object to extract fallback values from + // * @param groupByKey - The group by key to determine fallback logic + // * @returns Default group value as string array + // */ + private getDefaultGroupValue = ( + issueObject: Partial, + value: string, + groupByKey?: TIssueGroupByOptions + ): string[] => { + // Handle special case for state group if (groupByKey === "state_detail.group") { - return [this.rootIssueStore.rootStore.state.stateMap?.[value]?.group]; + return [this.rootIssueStore.rootStore.state.stateMap?.[value]?.group ?? issueObject.state__group]; } return [value]; From ce45472e4854e0072a063cd80c3491bacd9c6a17 Mon Sep 17 00:00:00 2001 From: Prateek Shourya Date: Mon, 9 Jun 2025 21:37:15 +0530 Subject: [PATCH 2/2] refactor: clean up filters constants --- packages/constants/src/issue/filter.ts | 40 +------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/packages/constants/src/issue/filter.ts b/packages/constants/src/issue/filter.ts index 2e29474eb8d..46275d75199 100644 --- a/packages/constants/src/issue/filter.ts +++ b/packages/constants/src/issue/filter.ts @@ -136,45 +136,7 @@ export const ISSUE_DISPLAY_FILTERS_BY_PAGE: TIssueFiltersToDisplayByPageType = { ], display_properties: ISSUE_DISPLAY_PROPERTIES_KEYS, display_filters: { - group_by: [ - "state", - "cycle", - "module", - "state_detail.group", - "priority", - "labels", - "assignees", - "created_by", - null, - ], - order_by: ["sort_order", "-created_at", "-updated_at", "start_date", "-priority"], - type: [null, "active", "backlog"], - }, - extra_options: { - access: true, - values: ["show_empty_groups"], - }, - }, - }, - draft_issues: { - list: { - filters: ["priority", "state_group", "cycle", "module", "labels", "start_date", "target_date", "issue_type"], - display_properties: ISSUE_DISPLAY_PROPERTIES_KEYS, - display_filters: { - group_by: ["state_detail.group", "cycle", "module", "priority", "project", "labels", null], - order_by: ["sort_order", "-created_at", "-updated_at", "start_date", "-priority"], - type: [null, "active", "backlog"], - }, - extra_options: { - access: true, - values: ["show_empty_groups"], - }, - }, - kanban: { - filters: ["priority", "state_group", "cycle", "module", "labels", "start_date", "target_date", "issue_type"], - display_properties: ISSUE_DISPLAY_PROPERTIES_KEYS, - display_filters: { - group_by: ["state_detail.group", "cycle", "module", "priority", "project", "labels"], + group_by: ["state", "cycle", "module", "priority", "labels", "assignees", "created_by", null], order_by: ["sort_order", "-created_at", "-updated_at", "start_date", "-priority"], type: [null, "active", "backlog"], },