Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WEB-2213] fix: group by persistence for list view #5590

Merged
merged 9 commits into from
Oct 3, 2024

Conversation

sharma01ketan
Copy link
Collaborator

@sharma01ketan sharma01ketan commented Sep 12, 2024

[WEB-2213]

Changes:

  • This PR adds the functionality of persisting the "state of groupings" for List View, by storing the applied grouping in the store and the localStorage.
  • The state of "Groupings" is shared among the List View and the Kanban View.
  • Correct values for the keys were not set previously, now they are set correctly.

New State:

  • The shared state is now persisted in the list view too.
  • Demonstrated only for "States" but changes apply to all "Group By" grouping states.
Screen.Recording.2024-09-12.at.2.40.10.PM.mov

Previous State:

  • Neither is the state for list view persisted nor is it shared with the kanban view
Screen.Recording.2024-09-12.at.2.44.18.PM.mov

[WEB-2213]

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced functionality for managing issue filters in Kanban and list layouts, allowing users to filter issues based on grouping preferences.
    • Introduced dynamic management of collapsed groups, improving interactivity and user experience.
  • Bug Fixes

    • Updated filter handling to correctly target specific categories (e.g., archived, cycle, draft, profile) instead of general project issues.
  • Improvements

    • Improved type safety for filter functions, reducing potential runtime errors and enhancing code maintainability.
    • Streamlined handling of group visibility and issue management within the Kanban layout, consolidating filter management into a single property and handler.
  • Documentation

    • Added comments to clarify potential issues with filter storage, aiding future development efforts.

@sharma01ketan sharma01ketan added this to the v0.23-dev milestone Sep 12, 2024
@sharma01ketan sharma01ketan self-assigned this Sep 12, 2024
Copy link
Contributor

coderabbitai bot commented Sep 12, 2024

Walkthrough

The changes introduce enhancements across several components, focusing on managing issue grouping and filtering in the Kanban layout. Key functionalities include the addition of handleCollapsedGroups to toggle grouping states and the introduction of collapsedGroups to track current filter states. These updates improve the interactivity and responsiveness of the components based on user actions, streamlining the overall control flow.

Changes

File Path Change Summary
web/core/components/issues/issue-layouts/list/base-list-root.tsx Enhanced BaseListRoot with handleCollapsedGroups for managing filter states and added collapsedGroups to track current filter states.
web/core/components/issues/issue-layouts/list/default.tsx Updated IList interface to include handleCollapsedGroups and collapsedGroups for improved management of issue grouping states.
web/core/components/issues/issue-layouts/list/headers/group-by-card.tsx Removed toggleListGroup from IHeaderGroupByCard and added handleCollapsedGroups for structured state management.
web/core/components/issues/issue-layouts/list/list-group.tsx Added handleCollapsedGroups and collapsedGroups to manage issue groups dynamically, simplifying state management logic.
web/core/components/issues/issue-layouts/kanban/base-kanban-root.tsx Refactored handleKanbanFilters to handleCollapsedGroups, updating its logic to manage collapsed groups.
web/core/components/issues/issue-layouts/kanban/default.tsx Replaced kanbanFilters with collapsedGroups in IKanBan interface and updated the logic in the KanBan component accordingly.
web/core/components/issues/issue-layouts/kanban/headers/group-by-card.tsx Updated IHeaderGroupByCard to use collapsedGroups and handleCollapsedGroups, modifying event handlers for group management.
web/core/components/issues/issue-layouts/kanban/headers/sub-group-by-card.tsx Renamed kanbanFilters to collapsedGroups and updated the handler to handleCollapsedGroups in IHeaderSubGroupByCard.
web/core/components/issues/issue-layouts/kanban/swimlanes.tsx Consistently renamed kanbanFilters to collapsedGroups across multiple interfaces and updated related handler functions.

Possibly related PRs

Suggested labels

🌟improvement

Suggested reviewers

  • sriramveeraghanta
  • rahulramesha
  • SatishGandham

Poem

🐇 In the meadow where filters play,
Hopping through issues, bright and gay.
With groups that toggle, oh what a sight,
Kanban's magic makes coding feel right!
So let us leap and dance with glee,
For every change brings joy, you see! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sharma01ketan sharma01ketan changed the title [WEB-2213] fix: states grouping persistence for list view [WEB-2213] fix: group by persistence for list view Sep 12, 2024
@sharma01ketan sharma01ketan marked this pull request as draft September 12, 2024 09:36
@sharma01ketan sharma01ketan marked this pull request as ready for review September 12, 2024 10:00
@@ -107,6 +112,21 @@ export const BaseListRoot = observer((props: IBaseListRoot) => {
[fetchNextIssues]
);

//kanbanFilters and EIssueFilterType.KANBAN_FILTERS are used becuase the state is shared between kanban view and list view
const handleCollapsedGroups = (toggle: "group_by" | "sub_group_by", value: string) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please wrap this with useCallback and add necessary dependencies.

Also for list view, it doesn't need the first variable, since it is always group_by

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the necessary changes:

  • Removed sub_group_by property from list view
  • Used useCallback for both list view and kanban view's filter handling function
  • Made naming consistent, Renamed kanbanFilters -> collapsedGroups and handleKanbanFilters -> handleCollapsedGroups for both list and kanban view

@sharma01ketan sharma01ketan marked this pull request as draft September 23, 2024 10:43
@sharma01ketan sharma01ketan marked this pull request as ready for review September 28, 2024 10:52
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (12)
web/core/components/issues/issue-layouts/kanban/headers/sub-group-by-card.tsx (1)

12-13: LGTM! Consider updating the type name for clarity.

The renaming from kanbanFilters to collapsedGroups and handleKanbanFilters to handleCollapsedGroups aligns well with the PR objectives of focusing on grouping persistence. The changes are consistent and maintain the existing type structure.

Consider updating the type name TIssueKanbanFilters to reflect the new terminology, e.g., TIssueCollapsedGroups. This would make the code more self-explanatory and consistent with the new naming convention.

web/core/components/issues/issue-layouts/list/default.tsx (2)

51-52: LGTM: New properties added to IList interface.

The addition of handleCollapsedGroups and collapsedGroups to the IList interface aligns with the PR objectives of implementing persistence for groupings and sharing state with the Kanban view.

Consider making the toggle parameter of handleCollapsedGroups more flexible for future use:

handleCollapsedGroups: (toggle: string, value: string) => void;

This would allow for easier extension if other toggle types are needed in the future.


Line range hint 136-171: LGTM: New props correctly passed to ListGroup.

The addition of handleCollapsedGroups and collapsedGroups props to the ListGroup component is correct and consistent with the changes made to the IList interface and List component.

There's a trailing space on line 136. Please remove it to resolve the linting error:

+136
web/core/components/issues/issue-layouts/list/headers/group-by-card.tsx (1)

Line range hint 1-168: Consider simplifying state management in future refactoring.

While the current implementation works correctly, there's an opportunity to simplify the component's state management in the future. The component currently uses a mix of local state (useState), props, and potentially global state (via MobX observer). Consider the following suggestions for future refactoring:

  1. Move more logic to the parent component or a central state management solution to reduce the complexity of this component.
  2. Evaluate if some of the local state (isOpen, openExistingIssueListModal) could be managed by the parent component to improve the overall state flow.
  3. Consider using custom hooks to encapsulate some of the logic and state management, which could improve reusability and testability.

These suggestions are not critical for the current PR but could be considered for future improvements to enhance maintainability and scalability of the codebase.

web/core/components/issues/issue-layouts/kanban/headers/group-by-card.tsx (1)

Line range hint 1-186: Consider broader impact of component changes.

While the changes to HeaderGroupByCard improve its implementation, they may have implications for other parts of the application:

  1. Parent components that use HeaderGroupByCard will need to be updated to provide the new collapsedGroups prop instead of kanbanFilters.
  2. The logic for managing collapsed groups may have moved to a different part of the application, potentially affecting state management.
  3. Other components that previously interacted with kanbanFilters might need to be updated to work with collapsedGroups.

To ensure a smooth transition:

  1. Review and update all usage of HeaderGroupByCard throughout the application.
  2. Verify that the state management for collapsed groups is consistent across different views (e.g., List View and Kanban View).
  3. Update any relevant documentation or comments to reflect the new prop names and functionality.
  4. Consider adding a brief comment in the component explaining the purpose of collapsedGroups and how it differs from the previous kanbanFilters.
web/core/components/issues/issue-layouts/kanban/default.tsx (2)

45-46: LGTM! Consider renaming the handler function for clarity.

The addition of collapsedGroups and handleCollapsedGroups to the IKanBan interface aligns well with the PR objectives of implementing state persistence for groupings. The types are well-defined, providing type safety and clarity.

Consider renaming handleCollapsedGroups to toggleCollapsedGroups to more accurately reflect its functionality. This would make the purpose of the function more immediately clear to other developers.

-  handleCollapsedGroups: (toggle: "group_by" | "sub_group_by", value: string) => void;
+  toggleCollapsedGroups: (toggle: "group_by" | "sub_group_by", value: string) => void;

130-130: LGTM! Consider extracting the condition for better readability.

The update to use collapsedGroups?.group_by.includes(_list.id) is correct and aligns with the new collapsedGroups property. The logic accurately determines whether to show or hide issues based on the collapsed state.

To improve readability, consider extracting the condition into a separate variable with a descriptive name. This would make the code more self-documenting:

-      if (collapsedGroups?.group_by.includes(_list.id)) groupVisibility.showIssues = false;
+      const isGroupCollapsed = collapsedGroups?.group_by.includes(_list.id);
+      if (isGroupCollapsed) groupVisibility.showIssues = false;
web/core/components/issues/issue-layouts/kanban/base-kanban-root.tsx (2)

209-224: LGTM! Consider a minor enhancement for clarity.

The handleCollapsedGroups function effectively implements the toggling logic for collapsing/expanding groups, aligning with the PR objective of implementing state persistence for groupings. The use of useCallback is appropriate for performance optimization.

Consider renaming the collapsedGroups variable within the function to updatedCollapsedGroups for better clarity:

- let collapsedGroups = issuesFilter?.issueFilters?.kanbanFilters?.[toggle] || [];
+ let updatedCollapsedGroups = issuesFilter?.issueFilters?.kanbanFilters?.[toggle] || [];
- if (collapsedGroups.includes(value)) {
-   collapsedGroups = collapsedGroups.filter((_value) => _value != value);
+ if (updatedCollapsedGroups.includes(value)) {
+   updatedCollapsedGroups = updatedCollapsedGroups.filter((_value) => _value != value);
  } else {
-   collapsedGroups.push(value);
+   updatedCollapsedGroups.push(value);
  }
  updateFilters(projectId?.toString() ?? "", EIssueFilterType.KANBAN_FILTERS, {
-   [toggle]: collapsedGroups,
+   [toggle]: updatedCollapsedGroups,
  });

This change would help distinguish between the input collapsedGroups and the updated version within the function.


271-272: LGTM! Props added for collapsed groups management.

The addition of handleCollapsedGroups and collapsedGroups props to the KanBanView component allows for proper management of the collapsed state of groups and subgroups, aligning with the PR objective of implementing state persistence for groupings.

For consistency with other props, consider using object shorthand notation:

- handleCollapsedGroups={handleCollapsedGroups}
- collapsedGroups={collapsedGroups}
+ {handleCollapsedGroups}
+ {collapsedGroups}

This change would make the prop passing style consistent with other props in the component.

web/core/components/issues/issue-layouts/list/list-group.tsx (2)

95-95: LGTM: Deriving isExpanded state from collapsedGroups.

The isExpanded state is now correctly derived from the collapsedGroups prop, which aligns with the PR objectives. This change ensures that the expansion state is consistent with the persisted groupings.

Consider improving readability by inverting the logic:

const isExpanded = !collapsedGroups?.group_by.includes(group.id);

to:

const isExpanded = collapsedGroups?.group_by.includes(group.id) !== true;

This makes the logic more explicit and easier to understand at a glance.


215-218: LGTM: Automatic group expansion on drop.

The addition of logic to automatically expand a collapsed group when an item is dropped into it improves the user experience and aligns with the PR objectives.

For consistency with the rest of the codebase, consider using strict equality and adding a space after if:

if (!isExpanded) {
  handleCollapsedGroups("group_by", group.id);
}
web/core/components/issues/issue-layouts/list/base-list-root.tsx (1)

115-115: Typo in comment: 'becuase' should be 'because'

There's a typo in the comment at line 115. The word 'becuase' should be corrected to 'because'.

Apply this diff to fix the typo:

-// kanbanFilters and EIssueFilterType.KANBAN_FILTERS are used becuase the state is shared between kanban view and list view
+// kanbanFilters and EIssueFilterType.KANBAN_FILTERS are used because the state is shared between kanban view and list view
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9c5a4d2 and df3d6bb.

📒 Files selected for processing (9)
  • web/core/components/issues/issue-layouts/kanban/base-kanban-root.tsx (2 hunks)
  • web/core/components/issues/issue-layouts/kanban/default.tsx (4 hunks)
  • web/core/components/issues/issue-layouts/kanban/headers/group-by-card.tsx (3 hunks)
  • web/core/components/issues/issue-layouts/kanban/headers/sub-group-by-card.tsx (1 hunks)
  • web/core/components/issues/issue-layouts/kanban/swimlanes.tsx (12 hunks)
  • web/core/components/issues/issue-layouts/list/base-list-root.tsx (5 hunks)
  • web/core/components/issues/issue-layouts/list/default.tsx (5 hunks)
  • web/core/components/issues/issue-layouts/list/headers/group-by-card.tsx (3 hunks)
  • web/core/components/issues/issue-layouts/list/list-group.tsx (5 hunks)
🧰 Additional context used
🪛 GitHub Check: lint-web
web/core/components/issues/issue-layouts/list/base-list-root.tsx

[failure] 19-19:
next/navigation import should occur before import of @plane/types


[failure] 125-125:
Trailing spaces not allowed

web/core/components/issues/issue-layouts/list/default.tsx

[failure] 136-136:
Trailing spaces not allowed

🔇 Additional comments (29)
web/core/components/issues/issue-layouts/kanban/headers/sub-group-by-card.tsx (1)

17-17: LGTM! Consistent prop renaming.

The renaming of kanbanFilters to collapsedGroups in the props destructuring is consistent with the interface update. The order of destructured props is maintained, which is good for code readability.

web/core/components/issues/issue-layouts/list/default.tsx (2)

17-17: LGTM: New import added correctly.

The addition of TIssueKanbanFilters to the import statement is consistent with the changes made to the IList interface.


73-74: LGTM: New props correctly destructured.

The addition of handleCollapsedGroups and collapsedGroups to the props destructuring is consistent with the changes made to the IList interface.

web/core/components/issues/issue-layouts/list/headers/group-by-card.tsx (3)

32-32: LGTM: Interface update improves clarity and aligns with PR objectives.

The replacement of toggleListGroup with handleCollapsedGroups in the IHeaderGroupByCard interface provides more context about the method's functionality. This change aligns well with the PR's objective of implementing grouping persistence for the List View.


46-46: LGTM: Component changes correctly implement the interface updates.

The HeaderGroupByCard component has been updated to use the new handleCollapsedGroups method from the props. The onClick handler now provides more specific information about the action being performed, which improves code readability and maintainability.

Also applies to: 111-111


Line range hint 1-168: Summary: Changes successfully implement grouping persistence for List View.

The modifications to the HeaderGroupByCard component and its interface successfully implement the grouping persistence functionality for the List View. The changes align well with the PR objectives and improve the overall user experience by maintaining the state of groupings across page refreshes.

Key improvements:

  1. Updated interface with more specific method names.
  2. Correct implementation of the new handleCollapsedGroups method in the component.
  3. Improved clarity and context in the onClick handler.

While the current implementation is sound, there's potential for future refactoring to simplify state management and improve overall component architecture.

web/core/components/issues/issue-layouts/kanban/headers/group-by-card.tsx (3)

27-28: Improved type safety and clarity in interface definition.

The changes to the IHeaderGroupByCard interface enhance type safety and provide better clarity:

  1. Replacing kanbanFilters with collapsedGroups: TIssueKanbanFilters more accurately describes the prop's purpose.
  2. The new handleCollapsedGroups function signature is more specific, clearly defining the expected parameters and return type.

These improvements will help prevent potential bugs and make the component's API more self-documenting.


Line range hint 1-186: Summary: Positive changes with considerations for broader impact

The changes to HeaderGroupByCard represent a positive step towards improved type safety, clarity, and potentially more consistent state management across views. The refactoring from kanbanFilters to collapsedGroups and the corresponding handler updates are well-implemented within this component.

Recommendations:

  1. Thoroughly test the Kanban view to ensure grouping and collapsing functionality works as expected with these changes.
  2. Review and update all components that interact with HeaderGroupByCard to ensure they provide the correct props.
  3. Verify that state management for collapsed groups is consistent between List and Kanban views.
  4. Consider adding inline documentation to explain the purpose and usage of collapsedGroups.
  5. Update any relevant test cases to reflect these changes.

Overall, these changes appear to enhance the component's design, but careful integration testing is advised to ensure they don't introduce regressions in the broader application context.


41-42: Implementation aligned with interface changes.

The component implementation has been correctly updated to use the new collapsedGroups and handleCollapsedGroups props:

  1. Props destructuring updated (lines 41-42).
  2. verticalAlignPosition calculation now uses collapsedGroups (line 47).
  3. Click handler updated to use handleCollapsedGroups (line 136).

These changes maintain consistency with the interface updates.

To ensure the changes don't introduce unexpected behavior, please verify:

  1. The grouping and collapsing functionality works as expected in the Kanban view.
  2. The vertical alignment of cards is correctly maintained based on the collapsedGroups state.

You can use the following script to check for any other occurrences of the old prop names that might have been missed:

Also applies to: 47-47, 136-136

web/core/components/issues/issue-layouts/kanban/default.tsx (3)

69-70: LGTM! Props destructuring is correct.

The addition of collapsedGroups and handleCollapsedGroups to the props destructuring is consistent with the interface updates. This ensures that these new properties are available for use within the KanBan component.


Line range hint 1-200: Overall, the changes look good and align with the PR objectives.

The implementation of collapsedGroups and handleCollapsedGroups is consistent throughout the file and aligns well with the PR objectives of implementing state persistence for groupings. The changes provide a more specific and type-safe way to handle collapsed groups in the Kanban view.

A few minor suggestions have been made to improve readability and clarity, but these don't affect the overall functionality. Great job on implementing this feature!


164-165: LGTM! Verify HeaderGroupByCard implementation.

The addition of collapsedGroups and handleCollapsedGroups as props to the HeaderGroupByCard component is correct and consistent with the earlier changes. This allows the component to access and modify the collapsed state of groups.

To ensure that these new props are correctly utilized, please verify the implementation of the HeaderGroupByCard component. Run the following script to check its implementation:

✅ Verification successful

Action Required: Further Verification of HeaderGroupByCard Implementation

The initial script failed to recognize the 'typescript' file type. Please use the following script to search within .tsx files for the HeaderGroupByCard component and its associated props:


Verified: HeaderGroupByCard correctly utilizes the new props.

The implementation of the HeaderGroupByCard component correctly handles the collapsedGroups and handleCollapsedGroups props as introduced. All usages in the kanban-related files align with the updated interface, ensuring consistent behavior.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of HeaderGroupByCard component

# Test: Search for the HeaderGroupByCard component definition and its usage of collapsedGroups and handleCollapsedGroups
rg --type typescript -A 10 'const HeaderGroupByCard'

Length of output: 89


Script:

# !/bin/bash
# Description: Verify the implementation of HeaderGroupByCard component within .tsx files

# Find all .tsx files and search for HeaderGroupByCard component usage
fd --extension tsx | xargs rg 'HeaderGroupByCard' -A 10

Length of output: 21917

web/core/components/issues/issue-layouts/kanban/base-kanban-root.tsx (2)

226-226: LGTM! Proper initialization of collapsedGroups.

The assignment of collapsedGroups correctly retrieves the collapsed groups state from the filters, with a sensible default value. This implementation supports the PR objective of persisting the state of groupings.


Line range hint 1-290: Overall, excellent implementation of group state persistence.

The changes in this file effectively implement the functionality of persisting the "state of groupings" for the Kanban View, aligning well with the PR objectives. The code is well-structured, follows React best practices, and makes appropriate use of hooks for performance optimization.

A few minor suggestions have been made for improved clarity and consistency, but these are not critical issues. Great job on this implementation!

web/core/components/issues/issue-layouts/list/list-group.tsx (4)

16-16: LGTM: New props for managing collapsed groups.

The addition of handleCollapsedGroups and collapsedGroups to the Props interface aligns well with the PR objectives. These props will enable the component to manage and persist the state of collapsed groups effectively.

Also applies to: 63-64


89-90: LGTM: Proper destructuring of new props.

The new props handleCollapsedGroups and collapsedGroups are correctly destructured from the props object, maintaining consistency with the Props interface changes.


249-249: LGTM: Passing handleCollapsedGroups to HeaderGroupByCard.

The handleCollapsedGroups prop is correctly passed to the HeaderGroupByCard component, enabling it to manage the collapsed state of groups. This change is consistent with the PR objectives and the overall modifications in the file.


Line range hint 1-296: Overall assessment: Well-implemented persistence for groupings state.

The changes in this file effectively implement the persistence of groupings state for the List View, aligning well with the PR objectives. The new props and logic for managing collapsed groups are appropriately integrated into the existing component structure. The code quality is good, with only minor suggestions for improvement in readability and consistency.

Key improvements:

  1. Addition of handleCollapsedGroups and collapsedGroups props.
  2. Derivation of isExpanded state from collapsedGroups.
  3. Automatic expansion of groups on item drop.
  4. Proper propagation of new props to child components.

These changes should significantly enhance the user experience by maintaining the state of groupings across page refreshes and providing consistency between List and Kanban views.

web/core/components/issues/issue-layouts/kanban/swimlanes.tsx (9)

38-39: LGTM: Consistent renaming in ISubGroupSwimlaneHeader interface

The renaming of kanbanFilters to collapsedGroups and handleKanbanFilters to handleCollapsedGroups is consistent with the PR objectives. The types remain unchanged, maintaining the existing functionality while improving clarity.


56-56: LGTM: Consistent prop renaming in SubGroupSwimlaneHeader component

The prop names have been updated consistently in the component's parameter destructuring and when passing them to the HeaderGroupByCard component. This change aligns with the interface updates and maintains the existing functionality.

Also applies to: 76-77


99-100: LGTM: Consistent renaming in ISubGroupSwimlane interface

The renaming of kanbanFilters to collapsedGroups and handleKanbanFilters to handleCollapsedGroups in the ISubGroupSwimlane interface is consistent with previous changes. The types remain unchanged, ensuring that the existing functionality is preserved.


123-124: LGTM: Consistent prop renaming and usage in SubGroupSwimlane component

The prop names have been updated consistently in the component's parameter destructuring. The usage of collapsedGroups in the visibilitySubGroupBy function has been correctly updated. These changes align with the interface updates and maintain the existing functionality.

Also applies to: 150-150


171-172: LGTM: Consistent prop renaming in HeaderSubGroupByCard usage

The prop names passed to the HeaderSubGroupByCard component have been updated consistently. This change aligns with previous updates and maintains the existing functionality.


189-190: LGTM: Consistent prop renaming in KanBan component usage

The prop names passed to the KanBan component have been updated consistently. This change aligns with previous updates and maintains the existing functionality.


226-227: LGTM: Consistent renaming in IKanBanSwimLanes interface

The renaming of kanbanFilters to collapsedGroups and handleKanbanFilters to handleCollapsedGroups in the IKanBanSwimLanes interface is consistent with previous changes. The types remain unchanged, ensuring that the existing functionality is preserved.


251-252: LGTM: Consistent prop renaming in KanBanSwimLanes component

The prop names have been updated consistently in the component's parameter destructuring and when passing them to the SubGroupSwimlaneHeader and SubGroupSwimlane components. These changes align with the interface updates and previous changes, maintaining the existing functionality.

Also applies to: 305-306, 324-325


Line range hint 1-341: Summary: Consistent renaming improves code clarity

The changes in this file consistently rename kanbanFilters to collapsedGroups and handleKanbanFilters to handleCollapsedGroups across all relevant interfaces and components. This renaming aligns with the PR objectives and improves code clarity by using more descriptive names for the grouping functionality. The existing functionality is maintained throughout these changes.

Key points:

  1. All interfaces (ISubGroupSwimlaneHeader, ISubGroupSwimlane, IKanBanSwimLanes) have been updated.
  2. Components (SubGroupSwimlaneHeader, SubGroupSwimlane, KanBanSwimLanes) have been updated to use the new prop names.
  3. Usage of these props in child components (HeaderGroupByCard, HeaderSubGroupByCard, KanBan) has been updated.
  4. The visibilitySubGroupBy function has been updated to use the new collapsedGroups name.

These changes contribute to a more consistent and understandable codebase, making it easier for developers to work with the Kanban swimlanes functionality.

web/core/components/issues/issue-layouts/list/base-list-root.tsx (2)

115-131: handleCollapsedGroups function is well-implemented

The handleCollapsedGroups function correctly uses useCallback with the necessary dependencies. It effectively manages the collapsed groups state shared between Kanban View and List View.

🧰 Tools
🪛 GitHub Check: lint-web

[failure] 125-125:
Trailing spaces not allowed


154-155: Props passed correctly to the List component

The handleCollapsedGroups and collapsedGroups props are properly passed to the <List> component, ensuring consistent state persistence between views.

Comment on lines +21 to +24
onClick={() => handleCollapsedGroups("sub_group_by", column_id)}
>
<div className="flex h-[20px] w-[20px] flex-shrink-0 items-center justify-center overflow-hidden rounded-sm transition-all hover:bg-custom-background-80">
{kanbanFilters?.sub_group_by.includes(column_id) ? (
{collapsedGroups?.sub_group_by.includes(column_id) ? (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Residual kanbanFilters Found

There are remaining instances of kanbanFilters in the following files, indicating that the renaming to collapsedGroups may be incomplete:

  • web/core/components/issues/issue-layouts/list/base-list-root.tsx
  • web/core/components/issues/issue-layouts/kanban/base-kanban-root.tsx

Please update these instances to ensure consistency across the codebase.

🔗 Analysis chain

LGTM! Verify the impact on related components.

The changes in the onClick handler and the condition check are consistent with the interface updates and prop renaming. The functionality appears to remain the same, with only the naming conventions updated.

To ensure that these changes don't introduce any unintended side effects, please run the following verification script:

This script will help identify any places where the old naming conventions might still be in use, and confirm that the new collapsedGroups terminology is used consistently across related components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining instances of 'kanbanFilters' or 'handleKanbanFilters'
# in related components, and verify that 'collapsedGroups' is used consistently.

echo "Checking for remaining instances of old naming conventions:"
rg --type typescript 'kanbanFilters|handleKanbanFilters' web/core/components/issues/

echo "\nVerifying consistent usage of 'collapsedGroups':"
rg --type typescript 'collapsedGroups' web/core/components/issues/

Length of output: 469


Script:

#!/bin/bash
# Description: Check for any remaining instances of 'kanbanFilters' or 'handleKanbanFilters'
# in related components, and verify that 'collapsedGroups' is used consistently.

echo "Checking for remaining instances of old naming conventions:"
rg --type ts 'kanbanFilters|handleKanbanFilters' web/core/components/issues/

echo "\nVerifying consistent usage of 'collapsedGroups':"
rg --type ts 'collapsedGroups' web/core/components/issues/

Length of output: 6365

} else {
collapsedGroups.push(value);
}
updateFilters(projectId?.toString() ?? "", EIssueFilterType.KANBAN_FILTERS,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove trailing spaces to satisfy linting rules

There are trailing spaces at the end of line 125, which violate the linting rules.

Apply this diff to remove the trailing spaces:

-            updateFilters(projectId?.toString() ?? "", EIssueFilterType.KANBAN_FILTERS, 
+            updateFilters(projectId?.toString() ?? "", EIssueFilterType.KANBAN_FILTERS,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
updateFilters(projectId?.toString() ?? "", EIssueFilterType.KANBAN_FILTERS,
updateFilters(projectId?.toString() ?? "", EIssueFilterType.KANBAN_FILTERS,
🧰 Tools
🪛 GitHub Check: lint-web

[failure] 125-125:
Trailing spaces not allowed

@@ -16,6 +16,7 @@
import { List } from "./default";
// types
import { IQuickActionProps, TRenderQuickActions } from "./list-view-types";
import { useParams } from "next/navigation";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix import order to comply with linting rules

According to the linting rules, the import from "next/navigation" should appear before the import from "@plane/types".

Apply this diff to correct the import order:

+import { useParams } from "next/navigation";
 import { GroupByColumnTypes, TGroupedIssues, TIssueKanbanFilters } from "@plane/types";

Committable suggestion was skipped due to low confidence.

🧰 Tools
🪛 GitHub Check: lint-web

[failure] 19-19:
next/navigation import should occur before import of @plane/types

Copy link
Collaborator

@rahulramesha rahulramesha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharma01ketan One minor change, and also please fix lint errors, looks like they are failing on the PR

collapsedGroups.push(value);
// kanbanFilters and EIssueFilterType.KANBAN_FILTERS are used becuase the state is shared between kanban view and list view
const handleCollapsedGroups = useCallback(
(toggle: "group_by", value: string) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can also remove toggle argument completely since it is always "group_by" for list

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, made the changes.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
web/core/components/issues/issue-layouts/list/base-list-root.tsx (2)

63-65: LGTM: Hooks and state initialization look good.

The use of useParams for extracting URL parameters and the initialization of collapsedGroups are implemented correctly. The updateFilters function is properly obtained from the useIssuesActions hook.

Consider using a default empty object for kanbanFilters to simplify the initialization:

const collapsedGroups = issuesFilter?.issueFilters?.kanbanFilters ?? { group_by: [], sub_group_by: [] } as TIssueKanbanFilters;

This change would make the code slightly more concise and easier to read.


115-131: LGTM: The handleCollapsedGroups function is well-implemented.

The function correctly toggles values in the collapsedGroups array and updates the filters using the updateFilters method. The use of useCallback is appropriate for performance optimization.

Consider using the spread operator for a more concise array update:

const updatedGroups = collapsedGroups.includes(value)
  ? collapsedGroups.filter((_value) => _value !== value)
  : [...collapsedGroups, value];

updateFilters(projectId?.toString() ?? "", EIssueFilterType.KANBAN_FILTERS,
  { group_by: updatedGroups } as TIssueKanbanFilters
);

This change would make the code slightly more readable and reduce the number of lines.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between df3d6bb and 5a92bca.

📒 Files selected for processing (8)
  • web/core/components/issues/issue-layouts/kanban/base-kanban-root.tsx (2 hunks)
  • web/core/components/issues/issue-layouts/kanban/default.tsx (4 hunks)
  • web/core/components/issues/issue-layouts/kanban/headers/group-by-card.tsx (3 hunks)
  • web/core/components/issues/issue-layouts/kanban/swimlanes.tsx (12 hunks)
  • web/core/components/issues/issue-layouts/list/base-list-root.tsx (4 hunks)
  • web/core/components/issues/issue-layouts/list/default.tsx (4 hunks)
  • web/core/components/issues/issue-layouts/list/headers/group-by-card.tsx (3 hunks)
  • web/core/components/issues/issue-layouts/list/list-group.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • web/core/components/issues/issue-layouts/kanban/base-kanban-root.tsx
  • web/core/components/issues/issue-layouts/kanban/default.tsx
  • web/core/components/issues/issue-layouts/kanban/headers/group-by-card.tsx
  • web/core/components/issues/issue-layouts/kanban/swimlanes.tsx
  • web/core/components/issues/issue-layouts/list/default.tsx
  • web/core/components/issues/issue-layouts/list/headers/group-by-card.tsx
  • web/core/components/issues/issue-layouts/list/list-group.tsx
🔇 Additional comments (3)
web/core/components/issues/issue-layouts/list/base-list-root.tsx (3)

4-7: LGTM: Import changes are appropriate and correctly ordered.

The new imports for useParams, TIssueKanbanFilters, and EIssueFilterType are necessary for the added functionality. The import order satisfies the linting rules as mentioned in the past review comments.


154-155: LGTM: New props are correctly passed to the List component.

The addition of handleCollapsedGroups and collapsedGroups props to the List component is correct. This change enables the List component to manage and reflect changes in issue grouping based on user actions, improving the component's functionality.


Line range hint 1-160: Overall changes align well with PR objectives.

The implementation successfully addresses the main objectives of the PR:

  1. It implements persistence of the "state of groupings" for the List View.
  2. It introduces a shared state mechanism between the List View and the Kanban View.
  3. It corrects previously set values for the keys.

The use of EIssueFilterType.KANBAN_FILTERS and the updateFilters function ensures that the state is shared and persisted correctly. These changes enhance the functionality and user experience of the application by maintaining consistent grouping states across views and page refreshes.

@pushya22 pushya22 merged commit b7ee7e1 into preview Oct 3, 2024
14 of 15 checks passed
@pushya22 pushya22 deleted the fix/list-kanban-grouping branch October 3, 2024 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants