fix: layout conversion for git apps by getting actual page list from current list and dynamic binding path fix (#22968)

## Description
This PR provides a fix by checking the page list from current branch
before converting the pages in git connected apps.
This PR also changes dynamic binding paths verification logic to use
lodash's get instead of directly accessing key to cater for nested paths

Fixes #22698 


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)

## How Has This Been Tested?
- Manual

### 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:
- [ ] 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
This commit is contained in:
rahulramesha 2023-05-08 15:26:41 +05:30 committed by GitHub
parent a4dec4bb6e
commit 6d1fd096d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 12 deletions

View File

@ -1,5 +1,6 @@
import { setLayoutConversionStateAction } from "actions/autoLayoutActions";
import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
import type { Page } from "@appsmith/constants/ReduxActionConstants";
import type { ReduxAction } from "@appsmith/constants/ReduxActionConstants";
import type { AppState } from "@appsmith/reducers";
import { MAIN_CONTAINER_WIDGET_ID } from "constants/WidgetConstants";
@ -21,7 +22,10 @@ import * as Sentry from "@sentry/react";
import log from "loglevel";
import { saveAllPagesSaga } from "./PageSagas";
import { updateApplicationLayout } from "@appsmith/actions/applicationActions";
import { getCurrentApplicationId } from "selectors/editorSelectors";
import {
getCurrentApplicationId,
getPageList,
} from "selectors/editorSelectors";
import { updateApplicationLayoutType } from "./AutoLayoutUpdateSagas";
import AnalyticsUtil from "utils/AnalyticsUtil";
@ -33,9 +37,11 @@ function* convertFromAutoToFixedSaga(action: ReduxAction<SupportedLayouts>) {
let appId = "";
let snapshotSaveSuccess = false;
try {
appId = yield select(getCurrentApplicationId);
const pageList: Page[] = yield select(getPageList);
const pageWidgetsList: PageWidgetsReduxState = yield select(getPageWidgets);
appId = yield select(getCurrentApplicationId);
const notEmptyApp = isNotEmptyApp(pageWidgetsList);
if (notEmptyApp) {
@ -55,8 +61,9 @@ function* convertFromAutoToFixedSaga(action: ReduxAction<SupportedLayouts>) {
const pageLayouts = [];
//Convert all the pages into Fixed layout by iterating over the list
for (const [pageId, page] of Object.entries(pageWidgetsList)) {
const { dsl: normalizedDSL, layoutId } = page;
for (const page of pageList) {
const pageId = page?.pageId;
const { dsl: normalizedDSL, layoutId } = pageWidgetsList[pageId];
const fixedLayoutDSL = convertNormalizedDSLToFixed(
normalizedDSL,
@ -120,9 +127,11 @@ function* convertFromFixedToAutoSaga() {
let appId = "";
let snapshotSaveSuccess = false;
try {
appId = yield select(getCurrentApplicationId);
const pageList: Page[] = yield select(getPageList);
const pageWidgetsList: PageWidgetsReduxState = yield select(getPageWidgets);
appId = yield select(getCurrentApplicationId);
const notEmptyApp = isNotEmptyApp(pageWidgetsList);
if (notEmptyApp) {
@ -141,8 +150,9 @@ function* convertFromFixedToAutoSaga() {
const pageLayouts = [];
for (const [pageId, page] of Object.entries(pageWidgetsList)) {
const { dsl: normalizedDSL, layoutId } = page;
for (const page of pageList) {
const pageId = page?.pageId;
const { dsl: normalizedDSL, layoutId } = pageWidgetsList[pageId];
const fixedDSL: DSLWidget = CanvasWidgetsNormalizer.denormalize(
MAIN_CONTAINER_WIDGET_ID,

View File

@ -3,7 +3,7 @@ import {
layoutConfigurations,
MAIN_CONTAINER_WIDGET_ID,
} from "constants/WidgetConstants";
import { partition } from "lodash";
import { get, partition } from "lodash";
import CanvasWidgetsNormalizer from "normalizers/CanvasWidgetsNormalizer";
import type { FlexLayer } from "utils/autoLayout/autoLayoutTypes";
import { alterLayoutForDesktop } from "utils/autoLayout/AutoLayoutUtils";
@ -822,10 +822,8 @@ function verifyDynamicPathBindingList(
const dynamicBindingPathList: DynamicPath[] = [];
for (const dynamicBindingPath of widget.dynamicBindingPathList) {
//if the values are not dynamic, remove from the dynamic binding path list
if (
!widget[dynamicBindingPath.key] ||
!isDynamicValue(widget[dynamicBindingPath.key])
) {
const dynamicValue = get(widget, dynamicBindingPath.key);
if (!dynamicValue || !isDynamicValue(dynamicValue)) {
continue;
}