PromucFlow_constructor/app/client/src/sagas/layoutConversionSagas.ts

256 lines
7.5 KiB
TypeScript
Raw Normal View History

import { setLayoutConversionStateAction } from "actions/autoLayoutActions";
import { ReduxActionTypes } 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";
import CanvasWidgetsNormalizer from "normalizers/CanvasWidgetsNormalizer";
import { AppPositioningTypes } from "reducers/entityReducers/pageListReducer";
import type { SupportedLayouts } from "reducers/entityReducers/pageListReducer";
import { CONVERSION_STATES } from "reducers/uiReducers/layoutConversionReducer";
import type { PageWidgetsReduxState } from "reducers/uiReducers/pageWidgetsReducer";
import { all, call, put, select, takeLatest } from "redux-saga/effects";
import { getPageWidgets } from "selectors/entitiesSelector";
import { convertNormalizedDSLToFixed } from "utils/DSLConversions/autoToFixedLayout";
import convertToAutoLayout from "utils/DSLConversions/fixedToAutoLayout";
import type { DSLWidget } from "widgets/constants";
fix: Layout Conversion bugs for auto Layout (#22565) ## Description The Changes in this PR includes, - separated the logic for getting Readable snapshot details and are derived on component render rather than on change of state to have upto date value on the conversion modal - Separated the DayJs Utils for the same. - Upon restoring Snapshot, change the layout type based on the response from API rather than the opposite of current layout type - Updated the width of modal widget for calculating the positions of children in PositionUtils - Updated Conversion algorithm to remove the dynamic binding path from list for property paths with default autolayout values Fixes #21967 Fixes #21969 Fixes #22244 Fixes #22094 Fixes #22187 Fixes #22697 # Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? Manual - 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 - [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 - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] 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: Preet <preetsidhu.bits@gmail.com>
2023-05-03 04:26:52 +00:00
import {
createSnapshotSaga,
deleteApplicationSnapshotSaga,
} from "./SnapshotSagas";
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 { updateApplicationLayoutType } from "./AutoLayoutUpdateSagas";
chore: Minor Tasks for Auto Layout feature, Sentry errors, metrics and Beta tag (#22792) ## Description This PR includes changes for, - Adding common error messages for sentry issues when user decides to send error message, to enable searching of the reported issues on sentry - Adding Analytics for conversion modal flow, to track user adoption of the feature - Add Beta tag to the conversion button Fixes #19712 Media <img width="301" alt="image" src="https://user-images.githubusercontent.com/71900764/234912585-1c5d60d7-89ed-4a61-82b5-163613584e25.png"> ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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
2023-05-07 05:10:03 +00:00
import AnalyticsUtil from "utils/AnalyticsUtil";
/**
* This method is used to convert from Auto layout to Fixed layout
* @param action
*/
function* convertFromAutoToFixedSaga(action: ReduxAction<SupportedLayouts>) {
chore: Minor Tasks for Auto Layout feature, Sentry errors, metrics and Beta tag (#22792) ## Description This PR includes changes for, - Adding common error messages for sentry issues when user decides to send error message, to enable searching of the reported issues on sentry - Adding Analytics for conversion modal flow, to track user adoption of the feature - Add Beta tag to the conversion button Fixes #19712 Media <img width="301" alt="image" src="https://user-images.githubusercontent.com/71900764/234912585-1c5d60d7-89ed-4a61-82b5-163613584e25.png"> ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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
2023-05-07 05:10:03 +00:00
let appId = "";
fix: Layout Conversion bugs for auto Layout (#22565) ## Description The Changes in this PR includes, - separated the logic for getting Readable snapshot details and are derived on component render rather than on change of state to have upto date value on the conversion modal - Separated the DayJs Utils for the same. - Upon restoring Snapshot, change the layout type based on the response from API rather than the opposite of current layout type - Updated the width of modal widget for calculating the positions of children in PositionUtils - Updated Conversion algorithm to remove the dynamic binding path from list for property paths with default autolayout values Fixes #21967 Fixes #21969 Fixes #22244 Fixes #22094 Fixes #22187 Fixes #22697 # Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? Manual - 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 - [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 - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] 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: Preet <preetsidhu.bits@gmail.com>
2023-05-03 04:26:52 +00:00
let snapshotSaveSuccess = false;
try {
chore: Minor Tasks for Auto Layout feature, Sentry errors, metrics and Beta tag (#22792) ## Description This PR includes changes for, - Adding common error messages for sentry issues when user decides to send error message, to enable searching of the reported issues on sentry - Adding Analytics for conversion modal flow, to track user adoption of the feature - Add Beta tag to the conversion button Fixes #19712 Media <img width="301" alt="image" src="https://user-images.githubusercontent.com/71900764/234912585-1c5d60d7-89ed-4a61-82b5-163613584e25.png"> ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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
2023-05-07 05:10:03 +00:00
appId = yield select(getCurrentApplicationId);
const pageWidgetsList: PageWidgetsReduxState = yield select(getPageWidgets);
chore: Minor Tasks for Auto Layout feature, Sentry errors, metrics and Beta tag (#22792) ## Description This PR includes changes for, - Adding common error messages for sentry issues when user decides to send error message, to enable searching of the reported issues on sentry - Adding Analytics for conversion modal flow, to track user adoption of the feature - Add Beta tag to the conversion button Fixes #19712 Media <img width="301" alt="image" src="https://user-images.githubusercontent.com/71900764/234912585-1c5d60d7-89ed-4a61-82b5-163613584e25.png"> ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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
2023-05-07 05:10:03 +00:00
const notEmptyApp = isNotEmptyApp(pageWidgetsList);
if (notEmptyApp) {
yield call(createSnapshotSaga);
}
chore: Minor Tasks for Auto Layout feature, Sentry errors, metrics and Beta tag (#22792) ## Description This PR includes changes for, - Adding common error messages for sentry issues when user decides to send error message, to enable searching of the reported issues on sentry - Adding Analytics for conversion modal flow, to track user adoption of the feature - Add Beta tag to the conversion button Fixes #19712 Media <img width="301" alt="image" src="https://user-images.githubusercontent.com/71900764/234912585-1c5d60d7-89ed-4a61-82b5-163613584e25.png"> ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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
2023-05-07 05:10:03 +00:00
AnalyticsUtil.logEvent("CONVERT_AUTO_TO_FIXED", {
isNewApp: !notEmptyApp,
});
fix: Layout Conversion bugs for auto Layout (#22565) ## Description The Changes in this PR includes, - separated the logic for getting Readable snapshot details and are derived on component render rather than on change of state to have upto date value on the conversion modal - Separated the DayJs Utils for the same. - Upon restoring Snapshot, change the layout type based on the response from API rather than the opposite of current layout type - Updated the width of modal widget for calculating the positions of children in PositionUtils - Updated Conversion algorithm to remove the dynamic binding path from list for property paths with default autolayout values Fixes #21967 Fixes #21969 Fixes #22244 Fixes #22094 Fixes #22187 Fixes #22697 # Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? Manual - 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 - [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 - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] 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: Preet <preetsidhu.bits@gmail.com>
2023-05-03 04:26:52 +00:00
snapshotSaveSuccess = true;
//Set conversion form to indicated conversion loading state
yield put(
setLayoutConversionStateAction(CONVERSION_STATES.CONVERSION_SPINNER),
);
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;
const fixedLayoutDSL = convertNormalizedDSLToFixed(
normalizedDSL,
action.payload,
);
const dsl: DSLWidget = CanvasWidgetsNormalizer.denormalize(
MAIN_CONTAINER_WIDGET_ID,
{ canvasWidgets: fixedLayoutDSL },
);
pageLayouts.push({
pageId,
layoutId,
layout: {
dsl,
},
});
}
yield call(saveAllPagesSaga, pageLayouts);
//Set type of fixed layout
yield call(setLayoutTypePostConversion, action.payload);
yield call(updateApplicationLayoutType, AppPositioningTypes.FIXED);
//update conversion form state to success
yield put(
setLayoutConversionStateAction(CONVERSION_STATES.COMPLETED_SUCCESS),
);
chore: Minor Tasks for Auto Layout feature, Sentry errors, metrics and Beta tag (#22792) ## Description This PR includes changes for, - Adding common error messages for sentry issues when user decides to send error message, to enable searching of the reported issues on sentry - Adding Analytics for conversion modal flow, to track user adoption of the feature - Add Beta tag to the conversion button Fixes #19712 Media <img width="301" alt="image" src="https://user-images.githubusercontent.com/71900764/234912585-1c5d60d7-89ed-4a61-82b5-163613584e25.png"> ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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
2023-05-07 05:10:03 +00:00
} catch (e: any) {
let error: Error = e;
if (error) {
error.message = `Layout Conversion Error - while Converting from Auto to Fixed Layout: ${error.message}`;
} else {
error = new Error(
"Layout Conversion Error - while Converting from Auto to Fixed Layout",
);
}
log.error(error);
fix: Layout Conversion bugs for auto Layout (#22565) ## Description The Changes in this PR includes, - separated the logic for getting Readable snapshot details and are derived on component render rather than on change of state to have upto date value on the conversion modal - Separated the DayJs Utils for the same. - Upon restoring Snapshot, change the layout type based on the response from API rather than the opposite of current layout type - Updated the width of modal widget for calculating the positions of children in PositionUtils - Updated Conversion algorithm to remove the dynamic binding path from list for property paths with default autolayout values Fixes #21967 Fixes #21969 Fixes #22244 Fixes #22094 Fixes #22187 Fixes #22697 # Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? Manual - 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 - [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 - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] 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: Preet <preetsidhu.bits@gmail.com>
2023-05-03 04:26:52 +00:00
if (snapshotSaveSuccess) {
yield call(deleteApplicationSnapshotSaga);
}
//update conversion form state to error
yield put(
chore: Minor Tasks for Auto Layout feature, Sentry errors, metrics and Beta tag (#22792) ## Description This PR includes changes for, - Adding common error messages for sentry issues when user decides to send error message, to enable searching of the reported issues on sentry - Adding Analytics for conversion modal flow, to track user adoption of the feature - Add Beta tag to the conversion button Fixes #19712 Media <img width="301" alt="image" src="https://user-images.githubusercontent.com/71900764/234912585-1c5d60d7-89ed-4a61-82b5-163613584e25.png"> ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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
2023-05-07 05:10:03 +00:00
setLayoutConversionStateAction(CONVERSION_STATES.COMPLETED_ERROR, error),
);
chore: Minor Tasks for Auto Layout feature, Sentry errors, metrics and Beta tag (#22792) ## Description This PR includes changes for, - Adding common error messages for sentry issues when user decides to send error message, to enable searching of the reported issues on sentry - Adding Analytics for conversion modal flow, to track user adoption of the feature - Add Beta tag to the conversion button Fixes #19712 Media <img width="301" alt="image" src="https://user-images.githubusercontent.com/71900764/234912585-1c5d60d7-89ed-4a61-82b5-163613584e25.png"> ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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
2023-05-07 05:10:03 +00:00
AnalyticsUtil.logEvent("CONVERSION_FAILURE", {
flow: "CONVERT_AUTO_TO_FIXED",
appId,
});
}
}
/**
* This method is used to convert from Fixed layout to Auto layout
* @param action
*/
function* convertFromFixedToAutoSaga() {
chore: Minor Tasks for Auto Layout feature, Sentry errors, metrics and Beta tag (#22792) ## Description This PR includes changes for, - Adding common error messages for sentry issues when user decides to send error message, to enable searching of the reported issues on sentry - Adding Analytics for conversion modal flow, to track user adoption of the feature - Add Beta tag to the conversion button Fixes #19712 Media <img width="301" alt="image" src="https://user-images.githubusercontent.com/71900764/234912585-1c5d60d7-89ed-4a61-82b5-163613584e25.png"> ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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
2023-05-07 05:10:03 +00:00
let appId = "";
fix: Layout Conversion bugs for auto Layout (#22565) ## Description The Changes in this PR includes, - separated the logic for getting Readable snapshot details and are derived on component render rather than on change of state to have upto date value on the conversion modal - Separated the DayJs Utils for the same. - Upon restoring Snapshot, change the layout type based on the response from API rather than the opposite of current layout type - Updated the width of modal widget for calculating the positions of children in PositionUtils - Updated Conversion algorithm to remove the dynamic binding path from list for property paths with default autolayout values Fixes #21967 Fixes #21969 Fixes #22244 Fixes #22094 Fixes #22187 Fixes #22697 # Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? Manual - 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 - [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 - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] 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: Preet <preetsidhu.bits@gmail.com>
2023-05-03 04:26:52 +00:00
let snapshotSaveSuccess = false;
try {
chore: Minor Tasks for Auto Layout feature, Sentry errors, metrics and Beta tag (#22792) ## Description This PR includes changes for, - Adding common error messages for sentry issues when user decides to send error message, to enable searching of the reported issues on sentry - Adding Analytics for conversion modal flow, to track user adoption of the feature - Add Beta tag to the conversion button Fixes #19712 Media <img width="301" alt="image" src="https://user-images.githubusercontent.com/71900764/234912585-1c5d60d7-89ed-4a61-82b5-163613584e25.png"> ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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
2023-05-07 05:10:03 +00:00
appId = yield select(getCurrentApplicationId);
const pageWidgetsList: PageWidgetsReduxState = yield select(getPageWidgets);
chore: Minor Tasks for Auto Layout feature, Sentry errors, metrics and Beta tag (#22792) ## Description This PR includes changes for, - Adding common error messages for sentry issues when user decides to send error message, to enable searching of the reported issues on sentry - Adding Analytics for conversion modal flow, to track user adoption of the feature - Add Beta tag to the conversion button Fixes #19712 Media <img width="301" alt="image" src="https://user-images.githubusercontent.com/71900764/234912585-1c5d60d7-89ed-4a61-82b5-163613584e25.png"> ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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
2023-05-07 05:10:03 +00:00
const notEmptyApp = isNotEmptyApp(pageWidgetsList);
if (notEmptyApp) {
yield call(createSnapshotSaga);
}
chore: Minor Tasks for Auto Layout feature, Sentry errors, metrics and Beta tag (#22792) ## Description This PR includes changes for, - Adding common error messages for sentry issues when user decides to send error message, to enable searching of the reported issues on sentry - Adding Analytics for conversion modal flow, to track user adoption of the feature - Add Beta tag to the conversion button Fixes #19712 Media <img width="301" alt="image" src="https://user-images.githubusercontent.com/71900764/234912585-1c5d60d7-89ed-4a61-82b5-163613584e25.png"> ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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
2023-05-07 05:10:03 +00:00
AnalyticsUtil.logEvent("CONVERT_FIXED_TO_AUTO", {
isNewApp: !notEmptyApp,
appId,
});
fix: Layout Conversion bugs for auto Layout (#22565) ## Description The Changes in this PR includes, - separated the logic for getting Readable snapshot details and are derived on component render rather than on change of state to have upto date value on the conversion modal - Separated the DayJs Utils for the same. - Upon restoring Snapshot, change the layout type based on the response from API rather than the opposite of current layout type - Updated the width of modal widget for calculating the positions of children in PositionUtils - Updated Conversion algorithm to remove the dynamic binding path from list for property paths with default autolayout values Fixes #21967 Fixes #21969 Fixes #22244 Fixes #22094 Fixes #22187 Fixes #22697 # Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? Manual - 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 - [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 - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] 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: Preet <preetsidhu.bits@gmail.com>
2023-05-03 04:26:52 +00:00
snapshotSaveSuccess = true;
yield put(
setLayoutConversionStateAction(CONVERSION_STATES.CONVERSION_SPINNER),
);
const pageLayouts = [];
for (const [pageId, page] of Object.entries(pageWidgetsList)) {
const { dsl: normalizedDSL, layoutId } = page;
const fixedDSL: DSLWidget = CanvasWidgetsNormalizer.denormalize(
MAIN_CONTAINER_WIDGET_ID,
{ canvasWidgets: normalizedDSL },
);
const dsl: DSLWidget = convertToAutoLayout(fixedDSL);
pageLayouts.push({
pageId,
layoutId,
layout: {
dsl,
},
});
}
yield call(saveAllPagesSaga, pageLayouts);
yield call(updateApplicationLayoutType, AppPositioningTypes.AUTO);
//update conversion form state to success
yield put(
setLayoutConversionStateAction(CONVERSION_STATES.COMPLETED_SUCCESS),
);
chore: Minor Tasks for Auto Layout feature, Sentry errors, metrics and Beta tag (#22792) ## Description This PR includes changes for, - Adding common error messages for sentry issues when user decides to send error message, to enable searching of the reported issues on sentry - Adding Analytics for conversion modal flow, to track user adoption of the feature - Add Beta tag to the conversion button Fixes #19712 Media <img width="301" alt="image" src="https://user-images.githubusercontent.com/71900764/234912585-1c5d60d7-89ed-4a61-82b5-163613584e25.png"> ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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
2023-05-07 05:10:03 +00:00
} catch (e: any) {
let error: Error = e;
if (error) {
error.message = `Layout Conversion Error - while Converting from Fixed to Auto Layout: ${error.message}`;
} else {
error = new Error(
"Layout Conversion Error - while Converting from Fixed to Auto Layout",
);
}
log.error(error);
//update conversion form state to error
fix: Layout Conversion bugs for auto Layout (#22565) ## Description The Changes in this PR includes, - separated the logic for getting Readable snapshot details and are derived on component render rather than on change of state to have upto date value on the conversion modal - Separated the DayJs Utils for the same. - Upon restoring Snapshot, change the layout type based on the response from API rather than the opposite of current layout type - Updated the width of modal widget for calculating the positions of children in PositionUtils - Updated Conversion algorithm to remove the dynamic binding path from list for property paths with default autolayout values Fixes #21967 Fixes #21969 Fixes #22244 Fixes #22094 Fixes #22187 Fixes #22697 # Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? Manual - 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 - [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 - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] 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: Preet <preetsidhu.bits@gmail.com>
2023-05-03 04:26:52 +00:00
if (snapshotSaveSuccess) {
yield call(deleteApplicationSnapshotSaga);
}
yield put(
chore: Minor Tasks for Auto Layout feature, Sentry errors, metrics and Beta tag (#22792) ## Description This PR includes changes for, - Adding common error messages for sentry issues when user decides to send error message, to enable searching of the reported issues on sentry - Adding Analytics for conversion modal flow, to track user adoption of the feature - Add Beta tag to the conversion button Fixes #19712 Media <img width="301" alt="image" src="https://user-images.githubusercontent.com/71900764/234912585-1c5d60d7-89ed-4a61-82b5-163613584e25.png"> ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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
2023-05-07 05:10:03 +00:00
setLayoutConversionStateAction(CONVERSION_STATES.COMPLETED_ERROR, error),
);
chore: Minor Tasks for Auto Layout feature, Sentry errors, metrics and Beta tag (#22792) ## Description This PR includes changes for, - Adding common error messages for sentry issues when user decides to send error message, to enable searching of the reported issues on sentry - Adding Analytics for conversion modal flow, to track user adoption of the feature - Add Beta tag to the conversion button Fixes #19712 Media <img width="301" alt="image" src="https://user-images.githubusercontent.com/71900764/234912585-1c5d60d7-89ed-4a61-82b5-163613584e25.png"> ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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
2023-05-07 05:10:03 +00:00
AnalyticsUtil.logEvent("CONVERSION_FAILURE", {
flow: "CONVERT_FIXED_TO_AUTO",
appId,
});
}
}
//Saga to log conversion sentry error when user reports it
function* logLayoutConversionErrorSaga() {
try {
const error: Error = yield select(
(state: AppState) => state.ui.layoutConversion.conversionError,
);
yield call(Sentry.captureException, error);
} catch (e) {
throw e;
}
}
/**
* Set layout type of Application based on user selection while converting
* @param selectedLayoutType
*/
function* setLayoutTypePostConversion(selectedLayoutType: SupportedLayouts) {
let convertToLayoutType: SupportedLayouts = selectedLayoutType;
const applicationId: string = yield select(getCurrentApplicationId);
if (selectedLayoutType === "DESKTOP") {
convertToLayoutType = "FLUID";
}
yield put(
updateApplicationLayout(applicationId, {
appLayout: {
type: convertToLayoutType,
},
}),
);
}
export default function* layoutConversionSagas() {
yield all([
takeLatest(
ReduxActionTypes.CONVERT_AUTO_TO_FIXED,
convertFromAutoToFixedSaga,
),
takeLatest(
ReduxActionTypes.CONVERT_FIXED_TO_AUTO,
convertFromFixedToAutoSaga,
),
takeLatest(
ReduxActionTypes.LOG_LAYOUT_CONVERSION_ERROR,
logLayoutConversionErrorSaga,
),
]);
}
//Function returns boolean, SnapShot should not be saved for a single empty canvas
chore: Minor Tasks for Auto Layout feature, Sentry errors, metrics and Beta tag (#22792) ## Description This PR includes changes for, - Adding common error messages for sentry issues when user decides to send error message, to enable searching of the reported issues on sentry - Adding Analytics for conversion modal flow, to track user adoption of the feature - Add Beta tag to the conversion button Fixes #19712 Media <img width="301" alt="image" src="https://user-images.githubusercontent.com/71900764/234912585-1c5d60d7-89ed-4a61-82b5-163613584e25.png"> ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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
2023-05-07 05:10:03 +00:00
function isNotEmptyApp(pageWidgetsList: PageWidgetsReduxState) {
const pageList = Object.values(pageWidgetsList);
if (pageList.length !== 1) return true;
const { dsl: pageDSL } = pageList[0];
return Object.keys(pageDSL).length !== 1;
}