Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 1 addition & 39 deletions packages/constants/src/issue/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
},
Expand Down
17 changes: 14 additions & 3 deletions web/core/store/issue/helpers/base-issues-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
41 changes: 28 additions & 13 deletions web/core/store/issue/helpers/base-issues.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export interface IBaseIssuesStore {
export const ISSUE_GROUP_BY_KEY: Record<TIssueDisplayFilterOptions, keyof TIssue> = {
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",
Expand All @@ -137,7 +137,7 @@ export const ISSUE_FILTER_DEFAULT_DATA: Record<TIssueDisplayFilterOptions, keyof
cycle: "cycle_id",
module: "module_ids",
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__group", // state_detail.group is only being used for state_group display,
priority: "priority",
labels: "label_ids",
created_by: "created_by",
Expand Down Expand Up @@ -1594,11 +1594,11 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
// if unGrouped, then return the path as ALL_ISSUES along with orderByUpdates
if (!this.issueGroupKey) return action ? [{ path: [ALL_ISSUES], action }, ...orderByUpdates] : orderByUpdates;

const issueGroupKey = issue?.[this.issueGroupKey] as string | string[] | null | undefined;
const issueGroupKeyValue = issue?.[this.issueGroupKey] as string | string[] | null | undefined;
const issueBeforeUpdateGroupKey = issueBeforeUpdate?.[this.issueGroupKey] as string | string[] | null | undefined;
// if grouped, the get the Difference between the two issue properties (this.issueGroupKey) on which groupBy is performed
const groupActionsArray = getDifference(
this.getArrayStringArray(issue, issueGroupKey, this.groupBy),
this.getArrayStringArray(issue, issueGroupKeyValue, this.groupBy),
this.getArrayStringArray(issueBeforeUpdate, issueBeforeUpdateGroupKey, this.groupBy),
action
);
Expand Down Expand Up @@ -1632,7 +1632,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
groupActionsArray,
subGroupActionsArray,
this.getArrayStringArray(issueBeforeUpdate, issueBeforeUpdateGroupKey, this.groupBy),
this.getArrayStringArray(issue, issueGroupKey, this.groupBy),
this.getArrayStringArray(issue, issueGroupKeyValue, this.groupBy),
this.getArrayStringArray(issueBeforeUpdate, issueBeforeUpdateSubGroupKey, this.subGroupBy),
this.getArrayStringArray(issue, issueSubGroupKey, this.subGroupBy)
),
Expand Down Expand Up @@ -1690,12 +1690,13 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
return issueKeyActions;
}

/**
* get the groupByKey issue property on which actions are to be decided in the form of array
* @param value
* @param groupByKey
* @returns an array of issue property values
*/
// /**
// * Normalizes group values into a consistent string array format
// * @param issueObject - The issue object to extract values from
// * @param value - The raw value (string, array, or null/undefined)
// * @param groupByKey - The group by key to handle special cases
// * @returns Normalized array of string values
// */
getArrayStringArray = (
issueObject: Partial<TIssue> | undefined,
value: string | string[] | undefined | null,
Expand All @@ -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<TIssue>,
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];
Expand Down