2025-01-10 04:51:54 +00:00
|
|
|
import type { ReduxAction } from "actions/ReduxActionTypes";
|
2021-09-21 07:55:56 +00:00
|
|
|
import {
|
|
|
|
|
ReduxActionErrorTypes,
|
|
|
|
|
ReduxActionTypes,
|
|
|
|
|
WidgetReduxActionTypes,
|
2024-08-06 14:52:22 +00:00
|
|
|
} from "ee/constants/ReduxActionConstants";
|
|
|
|
|
import { ENTITY_TYPE } from "ee/entities/AppsmithConsole/utils";
|
2024-04-16 08:41:09 +00:00
|
|
|
import type { WidgetBlueprint } from "WidgetProvider/constants";
|
|
|
|
|
import {
|
|
|
|
|
BlueprintOperationTypes,
|
|
|
|
|
GRID_DENSITY_MIGRATION_V1,
|
|
|
|
|
} from "WidgetProvider/constants";
|
|
|
|
|
import WidgetFactory from "WidgetProvider/factory";
|
|
|
|
|
import { generateAutoHeightLayoutTreeAction } from "actions/autoHeightActions";
|
|
|
|
|
import type { WidgetAddChild } from "actions/pageActions";
|
|
|
|
|
import { updateAndSaveLayout } from "actions/pageActions";
|
2024-03-08 14:29:29 +00:00
|
|
|
import {
|
|
|
|
|
BUILDING_BLOCK_EXPLORER_TYPE,
|
|
|
|
|
RenderModes,
|
|
|
|
|
} from "constants/WidgetConstants";
|
2024-08-09 14:20:29 +00:00
|
|
|
import { toast } from "@appsmith/ads";
|
2024-04-16 08:41:09 +00:00
|
|
|
import type { DataTree } from "entities/DataTree/dataTreeTypes";
|
|
|
|
|
import produce from "immer";
|
|
|
|
|
import { klona as clone } from "klona/full";
|
|
|
|
|
import { getWidgetMinMaxDimensionsInPixel } from "layoutSystems/autolayout/utils/flexWidgetUtils";
|
|
|
|
|
import { ResponsiveBehavior } from "layoutSystems/common/utils/constants";
|
|
|
|
|
import { isFunction } from "lodash";
|
|
|
|
|
import omit from "lodash/omit";
|
|
|
|
|
import log from "loglevel";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### 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
- [x] 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
- [x] 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:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type {
|
2021-09-21 07:55:56 +00:00
|
|
|
CanvasWidgetsReduxState,
|
|
|
|
|
FlattenedWidgetProps,
|
|
|
|
|
} from "reducers/entityReducers/canvasWidgetsReducer";
|
2024-04-29 10:13:39 +00:00
|
|
|
import { all, call, put, select, takeEvery } from "redux-saga/effects";
|
2024-04-16 08:41:09 +00:00
|
|
|
import { getDataTree } from "selectors/dataTreeSelectors";
|
|
|
|
|
import {
|
|
|
|
|
getCanvasWidth,
|
|
|
|
|
getIsAutoLayout,
|
|
|
|
|
getIsAutoLayoutMobileBreakPoint,
|
|
|
|
|
} from "selectors/editorSelectors";
|
2021-09-21 07:55:56 +00:00
|
|
|
import AppsmithConsole from "utils/AppsmithConsole";
|
|
|
|
|
import { getNextEntityName } from "utils/AppsmithUtils";
|
|
|
|
|
import { generateWidgetProps } from "utils/WidgetPropsUtils";
|
2024-04-16 08:41:09 +00:00
|
|
|
import { generateReactKey } from "utils/generators";
|
|
|
|
|
import type { WidgetProps } from "widgets/BaseWidget";
|
|
|
|
|
import { isStack } from "../layoutSystems/autolayout/utils/AutoLayoutUtils";
|
2021-09-21 07:55:56 +00:00
|
|
|
import {
|
|
|
|
|
buildWidgetBlueprint,
|
2023-02-21 04:13:25 +00:00
|
|
|
executeWidgetBlueprintBeforeOperations,
|
2021-09-21 07:55:56 +00:00
|
|
|
executeWidgetBlueprintOperations,
|
|
|
|
|
traverseTreeAndExecuteBlueprintChildOperations,
|
|
|
|
|
} from "./WidgetBlueprintSagas";
|
2022-05-04 09:45:57 +00:00
|
|
|
import { getPropertiesToUpdate } from "./WidgetOperationSagas";
|
2024-04-29 10:13:39 +00:00
|
|
|
import { getWidget, getWidgets } from "./selectors";
|
2024-05-09 04:29:12 +00:00
|
|
|
import { addBuildingBlockToCanvasSaga } from "./BuildingBlockSagas/BuildingBlockAdditionSagas";
|
feat: add analytics for drag and drop building blocks (#32699)
## Description
> [!TIP]
Add events to track the dragging of building blocks, dropping of blocks,
and the time taken from drag till drop is complete.
**Drag Event**
```
AnalyticsUtil.logEvent("DRAG_BUILDING_BLOCK_INITIATED", {
applicationId,
workspaceId,
source: "explorer",
eventData: {
buildingBlockName: props.details.displayName,
},
});
```
**Drop Event**
```
AnalyticsUtil.logEvent("DROP_BUILDING_BLOCK_INITIATED", {
applicationId,
workspaceId,
source: "explorer",
eventData: {
buildingBlockName: props.details.displayName,
},
});
AnalyticsUtil.logEvent("DROP_BUILDING_BLOCK_COMPLETED", {
applicationId,
workspaceId,
source: "explorer",
eventData: {
buildingBlockName: dragDetails.newWidget.displayName,
timeTakenToCompletion: timeTakenTo CompleteValueInSeconds,
timeTakenToDropWidgets: timeTakenValueInSeconds
},
});
```
Fixes #32492
## Automation
/ok-to-test tags="@tag.Widget"
### :mag: 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/8785306375>
> Commit: 8316506b039256ad6d171a3a81ddaec56cecdfc2
> Cypress dashboard url: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8785306375&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 analytics tracking for building block drag-and-drop
operations.
- Enhanced functionality for adding and managing building blocks within
the application.
- **Refactor**
- Updated action type constants for better consistency in handling
building block operations.
- **Bug Fixes**
- Improved logic for setting the start time of building block drag
operations to ensure accurate tracking.
<!-- 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>
2024-04-22 14:58:37 +00:00
|
|
|
|
2021-09-21 07:55:56 +00:00
|
|
|
const WidgetTypes = WidgetFactory.widgetTypes;
|
|
|
|
|
|
2023-12-26 14:16:58 +00:00
|
|
|
export interface GeneratedWidgetPayload {
|
2021-09-21 07:55:56 +00:00
|
|
|
widgetId: string;
|
|
|
|
|
widgets: { [widgetId: string]: FlattenedWidgetProps };
|
2023-10-11 07:35:24 +00:00
|
|
|
}
|
2021-09-21 07:55:56 +00:00
|
|
|
|
2023-10-11 07:35:24 +00:00
|
|
|
interface WidgetAddTabChild {
|
2024-07-31 15:41:28 +00:00
|
|
|
// TODO: Fix this the next time the file is edited
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2021-09-21 07:55:56 +00:00
|
|
|
tabs: any;
|
|
|
|
|
widgetId: string;
|
2023-10-11 07:35:24 +00:00
|
|
|
}
|
2021-09-21 07:55:56 +00:00
|
|
|
|
|
|
|
|
function* getEntityNames() {
|
2022-06-21 13:57:34 +00:00
|
|
|
const evalTree: DataTree = yield select(getDataTree);
|
2024-09-18 16:35:28 +00:00
|
|
|
|
2021-09-21 07:55:56 +00:00
|
|
|
return Object.keys(evalTree);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function* getChildWidgetProps(
|
|
|
|
|
parent: FlattenedWidgetProps,
|
|
|
|
|
params: WidgetAddChild,
|
|
|
|
|
widgets: { [widgetId: string]: FlattenedWidgetProps },
|
|
|
|
|
) {
|
|
|
|
|
const { leftColumn, newWidgetId, topRow, type } = params;
|
2023-10-27 06:24:26 +00:00
|
|
|
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### 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
- [x] 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
- [x] 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:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
let { columns, parentColumnSpace, parentRowSpace, props, rows, widgetName } =
|
|
|
|
|
params;
|
2021-09-21 07:55:56 +00:00
|
|
|
let minHeight = undefined;
|
|
|
|
|
const restDefaultConfig = omit(WidgetFactory.widgetConfigMap.get(type), [
|
|
|
|
|
"blueprint",
|
|
|
|
|
]);
|
2022-11-28 04:44:31 +00:00
|
|
|
const themeDefaultConfig =
|
|
|
|
|
WidgetFactory.getWidgetStylesheetConfigMap(type) || {};
|
2023-04-07 13:51:35 +00:00
|
|
|
const mainCanvasWidth: number = yield select(getCanvasWidth);
|
|
|
|
|
const isMobile: boolean = yield select(getIsAutoLayoutMobileBreakPoint);
|
2022-11-28 04:44:31 +00:00
|
|
|
|
2021-09-21 07:55:56 +00:00
|
|
|
if (!widgetName) {
|
|
|
|
|
const widgetNames = Object.keys(widgets).map((w) => widgets[w].widgetName);
|
|
|
|
|
const entityNames: string[] = yield call(getEntityNames);
|
|
|
|
|
|
|
|
|
|
widgetName = getNextEntityName(restDefaultConfig.widgetName, [
|
|
|
|
|
...widgetNames,
|
|
|
|
|
...entityNames,
|
|
|
|
|
]);
|
|
|
|
|
}
|
2024-09-18 16:35:28 +00:00
|
|
|
|
2021-09-21 07:55:56 +00:00
|
|
|
if (type === "CANVAS_WIDGET") {
|
|
|
|
|
columns =
|
|
|
|
|
(parent.rightColumn - parent.leftColumn) * parent.parentColumnSpace;
|
|
|
|
|
parentColumnSpace = 1;
|
|
|
|
|
rows = (parent.bottomRow - parent.topRow) * parent.parentRowSpace;
|
|
|
|
|
parentRowSpace = 1;
|
|
|
|
|
minHeight = rows;
|
|
|
|
|
// if (props) props.children = [];
|
|
|
|
|
|
|
|
|
|
if (props) {
|
|
|
|
|
props = produce(props, (draft: WidgetProps) => {
|
|
|
|
|
if (!draft.children || !Array.isArray(draft.children)) {
|
|
|
|
|
draft.children = [];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-04 07:25:54 +00:00
|
|
|
const isAutoLayout = isStack(widgets, parent);
|
2023-04-07 13:51:35 +00:00
|
|
|
const isFillWidget =
|
|
|
|
|
restDefaultConfig?.responsiveBehavior === ResponsiveBehavior.Fill;
|
2024-09-18 16:35:28 +00:00
|
|
|
|
2023-04-07 13:51:35 +00:00
|
|
|
if (isAutoLayout && isFillWidget) columns = 64;
|
2023-03-04 07:25:54 +00:00
|
|
|
|
2021-09-21 07:55:56 +00:00
|
|
|
const widgetProps = {
|
|
|
|
|
...restDefaultConfig,
|
|
|
|
|
...props,
|
|
|
|
|
columns,
|
|
|
|
|
rows,
|
|
|
|
|
minHeight,
|
|
|
|
|
widgetId: newWidgetId,
|
|
|
|
|
renderMode: RenderModes.CANVAS,
|
2022-05-04 09:45:57 +00:00
|
|
|
...themeDefaultConfig,
|
2021-09-21 07:55:56 +00:00
|
|
|
};
|
2023-04-07 13:51:35 +00:00
|
|
|
|
|
|
|
|
const { minWidth } = getWidgetMinMaxDimensionsInPixel(
|
|
|
|
|
widgetProps,
|
|
|
|
|
mainCanvasWidth,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// If the width of new widget is less than min width, set the width to min width
|
|
|
|
|
if (minWidth && columns * parentColumnSpace < minWidth) {
|
|
|
|
|
columns = minWidth / parentColumnSpace;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-21 07:55:56 +00:00
|
|
|
const widget = generateWidgetProps(
|
|
|
|
|
parent,
|
|
|
|
|
type,
|
|
|
|
|
leftColumn,
|
|
|
|
|
topRow,
|
|
|
|
|
parentRowSpace,
|
|
|
|
|
parentColumnSpace,
|
|
|
|
|
widgetName,
|
|
|
|
|
widgetProps,
|
|
|
|
|
restDefaultConfig.version,
|
|
|
|
|
);
|
|
|
|
|
|
2023-04-07 13:51:35 +00:00
|
|
|
let { disableResizeHandles } = WidgetFactory.getWidgetAutoLayoutConfig(type);
|
2024-09-18 16:35:28 +00:00
|
|
|
|
2023-04-07 13:51:35 +00:00
|
|
|
if (isFunction(disableResizeHandles)) {
|
|
|
|
|
disableResizeHandles = disableResizeHandles(widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isAutoLayout) {
|
|
|
|
|
// For hug widgets with horizontal resizing enabled, set the initial value for widthInPercentage
|
|
|
|
|
if (!isFillWidget && !disableResizeHandles?.horizontal) {
|
|
|
|
|
if (isMobile) {
|
|
|
|
|
widget.mobileWidthInPercentage =
|
|
|
|
|
(columns * parentColumnSpace) / mainCanvasWidth;
|
|
|
|
|
} else {
|
|
|
|
|
widget.widthInPercentage =
|
|
|
|
|
(columns * parentColumnSpace) / mainCanvasWidth;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-21 07:55:56 +00:00
|
|
|
widget.widgetId = newWidgetId;
|
chore: Reduce DSL size by removing runtime values from the DSL. (#34894)
## Description
Today, the DSL contains many properties that are not necessary to be
persisted, as these are properties which are inherent to the widget type
and are statically available in the codebase and during runtime.
`getChildWidgetProps` is the lowest level function the widget addition
flow that is not used in recursion and does not need to return these
runtime properties for proper functioning of the widget addition flow.
The flow is as follows:
`addChildSaga` -> `getUpdateDSLAfterCreatingChild` ->
`generateChildWidgets` -> `getChildWidgetProps` -> `generateWidgetProps`
(Don't understand the distinction in the names of the functions? Me
neither)
In this PR, we're selectively deleting the properties which are going to
be set into the DSL and are not required by the DSL. This is done in the
`getChildWidgetProps` function.
DSL Before:
```{
"isVisible": true,
"type": "BUTTON_WIDGET",
"animateLoading": true,
"text": "Submit",
"buttonVariant": "PRIMARY",
"placement": "CENTER",
"widgetName": "Button1",
"isDisabled": false,
"isDefaultClickDisabled": true,
"disabledWhenInvalid": false,
"resetFormOnClick": false,
"recaptchaType": "V3",
"version": 1,
"responsiveBehavior": "hug",
"minWidth": 120,
"searchTags": ["click", "submit"],
"tags": ["Buttons"],
"hideCard": false,
"isDeprecated": false,
"displayName": "Button",
"key": "yngxey92vx",
"iconSVG": "https://release-appcdn.appsmith.com/static/media/icon.7a418b9e1899a550d7e8f33b48cbde12.svg",
"thumbnailSVG": "https://release-appcdn.appsmith.com/static/media/thumbnail.a348658e996feaad96cadc30d99374ff.svg",
"needsErrorInfo": false,
"onCanvasUI": {
"selectionBGCSSVar": "--on-canvas-ui-widget-selection",
"focusBGCSSVar": "--on-canvas-ui-widget-focus",
"selectionColorCSSVar": "--on-canvas-ui-widget-focus",
"focusColorCSSVar": "--on-canvas-ui-widget-selection",
"disableParentSelection": false
},
"widgetId": "3du74sjd24",
"renderMode": "CANVAS",
"buttonColor": "{{appsmith.theme.colors.primaryColor}}",
"borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}",
"boxShadow": "none",
"isLoading": false,
"parentColumnSpace": 16.21875,
"parentRowSpace": 10,
"leftColumn": 16,
"rightColumn": 32,
"topRow": 27,
"bottomRow": 31,
"mobileLeftColumn": 16,
"mobileRightColumn": 32,
"mobileTopRow": 27,
"mobileBottomRow": 31,
"parentId": "0",
"dynamicBindingPathList": [
{ "key": "buttonColor" },
{ "key": "borderRadius" }
]
}
```
DSL After:
```
{
"isVisible": true,
"type": "BUTTON_WIDGET",
"animateLoading": true,
"text": "Submit",
"buttonVariant": "PRIMARY",
"placement": "CENTER",
"widgetName": "Button1",
"isDisabled": false,
"isDefaultClickDisabled": true,
"disabledWhenInvalid": false,
"resetFormOnClick": false,
"recaptchaType": "V3",
"version": 1,
"responsiveBehavior": "hug",
"minWidth": 120,
"key": "gtjsfondgr",
"needsErrorInfo": false,
"widgetId": "cszodka6p1",
"renderMode": "CANVAS",
"buttonColor": "{{appsmith.theme.colors.primaryColor}}",
"borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}",
"boxShadow": "none",
"isLoading": false,
"parentColumnSpace": 16.21875,
"parentRowSpace": 10,
"leftColumn": 18,
"rightColumn": 34,
"topRow": 28,
"bottomRow": 32,
"mobileLeftColumn": 18,
"mobileRightColumn": 34,
"mobileTopRow": 28,
"mobileBottomRow": 32,
"parentId": "0",
"dynamicBindingPathList": [
{ "key": "buttonColor" },
{ "key": "borderRadius" }
]
}
```
Fixes #21825
## Automation
/ok-to-test tags="@tag.All"
### :mag: 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/9904027497>
> Commit: b6eac580e47dcdd0b056acdb574aac7b8c7cba2f
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9904027497&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Fri, 12 Jul 2024 08:10:58 UTC
<!-- end of auto-generated comment: Cypress test results -->
## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **Refactor**
- Improved the drag state generation logic for fixed layouts to enhance
performance and maintainability.
- Simplified the `widget` object in the `WidgetAdditionSagas` to remove
unnecessary properties, improving clarity and efficiency.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-07-16 04:17:55 +00:00
|
|
|
// Remove props that don't belong in the DSL and can be accessed using
|
|
|
|
|
// the widget type's static methods and configurations
|
|
|
|
|
// Fixes #21825
|
|
|
|
|
widget.rows = undefined;
|
|
|
|
|
widget.columns = undefined;
|
|
|
|
|
widget.name = undefined;
|
|
|
|
|
widget.iconSVG = undefined;
|
|
|
|
|
widget.thumbnailSVG = undefined;
|
|
|
|
|
widget.hideCard = undefined;
|
|
|
|
|
widget.isDeprecated = undefined;
|
|
|
|
|
widget.needsMeta = undefined;
|
|
|
|
|
widget.searchTags = undefined;
|
|
|
|
|
widget.tags = undefined;
|
|
|
|
|
widget.displayName = undefined;
|
|
|
|
|
widget.onCanvasUI = undefined;
|
|
|
|
|
widget.eagerRender = undefined;
|
|
|
|
|
widget.needsHeightForContent = undefined;
|
|
|
|
|
widget.features = undefined;
|
|
|
|
|
widget.replacement = undefined;
|
|
|
|
|
|
2022-12-12 04:43:18 +00:00
|
|
|
/**
|
|
|
|
|
* un-evaluated childStylesheet used by widgets; so they are to be excluded
|
|
|
|
|
* from the dynamicBindingPathList and they are not included as a part of
|
|
|
|
|
* the props send to getPropertiesToUpdate.
|
|
|
|
|
*/
|
|
|
|
|
const themeConfigWithoutChildStylesheet = omit(
|
|
|
|
|
themeDefaultConfig,
|
|
|
|
|
"childStylesheet",
|
|
|
|
|
);
|
2023-07-03 05:08:01 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TODO: Balaji Soundararajan @sbalaji1192
|
|
|
|
|
* We are not getting all the paths with dynamic value here. Therefore we
|
|
|
|
|
* are not adding them to the dynamic binding path list. This creates an issue
|
|
|
|
|
* when adding a new widget that has a property with dynamic value resulting
|
|
|
|
|
* in an unevaluated value.
|
|
|
|
|
* Furthermore, even if use all the widget paths instead of the updates paths
|
|
|
|
|
* in the getPropertiesToUpdate function, we have to omit the blueprint paths.
|
|
|
|
|
*/
|
2022-05-04 09:45:57 +00:00
|
|
|
const { dynamicBindingPathList } = yield call(
|
|
|
|
|
getPropertiesToUpdate,
|
|
|
|
|
widget,
|
2022-12-12 04:43:18 +00:00
|
|
|
themeConfigWithoutChildStylesheet,
|
2022-05-04 09:45:57 +00:00
|
|
|
);
|
2023-02-20 12:03:54 +00:00
|
|
|
|
|
|
|
|
if (params.dynamicBindingPathList) {
|
|
|
|
|
const mergedDynamicBindingPathLists = [
|
|
|
|
|
...dynamicBindingPathList,
|
|
|
|
|
...params.dynamicBindingPathList,
|
|
|
|
|
];
|
2024-09-18 16:35:28 +00:00
|
|
|
|
2023-02-20 12:03:54 +00:00
|
|
|
widget.dynamicBindingPathList = mergedDynamicBindingPathLists;
|
|
|
|
|
} else {
|
|
|
|
|
widget.dynamicBindingPathList = clone(dynamicBindingPathList);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-21 07:55:56 +00:00
|
|
|
return widget;
|
|
|
|
|
}
|
2022-05-04 09:45:57 +00:00
|
|
|
|
2023-03-04 07:25:54 +00:00
|
|
|
export function* generateChildWidgets(
|
2021-09-21 07:55:56 +00:00
|
|
|
parent: FlattenedWidgetProps,
|
|
|
|
|
params: WidgetAddChild,
|
|
|
|
|
widgets: { [widgetId: string]: FlattenedWidgetProps },
|
|
|
|
|
propsBlueprint?: WidgetBlueprint,
|
2024-07-31 15:41:28 +00:00
|
|
|
// TODO: Fix this the next time the file is edited
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2021-09-21 07:55:56 +00:00
|
|
|
): any {
|
|
|
|
|
// Get the props for the widget
|
|
|
|
|
const widget = yield getChildWidgetProps(parent, params, widgets);
|
|
|
|
|
|
|
|
|
|
// Add the widget to the canvasWidgets
|
|
|
|
|
// We need this in here as widgets will be used to get the current widget
|
|
|
|
|
widgets[widget.widgetId] = widget;
|
|
|
|
|
|
|
|
|
|
// Get the default config for the widget from WidgetConfigResponse
|
|
|
|
|
const defaultConfig = { ...WidgetFactory.widgetConfigMap.get(widget.type) };
|
|
|
|
|
|
|
|
|
|
// If blueprint is provided in the params, use that
|
|
|
|
|
// else use the blueprint available in WidgetConfigResponse
|
|
|
|
|
// else there is no blueprint for this widget
|
|
|
|
|
const blueprint =
|
|
|
|
|
propsBlueprint || { ...defaultConfig?.blueprint } || undefined;
|
|
|
|
|
|
|
|
|
|
// If there is a blueprint.view
|
|
|
|
|
// We need to generate the children based on the view
|
|
|
|
|
if (blueprint && blueprint.view) {
|
|
|
|
|
// Get the list of children props in WidgetAddChild format
|
|
|
|
|
const childWidgetList: WidgetAddChild[] = yield call(
|
|
|
|
|
buildWidgetBlueprint,
|
|
|
|
|
blueprint,
|
|
|
|
|
widget.widgetId,
|
|
|
|
|
);
|
|
|
|
|
// For each child props
|
|
|
|
|
const childPropsList: GeneratedWidgetPayload[] = yield all(
|
|
|
|
|
childWidgetList.map((props: WidgetAddChild) => {
|
|
|
|
|
// Generate full widget props
|
|
|
|
|
// Notice that we're passing the blueprint if it exists.
|
|
|
|
|
return generateChildWidgets(
|
|
|
|
|
widget,
|
|
|
|
|
props,
|
|
|
|
|
widgets,
|
|
|
|
|
props.props?.blueprint,
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
);
|
2024-09-18 16:35:28 +00:00
|
|
|
|
2021-09-21 07:55:56 +00:00
|
|
|
// Start children array from scratch
|
|
|
|
|
widget.children = [];
|
|
|
|
|
childPropsList.forEach((props: GeneratedWidgetPayload) => {
|
|
|
|
|
// Push the widgetIds of the children generated above into the widget.children array
|
|
|
|
|
widget.children.push(props.widgetId);
|
|
|
|
|
// Add the list of widgets generated into the canvasWidgets
|
|
|
|
|
widgets = props.widgets;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Finally, add the widget to the canvasWidgets
|
|
|
|
|
// This is different from above, as this is the final widget props with
|
|
|
|
|
// a fully populated widget.children property
|
|
|
|
|
widgets[widget.widgetId] = widget;
|
|
|
|
|
|
|
|
|
|
// Some widgets need to run a few operations like modifying props or adding an action
|
|
|
|
|
// these operations can be performed on the parent of the widget we're adding
|
|
|
|
|
// therefore, we pass all widgets to executeWidgetBlueprintOperations
|
|
|
|
|
// blueprint.operations contain the set of operations to perform to update the canvasWidgets
|
|
|
|
|
if (blueprint && blueprint.operations && blueprint.operations.length > 0) {
|
|
|
|
|
// Finalize the canvasWidgets with everything that needs to be updated
|
|
|
|
|
widgets = yield call(
|
|
|
|
|
executeWidgetBlueprintOperations,
|
|
|
|
|
blueprint.operations,
|
|
|
|
|
widgets,
|
|
|
|
|
widget.widgetId,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add the parentId prop to this widget
|
|
|
|
|
widget.parentId = parent.widgetId;
|
|
|
|
|
// Remove the blueprint from the widget (if any)
|
|
|
|
|
// as blueprints are not useful beyond this point.
|
|
|
|
|
delete widget.blueprint;
|
|
|
|
|
|
|
|
|
|
// deleting propertyPaneEnchancements too as it shouldn't go in dsl because
|
|
|
|
|
// function can't be cloned into dsl
|
|
|
|
|
|
|
|
|
|
// instead of passing whole enhancments function in widget props, we are just setting
|
|
|
|
|
// enhancments as true so that we know this widget contains enhancments
|
|
|
|
|
if ("enhancements" in widget) {
|
|
|
|
|
widget.enhancements = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { widgetId: widget.widgetId, widgets };
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-13 13:21:57 +00:00
|
|
|
export function* getUpdateDslAfterCreatingChild(
|
|
|
|
|
addChildPayload: WidgetAddChild,
|
|
|
|
|
) {
|
2021-09-21 07:55:56 +00:00
|
|
|
// NOTE: widgetId here is the parentId of the dropped widget ( we should rename it to avoid confusion )
|
|
|
|
|
const { widgetId } = addChildPayload;
|
|
|
|
|
// Get the current parent widget whose child will be the new widget.
|
|
|
|
|
const stateParent: FlattenedWidgetProps = yield select(getWidget, widgetId);
|
|
|
|
|
// const parent = Object.assign({}, stateParent);
|
|
|
|
|
// Get all the widgets from the canvasWidgetsReducer
|
2022-06-21 13:57:34 +00:00
|
|
|
const stateWidgets: CanvasWidgetsReduxState = yield select(getWidgets);
|
2021-09-21 07:55:56 +00:00
|
|
|
const widgets = Object.assign({}, stateWidgets);
|
|
|
|
|
// Generate the full WidgetProps of the widget to be added.
|
|
|
|
|
const childWidgetPayload: GeneratedWidgetPayload = yield generateChildWidgets(
|
|
|
|
|
stateParent,
|
|
|
|
|
addChildPayload,
|
|
|
|
|
widgets,
|
2022-01-25 13:56:52 +00:00
|
|
|
// sending blueprint for onboarding usecase
|
|
|
|
|
addChildPayload.props?.blueprint,
|
2021-09-21 07:55:56 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Update widgets to put back in the canvasWidgetsReducer
|
|
|
|
|
// TODO(abhinav): This won't work if dont already have an empty children: []
|
|
|
|
|
const parent = {
|
|
|
|
|
...stateParent,
|
|
|
|
|
children: [...(stateParent.children || []), childWidgetPayload.widgetId],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
widgets[parent.widgetId] = parent;
|
|
|
|
|
AppsmithConsole.info({
|
|
|
|
|
text: "Widget was created",
|
|
|
|
|
source: {
|
|
|
|
|
type: ENTITY_TYPE.WIDGET,
|
|
|
|
|
id: childWidgetPayload.widgetId,
|
|
|
|
|
name: childWidgetPayload.widgets[childWidgetPayload.widgetId].widgetName,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
yield put({
|
|
|
|
|
type: WidgetReduxActionTypes.WIDGET_CHILD_ADDED,
|
|
|
|
|
payload: {
|
|
|
|
|
widgetId: childWidgetPayload.widgetId,
|
|
|
|
|
type: addChildPayload.type,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
// some widgets need to update property of parent if the parent have CHILD_OPERATIONS
|
|
|
|
|
// so here we are traversing up the tree till we get to MAIN_CONTAINER_WIDGET_ID
|
|
|
|
|
// while traversing, if we find any widget which has CHILD_OPERATION, we will call the fn in it
|
|
|
|
|
const updatedWidgets: CanvasWidgetsReduxState = yield call(
|
|
|
|
|
traverseTreeAndExecuteBlueprintChildOperations,
|
|
|
|
|
parent,
|
2022-12-17 20:03:35 +00:00
|
|
|
[addChildPayload.newWidgetId],
|
2021-09-21 07:55:56 +00:00
|
|
|
widgets,
|
|
|
|
|
);
|
2022-09-30 08:19:52 +00:00
|
|
|
|
2021-09-21 07:55:56 +00:00
|
|
|
return updatedWidgets;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this saga is called when we drop a widget on the canvas.
|
|
|
|
|
*
|
|
|
|
|
* @param addChildAction
|
|
|
|
|
*/
|
2024-04-16 08:41:09 +00:00
|
|
|
export function* addChildSaga(
|
|
|
|
|
addChildAction: ReduxAction<
|
|
|
|
|
WidgetAddChild & {
|
|
|
|
|
shouldReplay?: boolean;
|
|
|
|
|
}
|
|
|
|
|
>,
|
|
|
|
|
) {
|
2021-09-21 07:55:56 +00:00
|
|
|
try {
|
|
|
|
|
const start = performance.now();
|
2024-09-18 16:35:28 +00:00
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
toast.dismiss();
|
2023-02-21 04:13:25 +00:00
|
|
|
const stateWidgets: CanvasWidgetsReduxState = yield select(getWidgets);
|
|
|
|
|
const { newWidgetId, type, widgetId } = addChildAction.payload;
|
|
|
|
|
|
|
|
|
|
yield call(
|
|
|
|
|
executeWidgetBlueprintBeforeOperations,
|
|
|
|
|
BlueprintOperationTypes.BEFORE_ADD,
|
|
|
|
|
{
|
|
|
|
|
parentId: widgetId,
|
|
|
|
|
widgetId: newWidgetId,
|
|
|
|
|
widgets: stateWidgets,
|
|
|
|
|
widgetType: type,
|
|
|
|
|
},
|
|
|
|
|
);
|
2023-02-20 12:03:54 +00:00
|
|
|
|
2021-09-21 07:55:56 +00:00
|
|
|
const updatedWidgets: {
|
|
|
|
|
[widgetId: string]: FlattenedWidgetProps;
|
|
|
|
|
} = yield call(getUpdateDslAfterCreatingChild, addChildAction.payload);
|
2024-09-18 16:35:28 +00:00
|
|
|
|
2024-04-16 08:41:09 +00:00
|
|
|
yield put(
|
|
|
|
|
updateAndSaveLayout(updatedWidgets, {
|
|
|
|
|
shouldReplay: addChildAction.payload.shouldReplay,
|
|
|
|
|
}),
|
|
|
|
|
);
|
2022-05-25 10:05:53 +00:00
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.RECORD_RECENTLY_ADDED_WIDGET,
|
|
|
|
|
payload: [addChildAction.payload.newWidgetId],
|
|
|
|
|
});
|
2022-11-23 09:48:23 +00:00
|
|
|
yield put(generateAutoHeightLayoutTreeAction(true, true));
|
|
|
|
|
|
2021-09-21 07:55:56 +00:00
|
|
|
log.debug("add child computations took", performance.now() - start, "ms");
|
|
|
|
|
// go up till MAIN_CONTAINER, if there is a operation CHILD_OPERATIONS IN ANY PARENT,
|
|
|
|
|
// call execute
|
|
|
|
|
} catch (error) {
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionErrorTypes.WIDGET_OPERATION_ERROR,
|
|
|
|
|
payload: {
|
|
|
|
|
action: WidgetReduxActionTypes.WIDGET_ADD_CHILD,
|
|
|
|
|
error,
|
2024-09-05 05:36:43 +00:00
|
|
|
logToDebugger: true,
|
2021-09-21 07:55:56 +00:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getChildTabData = (
|
|
|
|
|
tabProps: WidgetProps,
|
|
|
|
|
tab: {
|
|
|
|
|
id: string;
|
|
|
|
|
label: string;
|
|
|
|
|
widgetId: string;
|
|
|
|
|
},
|
|
|
|
|
) => {
|
|
|
|
|
const columns =
|
|
|
|
|
(tabProps.rightColumn - tabProps.leftColumn) * tabProps.parentColumnSpace;
|
|
|
|
|
// GRID_DENSITY_MIGRATION_V1 used to adjust code as per new scaled canvas.
|
|
|
|
|
const rows =
|
|
|
|
|
(tabProps.bottomRow - tabProps.topRow - GRID_DENSITY_MIGRATION_V1) *
|
|
|
|
|
tabProps.parentRowSpace;
|
2024-09-18 16:35:28 +00:00
|
|
|
|
2021-09-21 07:55:56 +00:00
|
|
|
return {
|
|
|
|
|
type: WidgetTypes.CANVAS_WIDGET,
|
|
|
|
|
columns: columns,
|
|
|
|
|
rows: rows,
|
|
|
|
|
topRow: 1,
|
|
|
|
|
newWidgetId: tab.widgetId,
|
|
|
|
|
widgetId: tabProps.widgetId,
|
|
|
|
|
leftColumn: 0,
|
|
|
|
|
rightColumn:
|
|
|
|
|
(tabProps.rightColumn - tabProps.leftColumn) * tabProps.parentColumnSpace,
|
|
|
|
|
bottomRow: (tabProps.bottomRow - tabProps.topRow) * tabProps.parentRowSpace,
|
|
|
|
|
props: {
|
|
|
|
|
tabId: tab.id,
|
|
|
|
|
tabName: tab.label,
|
|
|
|
|
containerStyle: "none",
|
|
|
|
|
canExtend: false,
|
|
|
|
|
detachFromLayout: true,
|
|
|
|
|
children: [],
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function* addNewTabChildSaga(
|
|
|
|
|
addChildTabAction: ReduxAction<WidgetAddTabChild>,
|
|
|
|
|
) {
|
|
|
|
|
const { widgetId } = addChildTabAction.payload;
|
|
|
|
|
const tabProps: WidgetProps = yield select(getWidget, widgetId);
|
|
|
|
|
let tabs = tabProps.tabsObj;
|
|
|
|
|
const tabsArray = Object.values(tabs);
|
|
|
|
|
const newTabWidgetId = generateReactKey();
|
|
|
|
|
const newTabId = generateReactKey({ prefix: "tab" });
|
|
|
|
|
const newTabLabel = getNextEntityName(
|
|
|
|
|
"Tab ",
|
2024-07-31 15:41:28 +00:00
|
|
|
// TODO: Fix this the next time the file is edited
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2021-09-21 07:55:56 +00:00
|
|
|
tabsArray.map((tab: any) => tab.label),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
tabs = {
|
|
|
|
|
...tabs,
|
|
|
|
|
[newTabId]: {
|
|
|
|
|
id: newTabId,
|
2022-03-17 10:58:26 +00:00
|
|
|
index: tabsArray.length,
|
2021-09-21 07:55:56 +00:00
|
|
|
label: newTabLabel,
|
|
|
|
|
widgetId: newTabWidgetId,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
},
|
|
|
|
|
};
|
2024-07-31 15:41:28 +00:00
|
|
|
// TODO: Fix this the next time the file is edited
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2021-09-21 07:55:56 +00:00
|
|
|
const newTabProps: any = getChildTabData(tabProps, {
|
|
|
|
|
id: newTabId,
|
|
|
|
|
label: newTabLabel,
|
|
|
|
|
widgetId: newTabWidgetId,
|
|
|
|
|
});
|
2023-05-11 04:45:14 +00:00
|
|
|
const isAutoLayout: boolean = yield select(getIsAutoLayout);
|
2021-09-21 07:55:56 +00:00
|
|
|
const updatedWidgets: CanvasWidgetsReduxState = yield call(
|
|
|
|
|
getUpdateDslAfterCreatingChild,
|
2023-05-11 04:45:14 +00:00
|
|
|
isAutoLayout ? { ...newTabProps, topRow: 0 } : newTabProps,
|
2021-09-21 07:55:56 +00:00
|
|
|
);
|
2024-09-18 16:35:28 +00:00
|
|
|
|
2021-09-21 07:55:56 +00:00
|
|
|
updatedWidgets[widgetId]["tabsObj"] = tabs;
|
|
|
|
|
yield put(updateAndSaveLayout(updatedWidgets));
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-16 08:41:09 +00:00
|
|
|
function* addUIEntitySaga(addEntityAction: ReduxAction<WidgetAddChild>) {
|
|
|
|
|
try {
|
|
|
|
|
const { payload } = addEntityAction;
|
|
|
|
|
const { type } = payload;
|
|
|
|
|
|
|
|
|
|
if (type === BUILDING_BLOCK_EXPLORER_TYPE) {
|
2024-04-29 10:13:39 +00:00
|
|
|
yield call(addBuildingBlockToCanvasSaga, addEntityAction);
|
2024-03-08 14:29:29 +00:00
|
|
|
} else {
|
|
|
|
|
yield call(addChildSaga, addEntityAction);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionErrorTypes.WIDGET_OPERATION_ERROR,
|
|
|
|
|
payload: {
|
|
|
|
|
action: WidgetReduxActionTypes.WIDGET_ADD_CHILD,
|
|
|
|
|
error,
|
2024-09-05 05:36:43 +00:00
|
|
|
logToDebugger: true,
|
2024-03-08 14:29:29 +00:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-21 07:55:56 +00:00
|
|
|
export default function* widgetAdditionSagas() {
|
|
|
|
|
yield all([
|
2024-03-08 14:29:29 +00:00
|
|
|
takeEvery(WidgetReduxActionTypes.WIDGET_ADD_CHILD, addUIEntitySaga),
|
2021-09-21 07:55:56 +00:00
|
|
|
takeEvery(ReduxActionTypes.WIDGET_ADD_NEW_TAB_CHILD, addNewTabChildSaga),
|
|
|
|
|
]);
|
|
|
|
|
}
|