Fix container widget dynamicBindingPathList correction (#3619)

This commit is contained in:
Hetu Nandu 2021-03-19 11:39:35 +05:30 committed by GitHub
parent a82c789c1a
commit 64116583e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -365,7 +365,7 @@ function* savePageSaga(action: ReduxAction<{ isRetry?: boolean }>) {
if (error instanceof IncorrectBindingError) {
const { isRetry } = action.payload;
const incorrectBindingError = JSON.parse(error.message);
const { widgetId, message } = incorrectBindingError;
const { message } = incorrectBindingError;
if (isRetry) {
Sentry.captureException(new Error("Failed to correct binding paths"));
yield put({
@ -379,18 +379,23 @@ function* savePageSaga(action: ReduxAction<{ isRetry?: boolean }>) {
},
});
} else {
const correctedWidget = migrateIncorrectDynamicBindingPathLists(
widgets[widgetId],
// Create a denormalized structure because the migration needs the children in the dsl form
const denormalizedWidgets = CanvasWidgetsNormalizer.denormalize("0", {
canvasWidgets: widgets,
});
const correctedWidgets = migrateIncorrectDynamicBindingPathLists(
denormalizedWidgets,
);
// Normalize the widgets because the save page needs it in the flat structure
const normalizedWidgets = CanvasWidgetsNormalizer.normalize(
correctedWidgets,
);
AnalyticsUtil.logEvent("CORRECT_BAD_BINDING", {
error: error.message,
correctWidget: JSON.stringify(correctedWidget),
correctWidget: JSON.stringify(normalizedWidgets),
});
yield put(
updateAndSaveLayout(
{ ...widgets, [widgetId]: correctedWidget },
true,
),
updateAndSaveLayout(normalizedWidgets.entities.canvasWidgets, true),
);
}
}