2022-04-12 10:50:01 +00:00
|
|
|
import {
|
|
|
|
|
ReduxActionTypes,
|
|
|
|
|
ReduxAction,
|
|
|
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
2020-04-13 08:24:13 +00:00
|
|
|
import { BatchAction, batchAction } from "actions/batchActions";
|
2022-12-22 06:34:28 +00:00
|
|
|
import { EvalMetaUpdates } from "@appsmith/workers/common/DataTreeEvaluator/types";
|
2022-06-25 05:30:54 +00:00
|
|
|
import { DataTreeWidget } from "../entities/DataTree/dataTreeFactory";
|
2020-02-07 02:32:52 +00:00
|
|
|
|
2020-03-06 09:45:21 +00:00
|
|
|
export interface UpdateWidgetMetaPropertyPayload {
|
|
|
|
|
widgetId: string;
|
|
|
|
|
propertyName: string;
|
2022-05-25 09:46:14 +00:00
|
|
|
propertyValue: unknown;
|
2020-03-06 09:45:21 +00:00
|
|
|
}
|
2022-05-25 09:46:14 +00:00
|
|
|
|
|
|
|
|
export const updateWidgetMetaPropAndEval = (
|
2020-02-07 02:32:52 +00:00
|
|
|
widgetId: string,
|
|
|
|
|
propertyName: string,
|
2022-05-25 09:46:14 +00:00
|
|
|
propertyValue: unknown,
|
2020-04-13 08:24:13 +00:00
|
|
|
): BatchAction<UpdateWidgetMetaPropertyPayload> => {
|
|
|
|
|
return batchAction({
|
2022-05-25 09:46:14 +00:00
|
|
|
type: ReduxActionTypes.SET_META_PROP_AND_EVAL,
|
2020-02-07 02:32:52 +00:00
|
|
|
payload: {
|
|
|
|
|
widgetId,
|
|
|
|
|
propertyName,
|
|
|
|
|
propertyValue,
|
|
|
|
|
},
|
2020-04-13 08:24:13 +00:00
|
|
|
});
|
2020-02-07 02:32:52 +00:00
|
|
|
};
|
|
|
|
|
|
2022-06-25 05:30:54 +00:00
|
|
|
export type ResetWidgetMetaPayload = {
|
|
|
|
|
widgetId: string;
|
2022-12-15 08:23:09 +00:00
|
|
|
evaluatedWidget: DataTreeWidget | undefined;
|
2022-06-25 05:30:54 +00:00
|
|
|
};
|
|
|
|
|
|
2020-03-06 09:45:21 +00:00
|
|
|
export const resetWidgetMetaProperty = (
|
|
|
|
|
widgetId: string,
|
2022-12-15 08:23:09 +00:00
|
|
|
evaluatedWidget: DataTreeWidget | undefined,
|
2022-06-25 05:30:54 +00:00
|
|
|
): BatchAction<ResetWidgetMetaPayload> => {
|
2020-04-13 08:24:13 +00:00
|
|
|
return batchAction({
|
2020-03-06 09:45:21 +00:00
|
|
|
type: ReduxActionTypes.RESET_WIDGET_META,
|
|
|
|
|
payload: {
|
|
|
|
|
widgetId,
|
2022-06-25 05:30:54 +00:00
|
|
|
evaluatedWidget,
|
2020-03-06 09:45:21 +00:00
|
|
|
},
|
2022-02-17 04:31:59 +00:00
|
|
|
postEvalActions: [{ type: ReduxActionTypes.RESET_WIDGET_META_EVALUATED }],
|
2020-04-13 08:24:13 +00:00
|
|
|
});
|
2020-03-06 09:45:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const resetChildrenMetaProperty = (
|
|
|
|
|
widgetId: string,
|
|
|
|
|
): ReduxAction<{ widgetId: string }> => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.RESET_CHILDREN_WIDGET_META,
|
|
|
|
|
payload: {
|
|
|
|
|
widgetId,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
2022-01-28 11:10:05 +00:00
|
|
|
|
2022-05-25 09:46:14 +00:00
|
|
|
export const updateMetaState = (evalMetaUpdates: EvalMetaUpdates) => {
|
2022-01-28 11:10:05 +00:00
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.UPDATE_META_STATE,
|
|
|
|
|
payload: {
|
2022-05-25 09:46:14 +00:00
|
|
|
evalMetaUpdates,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const triggerEvalOnMetaUpdate = () => {
|
|
|
|
|
return batchAction({
|
|
|
|
|
type: ReduxActionTypes.META_UPDATE_DEBOUNCED_EVAL,
|
|
|
|
|
payload: {},
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const syncUpdateWidgetMetaProperty = (
|
|
|
|
|
widgetId: string,
|
|
|
|
|
propertyName: string,
|
|
|
|
|
propertyValue: unknown,
|
|
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.SET_META_PROP,
|
|
|
|
|
payload: {
|
|
|
|
|
widgetId,
|
|
|
|
|
propertyName,
|
|
|
|
|
propertyValue,
|
2022-01-28 11:10:05 +00:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
2023-01-13 18:29:03 +00:00
|
|
|
|
|
|
|
|
export const resetWidgetsMetaState = (
|
|
|
|
|
widgetIdsToClear: string[],
|
|
|
|
|
): ReduxAction<{ widgetIdsToClear: string[] }> => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.RESET_WIDGETS_META_STATE,
|
|
|
|
|
payload: {
|
|
|
|
|
widgetIdsToClear,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|