[WEB-4283] fix: update group key handling in issue store utilities for state groups#7191
Conversation
- 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.
WalkthroughThis update refactors the issue grouping and filtering logic by simplifying group-by options, adjusting group key mappings, and improving value handling for the Changes
Sequence Diagram(s)sequenceDiagram
participant UI
participant Store
participant Utils
UI->>Store: Request grouped issue IDs (groupByKey)
Store->>Utils: getDefaultGroupKey(groupByKey)
Utils-->>Store: Return normalized group key
Store->>Store: getDefaultGroupValue(issue, value, groupByKey)
Store-->>UI: Return grouped issue IDs
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Pull Request Linked with Plane Work Items Comment Automatically Generated by Plane |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
web/core/store/issue/helpers/base-issues.store.ts (1)
1693-1713: Consider improving the method delegation and documentation.The refactoring of
getArrayStringArrayto delegate togetDefaultGroupValueis good, but the current implementation could be cleaner:getArrayStringArray = ( issueObject: Partial<TIssue> | undefined, value: string | string[] | undefined | null, groupByKey?: TIssueGroupByOptions | undefined ): string[] => { // if issue object is undefined return empty array if (!issueObject) return []; // if value is not defined, return None value in array if (!value || isEmpty(value)) return ["None"]; // if array return the array if (Array.isArray(value)) return value; - return this.getDefaultGroupValue(issueObject, value, groupByKey); + // Handle single string values + return this.getDefaultGroupValue(issueObject, value, groupByKey); };Also, consider updating the JSDoc comments to reflect the new delegation pattern and the special handling for state groups.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/constants/src/issue/filter.ts(1 hunks)web/core/store/issue/helpers/base-issues-utils.ts(1 hunks)web/core/store/issue/helpers/base-issues.store.ts(6 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
web/core/store/issue/helpers/base-issues-utils.ts (2)
packages/types/src/view-props.d.ts (1)
TIssueGroupByOptions(5-17)web/core/store/issue/helpers/base-issues.store.ts (2)
ISSUE_GROUP_BY_KEY(121-133)groupBy(311-322)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyze (javascript)
🔇 Additional comments (7)
web/core/store/issue/helpers/base-issues-utils.ts (2)
320-330: LGTM: Well-structured helper function with clear special case handling.The
getDefaultGroupKeyhelper function centralizes the group key mapping logic and correctly handles the special case for"state_detail.group"by returning"state__group"instead of using the constant mapping. This aligns with the PR objective to fix state group display issues.
333-335: Improve null safety with cleaner logic.The changes improve null safety by using the helper function and handling the null case more explicitly. The logic correctly handles when
groupKeyis null by settingvaluetonull.packages/constants/src/issue/filter.ts (1)
139-139:Details
✅ Verification successful
Verify the impact of removing grouping options.
The
group_byarray has been simplified by removing"state_detail.group"and"project"options. While this aligns with the refactoring objectives, please ensure this change doesn't break existing functionality for users who may be using these grouping options on archived issues.
🏁 Script executed:
#!/bin/bash # Description: Check if archived issues still use the removed grouping options elsewhere in the codebase # Search for usage of state_detail.group with archived issues rg -A 3 -B 3 "state_detail\.group.*archived|archived.*state_detail\.group" # Search for project grouping with archived issues rg -A 3 -B 3 "project.*archived_issues|archived_issues.*project" --type tsLength of output: 1515
No references to removed grouping options found – change is safe.
Ripgrep searches for
"state_detail.group"and"project"in the context of archived issues returned no matches. Removing these options fromarchived_issues.list.display_filters.group_bywill not break existing functionality.web/core/store/issue/helpers/base-issues.store.ts (4)
140-140: Ensure consistency in the ISSUE_FILTER_DEFAULT_DATA mapping.The mapping has been updated from
"state_group"to"state__group". Please verify this change is intentional and aligns with the data structure expectations throughout the codebase.
597-597: Excellent variable naming improvement.The rename from
issueGroupKeytoissueGroupKeyValuebetter reflects that this variable holds the value of the issue property rather than the key itself. This improves code clarity and maintainability.
1721-1732: Well-implemented helper method with proper state group handling.The new
getDefaultGroupValuemethod correctly handles the special case for"state_detail.group"by looking up the state group from the state map and falling back to the issue'sstate__groupproperty. This appears to be the core fix for the issue where work items weren't appearing immediately when grouped by state group.The implementation is solid with proper fallback logic.
124-124:Details
✅ Verification successful
Verify the mapping change aligns with the new group key logic.
The mapping for
"state_detail.group"has been changed from"state__group"to"state_id". This change should align with the new helper function inbase-issues-utils.tsthat returns"state__group"for this key. Please ensure this mapping change is correct and consistent with the overall refactoring.
🏁 Script executed:
#!/bin/bash # Description: Verify consistency between the mapping changes and helper function usage # Check how ISSUE_GROUP_BY_KEY is used with state_detail.group rg -A 5 -B 5 "ISSUE_GROUP_BY_KEY.*state_detail\.group|state_detail\.group.*ISSUE_GROUP_BY_KEY" # Check usage of getDefaultGroupKey function rg -A 5 -B 5 "getDefaultGroupKey"Length of output: 1928
🏁 Script executed:
#!/bin/bash # Print context around ISSUE_GROUP_BY_KEY and related mappings echo "=== ISSUE_GROUP_BY_KEY ===" rg -C5 'ISSUE_GROUP_BY_KEY' -n web/core/store/issue/helpers/base-issues.store.ts echo echo "=== state_detail.group mapping ===" rg -C3 'state_detail\.group' -n web/core/store/issue/helpers/base-issues.store.ts echo echo "=== ISSUE_FILTER_DEFAULT_DATA ===" rg -C5 'ISSUE_FILTER_DEFAULT_DATA' -n web/core/store/issue/helpers/base-issues.store.tsLength of output: 2938
Mapping for “state_detail.group” is correct and consistent with the refactoring
The updated
ISSUE_GROUP_BY_KEY["state_detail.group"] = "state_id"aligns with the newgetDefaultGroupKeyhelper—which special-cases this key to return"state__group"when grouping—and the unchangedISSUE_FILTER_DEFAULT_DATA["state_detail.group"] = "state__group"for default filters. No further changes are needed.
…r state groups (#7191) * 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. * refactor: clean up filters constants
Description
Type of Change
Summary by CodeRabbit