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

feat: building block canvas dragging #31398

Merged
merged 12 commits into from Mar 6, 2024
Merged

Conversation

AnaghHegde
Copy link
Member

@AnaghHegde AnaghHegde commented Mar 1, 2024

Description

The primary aim of this feature is to empower users by enabling them to seamlessly integrate building blocks along with their associated components (queries, JavaScript, datasources, and widgets) into their existing applications through drag-and-drop functionality.
This PR adds change to create a Partial IE engine to download the json file from CS, then add all DS, JS, Queries and Custom JS Libs. Also handle the name refactoring in js, queries and dsl and then return modified widget dsl to frontend.

PR fixes following issue(s)

Fixes #31315

Media

Type of change

  • New feature (non-breaking change which adds functionality)

Testing

How Has This Been Tested?

  • Manual
  • JUnit

Test Plan

https://www.notion.so/appsmith/Test-planning-Drag-and-drop-building-blocks-030b0a5e944a478c9598ad65ba5096e2?pm=c

Issues raised during DP testing

Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR)

Checklist:

Dev activity

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

QA activity:

  • Speedbreak features have been covered
  • Test plan covers all impacted features and areas of interest
  • Test plan has been peer reviewed by project stakeholders and other QA members
  • Manually tested functionality on DP
  • We had an implementation alignment call with stakeholders post QA Round 2
  • Cypress test cases have been added and approved by SDET/manual QA
  • Added Test Plan Approved label after Cypress tests were reviewed
  • Added Test Plan Approved label after JUnit tests were reviewed

Summary by CodeRabbit

  • New Features

    • Added BuildingBlockDTO import.
    • Added ApplicationTemplateService and WidgetRefactorUtil services.
    • Added importBuildingBlock method.
    • Introduced partial import functionality for building blocks.
    • Added capability to refactor widget and action names during import to avoid name clashes.
  • Enhancements

    • Improved logic for importing resources within a page.
    • Enhanced name refactoring in DSL bindings to ensure consistency across the application.
  • Refactor

    • Updated methods to handle new import structures and services more efficiently.
  • Tests

    • Added new tests to verify partial imports and name refactoring functionalities.

@AnaghHegde AnaghHegde self-assigned this Mar 1, 2024
Copy link
Contributor

coderabbitai bot commented Mar 1, 2024

Walkthrough

Walkthrough

The recent updates to the Appsmith server focus on enhancing the Partial Import Export (PIE) API by introducing the ability to import building blocks, such as queries, JavaScript functions, and datasources, into existing applications. This includes backend operations to support drag-and-drop functionality, efficient management of resources, and updating the application's widget structure for client rendering. The changes involve the addition of new services, methods, and utilities aimed at refining the process of integrating building blocks with components, thereby improving the user experience and operational efficiency.

Changes

Files Change Summary
.../partial/PartialImportServiceCEImpl.java, .../controllers/ce/ApplicationControllerCE.java, .../newactions/importable/NewActionImportableServiceCEImpl.java - Introduced BuildingBlockDTO import, ApplicationTemplateService, and WidgetRefactorUtil services.
- Added methods for building block import and resource import in a page.
- Enhanced name refactoring in DSL bindings.
- Modified updateActionNameBeforeMerge to use MappedImportableResourcesDTO for name refactoring.
.../server/widgets/refactors/WidgetRefactorUtil.java - Created WidgetRefactorUtil for widget name refactoring in DSL structures, including handling dynamic bindings and triggers.
.../solutions/PartialImportServiceTest.java - Added tests for partial imports with name clashes, utilizing new imports and services for import and application templates.

Assessment against linked issues

Objective Addressed Explanation
Enable users to integrate building blocks with components into existing applications via drag-and-drop functionality. (#31315)
Enhance the PIE API to support backend operations for adding queries, JavaScript functions, and datasources to applications. (#31315)
Improve the backend capability to efficiently manage queries, JavaScript functions, and datasources for a smoother integration process. (#31315)
Transmit the updated application's widget structure back to the client for rendering, ensuring a cohesive user experience. (#31315)
Address the need for backend management of queries, JavaScript, and datasources to effectively implement building blocks in the explorer. (#31315)

The code changes successfully address the key objectives outlined in the linked issue, focusing on enhancing the backend functionality of the PIE API to support the integration of building blocks into applications, which is crucial for improving the user experience and operational efficiency.

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

@github-actions github-actions bot added the Enhancement New feature or request label Mar 1, 2024
Comment on lines 373 to 385
public Mono<String> importBuildingBlock(BuildingBlockDTO buildingBlockDTO, String branchName) {
Mono<ApplicationJson> applicationJsonMono =
applicationTemplateService.getApplicationJsonFromTemplate(buildingBlockDTO.getTemplateId());

return applicationJsonMono
.flatMap(applicationJson -> this.importResourceInPage(
buildingBlockDTO.getWorkspaceId(),
buildingBlockDTO.getPageId(),
buildingBlockDTO.getApplicationId(),
branchName,
applicationJson))
.map(BuildingBlockImportDTO::getWidgetDsl);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The importBuildingBlock method introduces functionality for importing a building block based on a template ID. Ensure that the applicationTemplateService.getApplicationJsonFromTemplate method properly handles errors and edge cases, such as invalid template IDs or templates that cannot be converted to ApplicationJson. Additionally, consider adding more detailed logging or metrics around this process for better observability.

+ log.info("Starting import of building block with template ID: {}", buildingBlockDTO.getTemplateId());

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.

Suggested change
public Mono<String> importBuildingBlock(BuildingBlockDTO buildingBlockDTO, String branchName) {
Mono<ApplicationJson> applicationJsonMono =
applicationTemplateService.getApplicationJsonFromTemplate(buildingBlockDTO.getTemplateId());
return applicationJsonMono
.flatMap(applicationJson -> this.importResourceInPage(
buildingBlockDTO.getWorkspaceId(),
buildingBlockDTO.getPageId(),
buildingBlockDTO.getApplicationId(),
branchName,
applicationJson))
.map(BuildingBlockImportDTO::getWidgetDsl);
}
public Mono<String> importBuildingBlock(BuildingBlockDTO buildingBlockDTO, String branchName) {
log.info("Starting import of building block with template ID: {}", buildingBlockDTO.getTemplateId());
Mono<ApplicationJson> applicationJsonMono =
applicationTemplateService.getApplicationJsonFromTemplate(buildingBlockDTO.getTemplateId());
return applicationJsonMono
.flatMap(applicationJson -> this.importResourceInPage(
buildingBlockDTO.getWorkspaceId(),
buildingBlockDTO.getPageId(),
buildingBlockDTO.getApplicationId(),
branchName,
applicationJson))
.map(BuildingBlockImportDTO::getWidgetDsl);
}

@AnaghHegde
Copy link
Member Author

/build-deploy-preview

Copy link

github-actions bot commented Mar 1, 2024

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

Copy link

github-actions bot commented Mar 1, 2024

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

@github-actions github-actions bot added Templates Issues related to templates Templates Pod Issues related to Templates labels Mar 4, 2024
@AnaghHegde
Copy link
Member Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Mar 4, 2024

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

Copy link

github-actions bot commented Mar 4, 2024

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

Copy link

github-actions bot commented Mar 4, 2024

Failed server tests

  • com.appsmith.server.solutions.PartialImportServiceTest#testPartialImportWithBuildingBlock_nameClash_success

@AnaghHegde
Copy link
Member Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Mar 4, 2024

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

@appsmithorg appsmithorg deleted a comment from github-actions bot Mar 4, 2024
Copy link

github-actions bot commented Mar 4, 2024

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

@AnaghHegde
Copy link
Member Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Mar 4, 2024

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

Copy link

github-actions bot commented Mar 4, 2024

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

Copy link

github-actions bot commented Mar 4, 2024

Failed server tests

  • com.appsmith.server.solutions.PartialImportServiceTest#testPartialImport_gitConnectedAppDefaultBranch_success
  • com.appsmith.server.solutions.PartialImportServiceTest#testPartialImport_nameClashInAction_successWithNoNameDuplicates
  • com.appsmith.server.solutions.PartialImportServiceTest#testPartialImport_nonGitConnectedApp_success

@appsmithorg appsmithorg deleted a comment from github-actions bot Mar 5, 2024
Copy link
Contributor

@NilanshBansal NilanshBansal left a comment

Choose a reason for hiding this comment

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

Backend Code LGTM

@NilanshBansal
Copy link
Contributor

@AnaghHegde can you share steps on how to test this on dp?

@AnaghHegde
Copy link
Member Author

@NilanshBansal This can be tested via postman, since this is a new API. The FE work is still pending. Since this a new API, this will be tested in the same DP where we have the FE code is present.

@AnaghHegde
Copy link
Member Author

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

Copy link

github-actions bot commented Mar 6, 2024

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/8167616711.
Workflow: Appsmith External Integration Test Workflow.
Tags: @tag.ImportExport.

Copy link

github-actions bot commented Mar 6, 2024

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/8167616711.
Commit: ``.
Cypress dashboard url: Click here!
All cypress tests have passed 🎉🎉🎉

@rahulbarwal rahulbarwal merged commit 0fd2d51 into release Mar 6, 2024
18 checks passed
@rahulbarwal rahulbarwal deleted the feat/block-canvas-dragging branch March 6, 2024 06:38
@jacquesikot
Copy link
Contributor

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Mar 7, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Templates Pod Issues related to Templates Templates Issues related to templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Improve Partial Import Export (PIE) API to allow adding building blocks to apps.
4 participants