Make state variables accessible in transformations

This commit is contained in:
navaneeth 2021-09-08 12:30:06 +05:30
parent 3c6669799e
commit 1a63cb392a

View file

@ -48,11 +48,13 @@ export function fetchOAuthToken(authUrl, dataSourceId) {
export function runTransformation(_ref, rawData, transformation) {
const data = rawData;
const evalFunction = Function(['data', 'moment', '_', 'currentState'], transformation);
const evalFunction = Function(['data', 'moment', '_', 'components', 'queries', 'globals'], transformation);
let result = [];
const currentState = _ref.state.currentState || {};
try {
result = evalFunction(data, moment, _, _ref.state.currentState);
result = evalFunction(data, moment, _, currentState.components, currentState.queries, currentState.globals);
} catch (err) {
toast.error(err.message, { hideProgressBar: true });
}