## Description > [!TIP] **Goal** To drag any building blocks from the explorer and drop at any position on the users canvas with full implementation. **Implementation** - Show skeleton widget when building block is initially dragged unto the canvas. - Make API call to add datasources, queries, and JS to existing page of users app - Get returned widget DSL and use existing copy paste logic to display widgets on the canvas - Remove loading state, handle clean up for copy paste - Run all queries newly created by the dropped building block **Limitations** - There is a loading state and the process is not instant like dropping a widget This PR is followed by this one [here](https://github.com/appsmithorg/appsmith/pull/31406), which displays the loading state when a building block is dragged unto the canvas. Fixes #31856 ## Automation /ok-to-test tags="@tag.Templates, @tag.MainContainer, @tag.Visual, @tag.Widget" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/8701664455> > Commit: 456a7a0a322e76974a7f5c41a6c1e274ef82e4ea > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8701664455&attempt=1" target="_blank">Click here!</a> <!-- end of auto-generated comment: Cypress test results --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new "Building Blocks" category in the widget sidebar for enhanced organization and accessibility. - Added functionality to resize building blocks with new horizontal and vertical limits. - Implemented a "see more" button for "Building Blocks" to display all associated widgets. - Enhanced drag and drop functionality for building blocks on the canvas. - **Enhancements** - Improved sorting logic for widgets, prioritizing "Building Blocks". - Enhanced widget search functionality within the sidebar. - **Bug Fixes** - Adjusted default rows and columns settings for explorer building blocks to improve layout and usability. - **Documentation** - Updated messages and constants related to new features for clarity and consistency. - **Refactor** - Refactored drag and drop handling logic to support new building block constraints and features. - Updated application state management to include building blocks related data. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Anagh Hegde <anagh@appsmith.com> Co-authored-by: Rahul Barwal <rahul.barwal@appsmith.com>
53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
import type { AppState } from "@appsmith/reducers";
|
|
import { getIsAnvilLayoutEnabled } from "layoutSystems/anvil/integrations/selectors";
|
|
import { getAnvilWidgetDOMId } from "layoutSystems/common/utils/LayoutElementPositionsObserver/utils";
|
|
import { LayoutSystemTypes } from "layoutSystems/types";
|
|
|
|
/**
|
|
* Returns the layout system type based on the state of the application.
|
|
* @param state - The current state of the application.
|
|
* @returns The layout system type.
|
|
*/
|
|
export const getLayoutSystemType = (state: AppState) => {
|
|
// Check if the application has a defined appPositioning type
|
|
if (
|
|
state.ui.applications?.currentApplication?.applicationDetail?.appPositioning
|
|
?.type
|
|
) {
|
|
// Get the layout system type based on the appPositioning type
|
|
const layoutSystemType =
|
|
LayoutSystemTypes[
|
|
state.ui.applications.currentApplication?.applicationDetail
|
|
?.appPositioning?.type
|
|
];
|
|
// If the layout system type is not ANVIL, return it
|
|
if (layoutSystemType !== LayoutSystemTypes.ANVIL) {
|
|
return layoutSystemType;
|
|
}
|
|
// Check if the ANVIL layout system is enabled
|
|
const isAnvilEnabled = getIsAnvilLayoutEnabled(state);
|
|
// If ANVIL is enabled, return ANVIL as the layout system type
|
|
if (isAnvilEnabled) {
|
|
return LayoutSystemTypes.ANVIL;
|
|
}
|
|
}
|
|
// If no layout system type is found, return FIXED as the default layout system type
|
|
return LayoutSystemTypes.FIXED;
|
|
};
|
|
|
|
export const getWidgetSelectorByWidgetId = (
|
|
state: AppState,
|
|
widgetId: string,
|
|
) => {
|
|
const layoutSystemType = getLayoutSystemType(state);
|
|
switch (layoutSystemType) {
|
|
case LayoutSystemTypes.ANVIL:
|
|
return getAnvilWidgetDOMId(widgetId);
|
|
default:
|
|
return widgetId;
|
|
}
|
|
};
|
|
|
|
export const isFixedLayoutSelector = (state: AppState) =>
|
|
getLayoutSystemType(state) === LayoutSystemTypes.FIXED;
|