Fix widget updates not working properly (#3403)
* Fix widget updates not working properly
* Revert "Fix: Deleting a tab from a tab widget from the explorer would not reflect in the canvas(#3218)"
This reverts commit 39e4990a7f.
This commit is contained in:
parent
c4d6405981
commit
dc154b94b0
|
|
@ -40,7 +40,6 @@ import {
|
||||||
SetWidgetDynamicPropertyPayload,
|
SetWidgetDynamicPropertyPayload,
|
||||||
updateWidgetProperty,
|
updateWidgetProperty,
|
||||||
UpdateWidgetPropertyPayload,
|
UpdateWidgetPropertyPayload,
|
||||||
updateWidgetPropertyRequest,
|
|
||||||
UpdateWidgetPropertyRequestPayload,
|
UpdateWidgetPropertyRequestPayload,
|
||||||
} from "actions/controlActions";
|
} from "actions/controlActions";
|
||||||
import {
|
import {
|
||||||
|
|
@ -54,7 +53,7 @@ import {
|
||||||
isPathADynamicTrigger,
|
isPathADynamicTrigger,
|
||||||
} from "utils/DynamicBindingUtils";
|
} from "utils/DynamicBindingUtils";
|
||||||
import { WidgetProps } from "widgets/BaseWidget";
|
import { WidgetProps } from "widgets/BaseWidget";
|
||||||
import _, { cloneDeep, isString, set, uniqBy } from "lodash";
|
import _, { cloneDeep, isString, set } from "lodash";
|
||||||
import WidgetFactory from "utils/WidgetFactory";
|
import WidgetFactory from "utils/WidgetFactory";
|
||||||
import {
|
import {
|
||||||
buildWidgetBlueprint,
|
buildWidgetBlueprint,
|
||||||
|
|
@ -434,23 +433,6 @@ export function* deleteSaga(deleteAction: ReduxAction<WidgetDelete>) {
|
||||||
// SPECIAL HANDLING FOR TABS IN A TABS WIDGET
|
// SPECIAL HANDLING FOR TABS IN A TABS WIDGET
|
||||||
if (parent.type === WidgetTypes.TABS_WIDGET && widget.tabName) {
|
if (parent.type === WidgetTypes.TABS_WIDGET && widget.tabName) {
|
||||||
widgetName = widget.tabName;
|
widgetName = widget.tabName;
|
||||||
// Deleting a tab from the explorer doesn't remove the same
|
|
||||||
// from the "tabs" property of the widget.
|
|
||||||
// So updating the widget property here when the children length doesn't match
|
|
||||||
// `tabs` length
|
|
||||||
if (parent.children?.length !== parent.tabs.length) {
|
|
||||||
const filteredTabs = parent.tabs.filter(
|
|
||||||
(tab: any) => tab.widgetId !== widgetId,
|
|
||||||
);
|
|
||||||
yield put(
|
|
||||||
updateWidgetPropertyRequest(
|
|
||||||
parentId,
|
|
||||||
"tabs",
|
|
||||||
filteredTabs,
|
|
||||||
RenderModes.CANVAS,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (saveStatus && !disallowUndo) {
|
if (saveStatus && !disallowUndo) {
|
||||||
Toaster.show({
|
Toaster.show({
|
||||||
|
|
@ -758,7 +740,7 @@ function applyDynamicPathUpdates(
|
||||||
key: update.propertyPath,
|
key: update.propertyPath,
|
||||||
});
|
});
|
||||||
} else if (update.effect === DynamicPathUpdateEffectEnum.REMOVE) {
|
} else if (update.effect === DynamicPathUpdateEffectEnum.REMOVE) {
|
||||||
_.reject(currentList, { key: update.propertyPath });
|
currentList = _.reject(currentList, { key: update.propertyPath });
|
||||||
}
|
}
|
||||||
return currentList;
|
return currentList;
|
||||||
}
|
}
|
||||||
|
|
@ -831,12 +813,14 @@ function* setWidgetDynamicPropertySaga(
|
||||||
yield put(updateAndSaveLayout(widgets));
|
yield put(updateAndSaveLayout(widgets));
|
||||||
}
|
}
|
||||||
|
|
||||||
function* getPropertiesToUpdate(
|
function getPropertiesToUpdate(
|
||||||
widgetId: string,
|
widget: WidgetProps,
|
||||||
updates: Record<string, unknown>,
|
updates: Record<string, unknown>,
|
||||||
) {
|
): {
|
||||||
const widget: WidgetProps = yield select(getWidget, widgetId);
|
propertyUpdates: Record<string, unknown>;
|
||||||
|
dynamicTriggerPathList: DynamicPath[];
|
||||||
|
dynamicBindingPathList: DynamicPath[];
|
||||||
|
} {
|
||||||
// Create a
|
// Create a
|
||||||
const widgetWithUpdates = _.cloneDeep(widget);
|
const widgetWithUpdates = _.cloneDeep(widget);
|
||||||
Object.entries(updates).forEach(([propertyPath, propertyValue]) => {
|
Object.entries(updates).forEach(([propertyPath, propertyValue]) => {
|
||||||
|
|
@ -919,7 +903,7 @@ function* batchUpdateWidgetPropertySaga(
|
||||||
propertyUpdates,
|
propertyUpdates,
|
||||||
dynamicTriggerPathList,
|
dynamicTriggerPathList,
|
||||||
dynamicBindingPathList,
|
dynamicBindingPathList,
|
||||||
} = yield getPropertiesToUpdate(widgetId, modify);
|
} = getPropertiesToUpdate(widget, modify);
|
||||||
|
|
||||||
// We loop over all updates
|
// We loop over all updates
|
||||||
Object.entries(propertyUpdates).forEach(
|
Object.entries(propertyUpdates).forEach(
|
||||||
|
|
@ -928,21 +912,8 @@ function* batchUpdateWidgetPropertySaga(
|
||||||
widget = set(widget, propertyPath, propertyValue);
|
widget = set(widget, propertyPath, propertyValue);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
widget.dynamicBindingPathList = dynamicBindingPathList;
|
||||||
if (dynamicBindingPathList?.length) {
|
widget.dynamicTriggerPathList = dynamicTriggerPathList;
|
||||||
const currentList = widget.dynamicBindingPathList || [];
|
|
||||||
widget.dynamicBindingPathList = uniqBy(
|
|
||||||
[...currentList, ...dynamicBindingPathList],
|
|
||||||
"key",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (dynamicTriggerPathList?.length) {
|
|
||||||
const currentList = widget.dynamicTriggerPathList || [];
|
|
||||||
widget.dynamicTriggerPathList = uniqBy(
|
|
||||||
[...currentList, ...dynamicTriggerPathList],
|
|
||||||
"key",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.debug("Error updating property paths: ", { e });
|
log.debug("Error updating property paths: ", { e });
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user