appsmith icon indicating copy to clipboard operation
appsmith copied to clipboard

feat: remove api call from building block loading skeleton

Open jacquesikot opened this issue 1 year ago • 8 comments

Description

[!TIP]
Context The current process for dropping a building block onto the canvas is experiencing performance issues. Specifically, the time taken post-drop to fully ready the building block is excessive, impacting user experience. Problem A key performance bottleneck has been identified in the numerous API calls required to complete the building block drop operation. These calls are proving to be both time-consuming and inefficient. Solution To address this bottleneck, this PR implements a significant optimization by rendering the skeleton loader using local state management only. This change eliminates the need for an additional API call to the backend for adding the skeleton loader, thus streamlining the building block drop process.

Fixes #Issue Number
or
Fixes Issue URL

[!WARNING]
If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags="@tag.Widget, @tag.Templates"

:mag: Cypress test results

[!TIP] 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9123439174 Commit: dd1027ea251a396852c4a7d84de6ac377f43d081 Cypress dashboard url: Click here!

Communication

Should the DevRel and Marketing teams inform users about this change?

  • [ ] Yes
  • [x] No

jacquesikot avatar May 15 '24 22:05 jacquesikot

Walkthrough

The changes aim to improve the performance of dragging and dropping building blocks onto the canvas by introducing local state management for rendering skeleton loaders. This optimization removes the need for additional backend API calls, thus reducing the time taken to complete the drop operation and enhancing user experience.

Changes

Files Change Summary
ReduxActionConstants.tsx Added constants ADD_LOCAL_SKELETON_LOADER and REMOVE_LOCAL_SKELETON_LOADER to handle local skeleton loader actions.
canvasWidgetsReducer.ts Added handling for the new skeleton loader action types to update widget states and heights.
canvasWidgetsStructureReducer.ts Added cases for ADD_LOCAL_SKELETON_LOADER and REMOVE_LOCAL_SKELETON_LOADER to manage widget state updates based on the action payload.
FixedLayoutEditorCanvas.tsx Updated to merge props.children and props.metaWidgetChildrenStructure for rendering and sorting based on topRow, and expanded useMemo dependencies.
buildingBlockReducer.ts Renamed state property for consistency and adjusted handling of timestamps for building block drag operations.
BuildingBlockAdditionSagas.ts Added new saga functions to handle adding and removing skeleton loaders on the canvas.
withWidgetProps.tsx Modified getMetaWidgetChildrenStructure parameters to include allowCanvasWidgetBuildingBlockSkeletonLoader.
AddBuildingblockSkeletonLoaderToCanvas.test.ts Introduced tests for addBuildingBlockSkeletonLoaderToCanvas function.
RemoveSkeletonLoaderFromCanvas.test.ts Introduced tests for removeSkeletonLoaderFromCanvas function.
Drag_Drop_Building_Blocks_spec.ts Modified test case to focus on dragging and dropping building blocks on the canvas and introduced DEFAULT_SKELETON_LOADER_NAME constant to check for skeleton loader visibility.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant Canvas
    participant LocalState
    participant Backend

    User->>Canvas: Drag and drop building block
    Canvas->>LocalState: Add skeleton loader
    LocalState-->>Canvas: Update canvas with skeleton loader
    Canvas-->>User: Display skeleton loader
    Canvas->>Backend: Fetch building block data
    Backend-->>Canvas: Return building block data
    Canvas->>LocalState: Remove skeleton loader
    LocalState-->>Canvas: Update canvas with building block
    Canvas-->>User: Display building block

Assessment against linked issues

Objective Addressed Explanation
Save skeleton loader on client side only to boost building blocks drag and drop (#33657)
Eliminate additional API calls for adding skeleton loader (#33657)
Render skeleton loader using local state management (#33657)

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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

coderabbitai[bot] avatar May 15 '24 22:05 coderabbitai[bot]

/build-deploy-preview skip-tests=true

jacquesikot avatar May 16 '24 06:05 jacquesikot

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9107382633. Workflow: On demand build Docker image and deploy preview. skip-tests: true. env: ``. PR: 33501. recreate: .

github-actions[bot] avatar May 16 '24 06:05 github-actions[bot]

Deploy-Preview-URL: https://ce-33501.dp.appsmith.com

github-actions[bot] avatar May 16 '24 06:05 github-actions[bot]

/build-deploy-preview skip-tests=true

jacquesikot avatar May 17 '24 05:05 jacquesikot

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9123448600. Workflow: On demand build Docker image and deploy preview. skip-tests: true. env: ``. PR: 33501. recreate: .

github-actions[bot] avatar May 17 '24 05:05 github-actions[bot]

Deploy-Preview-URL: https://ce-33501.dp.appsmith.com

github-actions[bot] avatar May 17 '24 05:05 github-actions[bot]

@jacquesikot Lets add unit test where ever applicable in this PR.

rahulbarwal avatar May 17 '24 07:05 rahulbarwal

/build-deploy-preview skip-tests=true

jacquesikot avatar May 30 '24 01:05 jacquesikot

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9295295508. Workflow: On demand build Docker image and deploy preview. skip-tests: true. env: ``. PR: 33501. recreate: .

github-actions[bot] avatar May 30 '24 01:05 github-actions[bot]

Deploy-Preview-URL: https://ce-33501.dp.appsmith.com

github-actions[bot] avatar May 30 '24 01:05 github-actions[bot]

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

github-actions[bot] avatar Jun 07 '24 16:06 github-actions[bot]

This PR has been closed because of inactivity.

github-actions[bot] avatar Jun 15 '24 16:06 github-actions[bot]