PromucFlow_constructor/app/client/src/actions/metaActions.ts

90 lines
2.0 KiB
TypeScript
Raw Normal View History

import {
ReduxActionTypes,
ReduxAction,
} from "@appsmith/constants/ReduxActionConstants";
2020-04-13 08:24:13 +00:00
import { BatchAction, batchAction } from "actions/batchActions";
import { EvalMetaUpdates } from "workers/common/DataTreeEvaluator/types";
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;
propertyValue: unknown;
2020-03-06 09:45:21 +00:00
}
export const updateWidgetMetaPropAndEval = (
2020-02-07 02:32:52 +00:00
widgetId: string,
propertyName: string,
propertyValue: unknown,
2020-04-13 08:24:13 +00:00
): BatchAction<UpdateWidgetMetaPropertyPayload> => {
return batchAction({
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
};
export type ResetWidgetMetaPayload = {
widgetId: string;
evaluatedWidget: DataTreeWidget;
};
2020-03-06 09:45:21 +00:00
export const resetWidgetMetaProperty = (
widgetId: string,
evaluatedWidget: DataTreeWidget,
): 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,
evaluatedWidget,
2020-03-06 09:45:21 +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,
},
};
};
export const updateMetaState = (evalMetaUpdates: EvalMetaUpdates) => {
return {
type: ReduxActionTypes.UPDATE_META_STATE,
payload: {
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,
},
};
};