From 1a63cb392a46414855a8161d1223afa95fa6fdc3 Mon Sep 17 00:00:00 2001 From: navaneeth Date: Wed, 8 Sep 2021 12:30:06 +0530 Subject: [PATCH] Make state variables accessible in transformations --- frontend/src/_helpers/appUtils.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/_helpers/appUtils.js b/frontend/src/_helpers/appUtils.js index 08afd0c92c..f890fac8ec 100644 --- a/frontend/src/_helpers/appUtils.js +++ b/frontend/src/_helpers/appUtils.js @@ -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 }); }