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

fix: starter building blocks on canvas removes existing queries and JS objects #32629

Merged

Conversation

rahulbarwal
Copy link
Contributor

@rahulbarwal rahulbarwal commented Apr 12, 2024

Description

Root cause:
The original intention of the building blocks on canvas was to serve a new user on their very first app.
Looking at (good) usage of this feature, we turned it on for all pages on all apps.
Now, an experienced user don't always start with UI and thats when we hit this issue.

Additionally, this was a tech debt we had to repay and this PR takes that opportunity to get rid of hack of using add a page from template for this feature and uses proper PIE based API to support his.

Fixes #32573
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.Templates"

🔍 Cypress test results

Tip

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

Summary by CodeRabbit

  • New Features

    • Introduced functionality for importing starter building blocks into applications, including layout positioning and action triggers upon successful import.
    • Added new actions and selectors in Redux for managing current forking building block names.
  • Refactor

    • Updated the handling of template names and constants for better consistency and use within the app.
    • Simplified event handling and variable naming in several components for improved code clarity and performance.
  • Bug Fixes

    • Adjusted analytics and event data handling to ensure accurate tracking and functionality.
  • Tests

    • Updated Cypress E2E tests to reflect changes in functionality and removed outdated test cases.

@rahulbarwal rahulbarwal self-assigned this Apr 12, 2024
@rahulbarwal rahulbarwal added Bug Something isn't working Templates Pod Issues related to Templates Building blocks Building blocks on cavas, on templates listing or drag and drop of building blocks. labels Apr 12, 2024
Copy link
Contributor

coderabbitai bot commented Apr 12, 2024

Walkthrough

The code changes aim to streamline the integration and management of building blocks within applications. Key updates include introducing new actions and selectors for handling building blocks, refining component behaviors for consistency, and adding functionalities for importing and managing building blocks efficiently. These changes are designed to enhance user interactions and optimize backend processes related to building blocks.

Changes

File Path Change Summary
app/client/src/actions/templateActions.ts
app/client/src/reducers/uiReducers/templateReducer.ts
app/client/src/ce/constants/ReduxActionConstants.tsx
app/client/src/selectors/templatesSelectors.tsx
Introducing functionalities to manage forking building block names in the Redux store.
app/client/src/constants/TemplatesConstants.tsx Refactoring constants for template names, affecting how names are accessed and utilized.
app/client/src/layoutSystems/common/dropTarget/starterBuildingBlocks/index.tsx
app/client/src/pages/Editor/Explorer/Datasources/DatasourceStarterLayoutPrompt.tsx
Updating component behaviors and variable names for consistency and enhancing analytics logging.
app/client/src/pages/Templates/TemplatesModal/PageSelection.tsx Modifying dynamic value assignment based on template properties.
app/client/src/sagas/BuildingBlocksSagas.ts Introducing comprehensive functionalities for importing and managing building blocks, including API interactions and widget handling.
app/client/cypress/e2e/Regression/ClientSide/Templates/BuildingBlocks/StarterBuildingBlocksOnCanvas_spec.ts Adjusting and removing specific test cases related to building blocks functionality.

Assessment against linked issues

Objective Addressed Explanation
Enable drag-and-drop functionality for building blocks on the canvas. [#31314] While the PR enhances building block handling, specific implementation of drag-and-drop functionality is not explicitly mentioned.
Address critical issue of existing queries and JS objects being deleted when adding building blocks. [#32573] The changes do not directly address preventing the deletion of existing queries and JS objects as reported in the linked issue.
Enhance backend operations for adding queries, JavaScript, and datasources. [#31315] Although backend improvements are suggested, detailed specifics on queries, JavaScript, and datasources integration are not explicitly reflected in the changes.

Possibly related issues


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.

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

@rahulbarwal rahulbarwal left a comment

Choose a reason for hiding this comment

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

/build-deploy-preview skip-tests=true

@github-actions github-actions bot added Critical This issue needs immediate attention. Drop everything else Needs Triaging Needs attention from maintainers to triage Production Templates Issues related to templates labels Apr 12, 2024
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

Comment on lines 294 to 325
const buildingBlockDsl = JSON.parse(response.data.widgetDsl);
const buildingBlockWidgets = buildingBlockDsl.children;
const flattenedBlockWidgets = buildingBlockWidgets.map(
(widget: WidgetProps) => flattenDSL(widget),
);

// 3. Rename the template page to clicked from page
yield fork(renameStarterTemplatePageToDefault, templatePageIds[0]);
const widgetsToPasteInCanvas: CopiedWidgetData[] = yield all(
flattenedBlockWidgets.map(
(widget: FlattenedWidgetProps, index: number) => {
let widgetPositionInfo: WidgetLayoutPositionInfo | null = null;
if (
widget.parentId &&
layoutSystemType === LayoutSystemTypes.ANVIL
) {
widgetPositionInfo = getWidgetLayoutMetaInfo(
allWidgets[widget?.parentId]?.layout[0] ?? null,
widget.widgetId,
);
}
return {
hierarchy: getWidgetHierarchy(
buildingBlockWidgets[index].type,
buildingBlockWidgets[index].widgetId,
),
list: Object.values(widget)
.map((obj) => ({ ...obj }))
.reverse(),
parentId: MAIN_CONTAINER_WIDGET_ID,
widgetId: buildingBlockWidgets[index].widgetId,
widgetPositionInfo,
};
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Optimize the mapping and processing of widgets in apiCallForForkBuildingBlockToApplication. The current implementation involves multiple mappings and transformations which could be simplified or optimized to improve performance, especially if the number of widgets is large.

@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

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

Copy link

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

@rahulbarwal rahulbarwal added the ok-to-test Required label for CI label Apr 15, 2024
@rahulbarwal rahulbarwal added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Apr 15, 2024
…o bugfix/32573-bb-on-canvas-removes-existing-queries-jsobjects
@rahulbarwal rahulbarwal added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Apr 16, 2024
@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

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

Copy link

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

@rahulbarwal rahulbarwal added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Apr 22, 2024
…o bugfix/32573-bb-on-canvas-removes-existing-queries-jsobjects
@rahulbarwal rahulbarwal added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Apr 22, 2024
@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

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

Copy link

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

@github-actions github-actions bot removed the Stale label Apr 22, 2024
@github-actions github-actions bot added the Stale label Apr 23, 2024
@rahulbarwal
Copy link
Contributor Author

/ci-test-limit runId=8782108653

Copy link

@ApekshaBhosale
Copy link
Contributor

/ci-test-limit

1 similar comment
@ApekshaBhosale
Copy link
Contributor

/ci-test-limit

Copy link

Copy link

Copy link

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

Copy link

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

@rahulbarwal rahulbarwal added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Apr 23, 2024
@rahulbarwal rahulbarwal merged commit 7c40343 into release Apr 23, 2024
13 checks passed
@rahulbarwal rahulbarwal deleted the bugfix/32573-bb-on-canvas-removes-existing-queries-jsobjects branch April 23, 2024 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Building blocks Building blocks on cavas, on templates listing or drag and drop of building blocks. Critical This issue needs immediate attention. Drop everything else Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Production Stale Templates Pod Issues related to Templates Templates Issues related to templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Canvas starter building blocks cause existing queries and Js in apps to be deleted
3 participants