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-2316] chore: Kanban group virtualization #5565

Merged
merged 2 commits into from
Sep 18, 2024

Conversation

rahulramesha
Copy link
Collaborator

@rahulramesha rahulramesha commented Sep 9, 2024

This PR adds group wise virtualization to Kanban groups to fix faster reaction times with large number of groups/columns. This is to make sure the user experiences faster perceived performance.

Summary by CodeRabbit

  • New Features

    • Introduced a new optional property useIdletime for improved rendering behavior in the RenderIfVisible component.
    • Enhanced Kanban component with subgroup management through the new subGroupIndex prop.
    • Added a new KanbanColumnLoader component for improved layout rendering in Kanban views.
    • Implemented a function to dynamically calculate the approximate height of Kanban cards.
  • Bug Fixes

    • Adjusted visibility and rendering logic for better performance in the Kanban component.
  • Refactor

    • Updated rendering logic in several components to optimize performance and maintainability.

Copy link
Contributor

coderabbitai bot commented Sep 9, 2024

Walkthrough

This pull request introduces several enhancements across multiple components, including the addition of new properties and functionalities to improve rendering logic. Key changes include the introduction of the useIdletime property in the RenderIfVisible component, modifications to the KanBan component to utilize this new feature, and the addition of the getApproximateCardHeight utility function. Furthermore, new loader components have been created to streamline the Kanban layout, enhancing overall performance and flexibility.

Changes

Files Change Summary
web/core/components/core/render-if-visible-HOC.tsx Added useIdletime property to Props type, modifying visibility logic to conditionally use requestIdleCallback. Adjusted className logic for better handling of placeholderChildren.
web/core/components/issues/issue-layouts/kanban/default.tsx Introduced subGroupIndex prop to IKanBan interface. Integrated RenderIfVisible for conditional rendering of KanbanGroup, optimizing performance. Refined height calculation for groups using getApproximateCardHeight. Updated mapping of list to include groupIndex.
web/core/components/issues/issue-layouts/kanban/swimlanes.tsx Modified SubGroupSwimlane component to pass subGroupIndex to child components, enhancing subgroup management.
web/core/components/issues/issue-layouts/utils.tsx Added getApproximateCardHeight function to calculate dynamic height of Kanban cards based on display properties.
web/core/components/ui/loader/layouts/kanban-layout-loader.tsx Updated KanbanIssueBlockLoader to accept cardHeight prop. Introduced KanbanColumnLoader for rendering columns of issue blocks, improving modularity and code structure.

Suggested labels

🌟enhancement

Poem

🐇 In the garden where changes bloom,
A new prop dances, dispelling gloom.
With loaders bright and heights refined,
The Kanban flows, perfectly aligned.
Hooray for updates, let’s celebrate,
In code we trust, our future is great! 🌼

Tip

New features

Walkthrough comment now includes:

  • Possibly related PRs: A list of potentially related PRs to help you recall past context.
  • Suggested labels: CodeRabbit can now suggest labels by learning from your past PRs. You can also provide custom labeling instructions in the UI or configuration file.

Notes:

  • Please share any feedback in the discussion post on our Discord.
  • Possibly related PRs, automatic label suggestions based on past PRs, learnings, and possibly related issues require data opt-in (enabled by default).

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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: 1

Outside diff range, codebase verification and nitpick comments (1)
web/core/components/core/render-if-visible-HOC.tsx (1)

Line range hint 14-48: Enhanced rendering control with useIdletime, but fix the typeof comparison.

The addition of useIdletime to RenderIfVisible enhances control over rendering during idle times, which is a significant improvement for performance. However, there's an issue with the typeof comparison that needs correction:

- if (typeof window !== undefined && window.requestIdleCallback && useIdletime) {
+ if (typeof window !== 'undefined' && window.requestIdleCallback && useIdletime) {

This change ensures the correct evaluation of the window object's existence.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7c3fc69 and 8de44ef.

Files selected for processing (5)
  • web/core/components/core/render-if-visible-HOC.tsx (4 hunks)
  • web/core/components/issues/issue-layouts/kanban/default.tsx (5 hunks)
  • web/core/components/issues/issue-layouts/kanban/swimlanes.tsx (2 hunks)
  • web/core/components/issues/issue-layouts/utils.tsx (1 hunks)
  • web/core/components/ui/loader/layouts/kanban-layout-loader.tsx (1 hunks)
Additional context used
Biome
web/core/components/core/render-if-visible-HOC.tsx

[error] 42-42: Invalid typeof comparison value: this expression is not a string literal

not a string literal
Unsafe fix: Compare the result of typeof with a valid type name

(lint/suspicious/useValidTypeof)

Additional comments not posted (5)
web/core/components/ui/loader/layouts/kanban-layout-loader.tsx (3)

4-12: Well-implemented dynamic height adjustment.

The KanbanIssueBlockLoader component correctly handles the cardHeight prop to dynamically adjust the height of the loader. The use of forwardRef and default props is appropriately applied.


14-36: Effective modularization and conditional rendering.

The KanbanColumnLoader component effectively uses props to control its behavior and layout, including conditional rendering of the header and dynamic generation of child components. This approach enhances modularity and maintainability.


43-43: Dynamic column rendering aligns with virtualization goals.

The use of KanbanColumnLoader within KanbanLayoutLoader to dynamically render multiple columns based on cardsInEachColumn effectively supports the virtualization enhancements aimed at improving Kanban performance.

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

Line range hint 59-223: Well-implemented virtualization and dynamic rendering enhancements.

The KanBan component effectively utilizes subGroupIndex and RenderIfVisible to enhance performance through virtualization and conditional rendering. The dynamic calculation of group heights using getApproximateCardHeight is a notable improvement for handling varying content sizes.

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

158-158: Verify the usage of subGroupIndex within the KanBan component.

The addition of subGroupIndex as a parameter to the map function and its subsequent passing to the KanBan component is correctly implemented. However, it is crucial to ensure that this index is utilized effectively within the KanBan component to enhance performance as intended by the PR.

Run the following script to verify the usage of subGroupIndex within the KanBan component:

Also applies to: 187-187

Verification successful

Verified: The usage of subGroupIndex within the KanBan component is appropriate.

The subGroupIndex is correctly passed and utilized within the KanBan component to control rendering logic, aligning with the PR's objectives of improving performance through virtualization.

  • subGroupIndex is defined as an optional property in the IKanBan interface.
  • It is used in a conditional expression to determine rendering behavior.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `subGroupIndex` within the `KanBan` component.

# Test: Search for the usage of `subGroupIndex` within the `KanBan` component. Expect: Proper usage that aligns with performance improvements.
rg --type typescript -A 5 $'subGroupIndex'

Length of output: 76


Script:

#!/bin/bash
# Description: Verify the usage of `subGroupIndex` within the `KanBan` component.

# Test: Search for the usage of `subGroupIndex` within .tsx files to ensure proper usage.
rg --type-add 'tsx:*.tsx' -t tsx -A 5 'subGroupIndex'

Length of output: 3050

Comment on lines +622 to +672

/**
* Returns approximate height of Kanban card based on display properties
* @param displayProperties
* @returns
*/
export function getApproximateCardHeight(displayProperties: IIssueDisplayProperties | undefined) {
if (!displayProperties) return 100;

// default card height
let cardHeight = 46;

const clonedProperties = clone(displayProperties);

// key adds the height for key
if (clonedProperties.key) {
cardHeight += 24;
}

// Ignore smaller dimension properties
const ignoredProperties: (keyof IIssueDisplayProperties)[] = [
"key",
"sub_issue_count",
"link",
"attachment_count",
"created_on",
"updated_on",
];

ignoredProperties.forEach((key: keyof IIssueDisplayProperties) => {
delete clonedProperties[key];
});

let propertyCount = 0;

// count the remaining properties
(Object.keys(clonedProperties) as (keyof IIssueDisplayProperties)[]).forEach((key: keyof IIssueDisplayProperties) => {
if (clonedProperties[key]) {
propertyCount++;
}
});

// based on property count, approximate the height of each card
if (propertyCount > 3) {
cardHeight += 60;
} else if (propertyCount > 0) {
cardHeight += 32;
}

return cardHeight;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Approve the implementation of getApproximateCardHeight and suggest adding unit tests.

The implementation of getApproximateCardHeight is well-thought-out and aligns with the PR's objectives to dynamically adjust the Kanban card height based on its content. It is recommended to add unit tests to ensure the function behaves as expected under various scenarios, especially with different combinations of display properties.

Would you like me to help by writing some unit tests for this function?

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8de44ef and f8820ea.

Files selected for processing (1)
  • web/core/components/issues/issue-layouts/kanban/default.tsx (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • web/core/components/issues/issue-layouts/kanban/default.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants