PromucFlow_constructor/app/client/src/utils/DSLConversions/autoToFixedLayout.ts

290 lines
7.5 KiB
TypeScript
Raw Normal View History

feat: Shared Package for DSL based operations (#23894) ## Description Splitting DSL into different files when saving into git #### PR fixes following issue(s) Fixes #23763 #### Media #### Type of change - New feature (non-breaking change which adds functionality) ## Testing Manual 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. > Delete anything that is not relevant - [ ] Manual - [ ] Jest - [ ] Cypress > > #### 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 - [ ] 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](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#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 --------- Co-authored-by: Hetu Nandu <hetunandu@gmail.com>
2023-06-26 06:55:55 +00:00
import { nestDSL, flattenDSL } from "@shared/dsl";
import {
GridDefaults,
layoutConfigurations,
MAIN_CONTAINER_WIDGET_ID,
} from "constants/WidgetConstants";
import type { CanvasWidgetsReduxState } from "reducers/entityReducers/canvasWidgetsReducer";
import type { SupportedLayouts } from "reducers/entityReducers/pageListReducer";
import { HORIZONTAL_RESIZE_MIN_LIMIT } from "reflow/reflowTypes";
import {
alterLayoutForDesktop,
alterLayoutForMobile,
chore: BaseWidget Restructuring (#26562) ## Description Create a Basewidget wrapper that supplies Widget Onion as per the layout system. involves extracting widget layers presently in the BaseWidget into HOCs and hooks and make sure layout systems can be scaled. Make sure Modal widget is handled as a overlay widget whose wrappers are supplied by basewidget instead of modal widget implementing its own editing blocks. This PR also separates the drag n drop logic for both auto layout and fixed layout. They are moved into respective Layout system folders to have clear sepsration of concern #### PR fixes following issue(s) Fixes #26674 Fixes #26675 Fixes #26676 Fixes #26570 Fixes #26590 Fixes #26591 Fixes #26592 <img width="931" alt="BaseWidgetHOC" src="https://github.com/appsmithorg/appsmith/assets/35134347/22f4cf1e-e4c5-4475-83a8-6818e7cebe70"> [Miro Link to view the new system](https://miro.com/app/board/uXjVM6vRgf8=/?moveToWidget=3458764560239189204&cot=14) > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) > > > ## 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. > Delete anything that is not relevant - [x] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### 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 - [ ] 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](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#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 --------- Co-authored-by: rahulramesha <rahul@appsmith.com> Co-authored-by: rahulramesha <71900764+rahulramesha@users.noreply.github.com> Co-authored-by: Preet Sidhu <preetsidhu.bits@gmail.com> Co-authored-by: Aswath K <aswath.sana@gmail.com>
2023-09-11 15:55:11 +00:00
} from "layoutSystems/autolayout/utils/AutoLayoutUtils";
chore: Create layout system structure for Anvil and AnvilFlexComponent. (#27178) ## Description 1. Add new ```appPositioningType``` : ANVIL. 2. Create new code path and folder structure for Anvil layout system. 3. Move common pieces of functionalities between autoLayout and anvil to anvil folder structure (e.g. ```CanvasResizer```). 4. Create ```AnvilFlexComponent```. 5. Use WDS Flex component in AnvilFlexComponent. 6. Pass min max size props in a data structure that is supported by container queries in the Flex component. e.g. min-width: { base: "120px", "480px": "200px" } 7. Supply the following flex properties (flex-grow flex-shrink flex-basis) to widgets depending on their ```responsiveBehvaiour```: a) Fill: ```flex: 1 1 0%;``` b) Hug: ```flex: 0 0 auto;``` #### PR fixes following issue(s) Fixes # (issue number) 1. [#26987](https://github.com/appsmithorg/appsmith/issues/26987) 2. [#26609](https://github.com/appsmithorg/appsmith/issues/26609) 3. [#26611](https://github.com/appsmithorg/appsmith/issues/26611) #### Type of change - New feature (non-breaking change which adds functionality) ## 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. > Delete anything that is not relevant - [x] Manual - [ ] JUnit - [x] Jest - [ ] 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 - [x] 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 - [x] 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 - [x] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#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 --------- Co-authored-by: Ashok Kumar M <35134347+marks0351@users.noreply.github.com> Co-authored-by: Aswath K <aswath.sana@gmail.com> Co-authored-by: rahulramesha <rahul@appsmith.com> Co-authored-by: rahulramesha <71900764+rahulramesha@users.noreply.github.com>
2023-10-02 19:41:05 +00:00
import { Positioning } from "layoutSystems/common/utils/constants";
import {
getTopRow,
getBottomRow,
getLeftColumn,
getRightColumn,
chore: BaseWidget Restructuring (#26562) ## Description Create a Basewidget wrapper that supplies Widget Onion as per the layout system. involves extracting widget layers presently in the BaseWidget into HOCs and hooks and make sure layout systems can be scaled. Make sure Modal widget is handled as a overlay widget whose wrappers are supplied by basewidget instead of modal widget implementing its own editing blocks. This PR also separates the drag n drop logic for both auto layout and fixed layout. They are moved into respective Layout system folders to have clear sepsration of concern #### PR fixes following issue(s) Fixes #26674 Fixes #26675 Fixes #26676 Fixes #26570 Fixes #26590 Fixes #26591 Fixes #26592 <img width="931" alt="BaseWidgetHOC" src="https://github.com/appsmithorg/appsmith/assets/35134347/22f4cf1e-e4c5-4475-83a8-6818e7cebe70"> [Miro Link to view the new system](https://miro.com/app/board/uXjVM6vRgf8=/?moveToWidget=3458764560239189204&cot=14) > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) > > > ## 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. > Delete anything that is not relevant - [x] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### 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 - [ ] 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](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#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 --------- Co-authored-by: rahulramesha <rahul@appsmith.com> Co-authored-by: rahulramesha <71900764+rahulramesha@users.noreply.github.com> Co-authored-by: Preet Sidhu <preetsidhu.bits@gmail.com> Co-authored-by: Aswath K <aswath.sana@gmail.com>
2023-09-11 15:55:11 +00:00
} from "layoutSystems/autolayout/utils/flexWidgetUtils";
chore: Move the widget config to widget class (#26073) ## Description - Remove the config objects from widget and config maps from the widget factory. - Introduce methods in widget development API to dynamically fetch this items. - freeze the widget configuration. #### PR fixes following issue(s) Fixes https://github.com/appsmithorg/appsmith/issues/26008 > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## 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. > Delete anything that is not relevant - [x] Manual - [ ] Jest - [ ] Cypress > > #### 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 - [ ] 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](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [x] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [x] 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
2023-09-06 12:15:04 +00:00
import type { DSLWidget } from "WidgetProvider/constants";
const deletedResponsiveProperties = [
"mobileLeftColumn",
"mobileRightColumn",
"mobileTopRow",
"mobileBottomRow",
"responsiveBehavior",
"alignment",
"flexVerticalAlignment",
"widthInPercentage",
];
/**
* Main Method to convert Auto DSL to Fixed DSL
fix: casing changes (#23515) Fixes: https://github.com/appsmithorg/appsmith/issues/24202 #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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. > Delete anything that is not relevant - [ ] Manual - [ ] Jest - [ ] Cypress > > #### 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 - [ ] 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](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#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
2023-06-09 08:52:27 +00:00
* @param dsl DSL to be Converted to fixed layout
* @param destinationLayout Destination Layout Size
* @returns Converted Fixed DSL
*/
export default function convertDSLtoFixed(
dsl: DSLWidget,
destinationLayout: SupportedLayouts,
) {
feat: Shared Package for DSL based operations (#23894) ## Description Splitting DSL into different files when saving into git #### PR fixes following issue(s) Fixes #23763 #### Media #### Type of change - New feature (non-breaking change which adds functionality) ## Testing Manual 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. > Delete anything that is not relevant - [ ] Manual - [ ] Jest - [ ] Cypress > > #### 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 - [ ] 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](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#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 --------- Co-authored-by: Hetu Nandu <hetunandu@gmail.com>
2023-06-26 06:55:55 +00:00
const allWidgets = flattenDSL(dsl);
const convertedWidgets = convertNormalizedDSLToFixed(
allWidgets,
destinationLayout,
);
feat: Shared Package for DSL based operations (#23894) ## Description Splitting DSL into different files when saving into git #### PR fixes following issue(s) Fixes #23763 #### Media #### Type of change - New feature (non-breaking change which adds functionality) ## Testing Manual 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. > Delete anything that is not relevant - [ ] Manual - [ ] Jest - [ ] Cypress > > #### 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 - [ ] 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](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#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 --------- Co-authored-by: Hetu Nandu <hetunandu@gmail.com>
2023-06-26 06:55:55 +00:00
const convertedDSL = nestDSL(convertedWidgets);
return convertedDSL;
}
/**
fix: casing changes (#23515) Fixes: https://github.com/appsmithorg/appsmith/issues/24202 #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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. > Delete anything that is not relevant - [ ] Manual - [ ] Jest - [ ] Cypress > > #### 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 - [ ] 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](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#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
2023-06-09 08:52:27 +00:00
* Convert Normalized Auto DSL to fixed layout DSL
* @param widgets Normalized Auto DSL to be converted
* @param destinationLayout Destination Layout Size
fix: casing changes (#23515) Fixes: https://github.com/appsmithorg/appsmith/issues/24202 #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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. > Delete anything that is not relevant - [ ] Manual - [ ] Jest - [ ] Cypress > > #### 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 - [ ] 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](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#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
2023-06-09 08:52:27 +00:00
* @returns Converted Normalized fixed layout DSL
*/
export function convertNormalizedDSLToFixed(
widgets: CanvasWidgetsReduxState,
destinationLayout: SupportedLayouts,
) {
const isMobile = getIsMobile(destinationLayout);
const mobileWidth =
layoutConfigurations[destinationLayout].maxWidth ||
layoutConfigurations.MOBILE.maxWidth;
const deskTopWidth =
layoutConfigurations[destinationLayout].maxWidth ||
layoutConfigurations.DESKTOP.maxWidth;
const alteredWidgets = isMobile
? alterLayoutForMobile(
widgets,
MAIN_CONTAINER_WIDGET_ID,
mobileWidth,
mobileWidth,
)
: alterLayoutForDesktop(widgets, MAIN_CONTAINER_WIDGET_ID, deskTopWidth);
const convertedWidgets = getFixedCanvasWidget(
alteredWidgets,
MAIN_CONTAINER_WIDGET_ID,
isMobile,
);
return convertedWidgets;
}
/**
fix: casing changes (#23515) Fixes: https://github.com/appsmithorg/appsmith/issues/24202 #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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. > Delete anything that is not relevant - [ ] Manual - [ ] Jest - [ ] Cypress > > #### 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 - [ ] 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](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#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
2023-06-09 08:52:27 +00:00
* Converts Widget with widgetId and it's children to fixed layout recursively
* @param widgets Normalized Auto DSL
* @param widgetId
* @param isMobile
* @returns
*/
function convertAutoWidgetToFixed(
widgets: CanvasWidgetsReduxState,
widgetId: string,
isMobile: boolean,
): CanvasWidgetsReduxState {
const currWidget = { ...widgets[widgetId] };
if (!currWidget) return widgets;
let currWidgets = { ...widgets };
if (currWidget.type === "CANVAS_WIDGET") {
return getFixedCanvasWidget(currWidgets, widgetId, isMobile);
} else {
if (currWidget.children && currWidget.children.length > 0) {
for (const childId of currWidget.children) {
currWidgets = convertAutoWidgetToFixed(currWidgets, childId, isMobile);
}
}
// Delete responsive properties of widgets
for (const responsiveProperty of deletedResponsiveProperties) {
delete currWidget[responsiveProperty];
}
currWidgets[widgetId] = { ...currWidget };
}
return currWidgets;
}
/**
* Convert the Canvas Widget of canvasId to Fixed
* @param widgets
* @param canvasId
* @param isMobile
* @returns
*/
function getFixedCanvasWidget(
widgets: CanvasWidgetsReduxState,
canvasId: string,
isMobile: boolean,
): CanvasWidgetsReduxState {
const canvasWidget = { ...widgets[canvasId] };
if (
!canvasWidget ||
!canvasWidget.children ||
canvasWidget.positioning !== Positioning.Vertical ||
!canvasWidget.flexLayers
) {
if (
canvasWidget &&
canvasWidget.children &&
canvasWidget.children.length > 0
) {
//even if it is not autoLayout, remove all the unwanted props from it's children
for (const childId of canvasWidget.children) {
const currWidget = { ...widgets[childId] };
if (!currWidget) continue;
for (const responsiveProperty of deletedResponsiveProperties) {
delete currWidget[responsiveProperty];
}
widgets[childId] = { ...currWidget };
}
}
return widgets;
}
//if Mobile, use the existing already calculated positions in `alterLayoutForMobile`
if (isMobile) {
return processMobileCanvasChildren(widgets, canvasId);
} else {
return processCanvasChildren(widgets, canvasId);
}
}
/**
* Process the mobile canvas Widgets with already existing positions/dimensions
* @param widgets
* @param canvasId
* @returns
*/
function processMobileCanvasChildren(
widgets: CanvasWidgetsReduxState,
canvasId: string,
) {
const canvasWidget = { ...widgets[canvasId] };
let currWidgets = { ...widgets };
for (const childId of canvasWidget.children || []) {
const currWidget = currWidgets[childId];
currWidgets[childId] = {
...currWidget,
topRow: getTopRow(currWidget, true),
bottomRow: getBottomRow(currWidget, true),
fix: widget columns to have integers after conversion to fixed layout and redirect to home page while restoring if the page does not exist in the restored snapshot (#23144) ## Description This PR makes a change to make sure the widget's horizontal columns are integers, Also adding code to use the page list returned by the application while restoring snapshot #### PR fixes following issue(s) Fixes #23133 Fixes #23192 #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change - Bug fix (non-breaking change which fixes an issue)> ## Testing #### How Has This Been Tested? - [ ] Manual - [ ] Jest #### 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 - [ ] 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](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#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
2023-05-14 17:10:20 +00:00
leftColumn: Math.floor(getLeftColumn(currWidget, true)),
rightColumn: Math.floor(getRightColumn(currWidget, true)),
};
currWidgets = convertAutoWidgetToFixed(currWidgets, childId, true);
}
// Delete Canvas widget responsive properties
delete canvasWidget.flexLayers;
delete canvasWidget.responsiveBehavior;
currWidgets[canvasId] = {
...canvasWidget,
useAutoLayout: false,
positioning: Positioning.Fixed,
};
return currWidgets;
}
/**
* Process the mobile canvas Widgets with already existing positions/dimensions
* @param widgets
* @param canvasId
* @returns
*/
function processCanvasChildren(
widgets: CanvasWidgetsReduxState,
canvasId: string,
) {
const canvasWidget = { ...widgets[canvasId] };
let currWidgets = { ...widgets };
const widgetsToDelete: string[] = [];
for (const childId of canvasWidget.children || []) {
const currWidget = currWidgets[childId];
const leftColumn = getLeftColumn(currWidget, false);
let rightColumn = getRightColumn(currWidget, false);
if (
leftColumn >
GridDefaults.DEFAULT_GRID_COLUMNS - HORIZONTAL_RESIZE_MIN_LIMIT
) {
delete currWidgets[childId];
widgetsToDelete.push(childId);
continue;
}
if (rightColumn > GridDefaults.DEFAULT_GRID_COLUMNS) {
rightColumn = GridDefaults.DEFAULT_GRID_COLUMNS;
}
currWidgets[childId] = {
...currWidget,
topRow: getTopRow(currWidget, false),
bottomRow: getBottomRow(currWidget, false),
fix: widget columns to have integers after conversion to fixed layout and redirect to home page while restoring if the page does not exist in the restored snapshot (#23144) ## Description This PR makes a change to make sure the widget's horizontal columns are integers, Also adding code to use the page list returned by the application while restoring snapshot #### PR fixes following issue(s) Fixes #23133 Fixes #23192 #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change - Bug fix (non-breaking change which fixes an issue)> ## Testing #### How Has This Been Tested? - [ ] Manual - [ ] Jest #### 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 - [ ] 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](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#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
2023-05-14 17:10:20 +00:00
leftColumn: Math.floor(leftColumn),
rightColumn: Math.floor(rightColumn),
};
currWidgets = convertAutoWidgetToFixed(currWidgets, childId, false);
}
canvasWidget.children = canvasWidget.children?.filter(
(childId) => !widgetsToDelete.includes(childId),
);
// Delete Canvas widget responsive properties
delete canvasWidget.flexLayers;
delete canvasWidget.responsiveBehavior;
currWidgets[canvasId] = {
...canvasWidget,
useAutoLayout: false,
positioning: Positioning.Fixed,
};
return currWidgets;
}
/**
* returns if the destinationLayout isMobile ("Logic can be updated later based on updated logic")
* @param destinationLayout
* @returns
*/
function getIsMobile(destinationLayout: SupportedLayouts) {
return destinationLayout === "MOBILE";
}