appsmith icon indicating copy to clipboard operation
appsmith copied to clipboard

fix: Replaced Clonedeep with Klona

Open LOKESH1076 opened this issue 1 year ago • 9 comments

PR fixes following issue(s) Fixes #12936

As klona is faster when compared to lodash's cloneDeep. We would like to migrate from cloneDeep to klona in all the places where it is possible in client code. Steps

1.Search for cloneDeep in client code 2.Replace cloneDeep with klona 3.Test it to verify your changes works as expected before and after the change.

Type of change Bug fix (non-breaking change which fixes an issue)

Testing

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration.

  • [x] Jest
  • [x] Cypress

## Checklist: Dev activity

  • [x] My code follows the style guidelines of this project
  • [x] I have performed a self-review of my own code
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [x] I have made corresponding changes to the documentation
  • [x] My changes generate no new warnings
  • [x] I have added tests that prove my fix is effective or that my feature works
  • [x] New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • Refactor
    • Replaced the usage of lodash/cloneDeep with the klona library for deep cloning objects across various components and utility functions. This change enhances performance and consistency in object cloning operations throughout the application.

LOKESH1076 avatar Jan 26 '24 09:01 LOKESH1076

Welcome to the Appsmith community! Thank you for your first pull request and making this project better. 🤗 Please make sure that you raise a review request so your code change does not go unnoticed.

welcome[bot] avatar Jan 26 '24 09:01 welcome[bot]

[!WARNING]

Rate Limit Exceeded

@LOKESH1076 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 28 minutes and 16 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 51deda7fe33997c8e1404597547430003221c6dc and b0509331c640547c526c773e956a6bb3f69df4d5.

Walkthrough

The changes across various files in the app client's codebase revolve around replacing the usage of lodash/cloneDeep with the klona library for deep cloning objects. This transition aims to leverage klona's faster performance for cloning operations. The modifications span across multiple components, utilities, and tests, ensuring that deep cloning now uniformly utilizes klona across the board.

Changes

Files Change Summary
app/client/packages/dsl/src/migrate/migrations/009-table-widget-property-pane-migration.ts, app/client/src/ce/workers/Evaluation/__tests__/dataTreeUtils.test.ts, app/client/src/pages/Editor/FirstTimeUserOnboarding/testUtils.ts, app/client/src/reducers/uiReducers/appCollabReducer.ts, app/client/src/reflow/reflowUtils.ts, app/client/src/sagas/CanvasSagas/DraggingCanvasSagas.ts, app/client/src/sagas/WidgetOperationSagas.tsx, app/client/src/sagas/WidgetOperationUtils.ts, app/client/src/transformers/RestActionTransformer.ts, app/client/src/utils/WidgetMigrationUtils.test.ts, app/client/src/utils/migrations/TableWidget.ts, app/client/src/widgets/ChartWidget/component/CustomEChartIFrameComponent.tsx, app/client/src/widgets/ChartWidget/component/helpers.ts, app/client/src/widgets/JSONFormWidget/widget/propertyConfig/properties/common.ts, app/client/src/widgets/ListWidget/widget/index.tsx, app/client/src/widgets/TableWidget/widget/index.tsx, app/client/src/widgets/TableWidgetV2/component/header/actions/filter/FilterPaneContent.tsx, app/client/src/widgets/TabsMigrator/widget/index.tsx, app/client/src/widgets/wds/WDSTableWidget/component/header/actions/filter/FilterPaneContent.tsx Replaced lodash/cloneDeep with klona for deep cloning objects.

Assessment against linked issues

Objective Addressed Explanation
Replace cloneDeep with klona The changes in the listed files have uniformly replaced the usage of cloneDeep with klona as per the objective outlined in the linked issue #12936.

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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

coderabbitai[bot] avatar Jan 26 '24 09:01 coderabbitai[bot]

Something that has been attempted before unsuccessfully, @vsvamsi1 @rishabhrathod01 please take a call if this looks relevant

somangshu avatar Jan 31 '24 07:01 somangshu

@LOKESH1076 Can you profile our application and verify that you were able to see a drop in scripting.
My experience with klona is that it performs similar to what cloneDeep does, its only when we go for either the /lite or /json version did i see massive improvement in performance. Also these libraries may not support certain types please check the documentation https://www.npmjs.com/package/klona to see if it maintains parity with cloneDeep. cc @rishabhrathod01 @somangshu

vsvamsi1 avatar Feb 01 '24 06:02 vsvamsi1

/ok-to-test tags="@tag.All"

vsvamsi1 avatar Feb 01 '24 06:02 vsvamsi1

Whoa, @tag.All spotted in your test suite! 🚀 While @tag.All is cool, like a catch-all net, why not try specific tags? 🏷️ Narrow down your suite with specific tags for quicker and more accurate tests! 🚀 Less waiting, more zipping through tests like a ninja! Explore the tags documentation here

github-actions[bot] avatar Feb 01 '24 06:02 github-actions[bot]

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/7737006117. Workflow: Appsmith External Integration Test Workflow. Tags: ``.

github-actions[bot] avatar Feb 01 '24 06:02 github-actions[bot]

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/7737006117. Commit: ``. Cypress dashboard url: Click here! It seems like no tests ran 😔. We are not able to recognize it, please check workflow here.

github-actions[bot] avatar Feb 01 '24 06:02 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 Feb 14 '24 16:02 github-actions[bot]