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
This commit is contained in:
rahulramesha 2023-05-14 22:40:20 +05:30 committed by GitHub
parent d4236847dc
commit e56e353400
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 21 deletions

View File

@ -4,6 +4,7 @@ import {
} from "actions/autoLayoutActions";
import type { ApiResponse } from "api/ApiResponses";
import ApplicationApi from "@appsmith/api/ApplicationApi";
import type { PageDefaultMeta } from "@appsmith/api/ApplicationApi";
import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
import log from "loglevel";
import type { SnapShotDetails } from "reducers/uiReducers/layoutConversionReducer";
@ -95,6 +96,20 @@ function* restoreApplicationFromSnapshotSaga() {
getLogToSentryFromResponse(response),
);
// update the pages list temporarily with incomplete data.
if (response?.data?.pages) {
yield put({
type: ReduxActionTypes.FETCH_PAGE_LIST_SUCCESS,
payload: {
pages: response.data.pages.map((page: PageDefaultMeta) => ({
pageId: page.id,
isDefault: page.isDefault,
})),
applicationId,
},
});
}
//update layout positioning type from
yield call(
updateApplicationLayoutType,
@ -103,14 +118,6 @@ function* restoreApplicationFromSnapshotSaga() {
: AppPositioningTypes.FIXED,
);
if (response?.data?.applicationDetail?.appPositioning?.type) {
//update layout positioning type from response
yield call(
updateApplicationLayoutType,
response.data.applicationDetail.appPositioning.type,
);
}
if (isValidResponse) {
//update conversion form state to success
yield put(

View File

@ -202,8 +202,8 @@ function processMobileCanvasChildren(
...currWidget,
topRow: getTopRow(currWidget, true),
bottomRow: getBottomRow(currWidget, true),
leftColumn: getLeftColumn(currWidget, true),
rightColumn: getRightColumn(currWidget, true),
leftColumn: Math.floor(getLeftColumn(currWidget, true)),
rightColumn: Math.floor(getRightColumn(currWidget, true)),
};
currWidgets = convertAutoWidgetToFixed(currWidgets, childId, true);
@ -261,8 +261,8 @@ function processCanvasChildren(
...currWidget,
topRow: getTopRow(currWidget, false),
bottomRow: getBottomRow(currWidget, false),
leftColumn,
rightColumn,
leftColumn: Math.floor(leftColumn),
rightColumn: Math.floor(rightColumn),
};
currWidgets = convertAutoWidgetToFixed(currWidgets, childId, false);

View File

@ -564,7 +564,7 @@ describe("test Auto to Fixed Conversion methods", () => {
leftColumn: 0,
minWidth: 120,
parentId: "vv54unn046",
rightColumn: 17.375565610859727,
rightColumn: 17,
topRow: 0,
type: "BUTTON_WIDGET",
widgetId: "5c6gd8ynfa",
@ -696,7 +696,7 @@ describe("test Auto to Fixed Conversion methods", () => {
minWidth: 120,
parentId: "0",
parentRowSpace: 10,
rightColumn: 17.375565610859727,
rightColumn: 17,
topRow: 18.599999999999998,
type: "BUTTON_WIDGET",
widgetId: "n123229jea",
@ -718,7 +718,7 @@ describe("test Auto to Fixed Conversion methods", () => {
leftColumn: 0,
minWidth: 120,
parentId: "0",
rightColumn: 17.375565610859727,
rightColumn: 17,
topRow: 13.399999999999999,
type: "BUTTON_WIDGET",
widgetId: "p6em4n29z7",
@ -741,7 +741,7 @@ describe("test Auto to Fixed Conversion methods", () => {
leftColumn: 0,
minWidth: 120,
parentId: "mw6t1nvt67",
rightColumn: 17.375565610859727,
rightColumn: 17,
topRow: 5.2,
type: "BUTTON_WIDGET",
widgetId: "u0cd188upj",
@ -768,7 +768,7 @@ describe("test Auto to Fixed Conversion methods", () => {
},
wixla6nh38: {
bottomRow: 7,
leftColumn: 17.375565610859727,
leftColumn: 17,
minWidth: 450,
parentId: "vv54unn046",
rightColumn: 64,
@ -880,7 +880,7 @@ describe("test Auto to Fixed Conversion methods", () => {
leftColumn: 0,
minWidth: 120,
parentId: "vv54unn046",
rightColumn: 17.375565610859727,
rightColumn: 17,
topRow: 0,
type: "BUTTON_WIDGET",
widgetId: "5c6gd8ynfa",
@ -1012,7 +1012,7 @@ describe("test Auto to Fixed Conversion methods", () => {
minWidth: 120,
parentId: "0",
parentRowSpace: 10,
rightColumn: 17.375565610859727,
rightColumn: 17,
topRow: 27.000000000000004,
type: "BUTTON_WIDGET",
widgetId: "n123229jea",
@ -1034,7 +1034,7 @@ describe("test Auto to Fixed Conversion methods", () => {
leftColumn: 0,
minWidth: 120,
parentId: "0",
rightColumn: 17.375565610859727,
rightColumn: 17,
topRow: 22.200000000000003,
type: "BUTTON_WIDGET",
widgetId: "p6em4n29z7",
@ -1057,7 +1057,7 @@ describe("test Auto to Fixed Conversion methods", () => {
leftColumn: 0,
minWidth: 120,
parentId: "mw6t1nvt67",
rightColumn: 17.375565610859727,
rightColumn: 17,
topRow: 4.8,
type: "BUTTON_WIDGET",
widgetId: "u0cd188upj",