Browse Source

fix: expressions value is empty

Ahmad Kholid 2 years ago
parent
commit
7c01c4400d

+ 4 - 1
src/workflowEngine/WorkflowWorker.js

@@ -175,6 +175,7 @@ class WorkflowWorker {
     const replacedBlock = await templating({
       block,
       data: refData,
+      isPopup: this.engine.isPopup,
       refKeys:
         isRetry || block.data.disableBlock
           ? null
@@ -248,7 +249,9 @@ class WorkflowWorker {
 
         if (blockOnError.insertData) {
           for (const item of blockOnError.dataToInsert) {
-            let value = await renderString(item.value, refData)?.value;
+            let value = (
+              await renderString(item.value, refData, this.engine.isPopup)
+            )?.value;
             value = parseJSON(value, value);
 
             if (item.type === 'variable') {

+ 8 - 8
src/workflowEngine/blocksHandler/handlerConditions.js

@@ -190,15 +190,15 @@ async function conditions({ data, id }, { prevBlockData, refData }) {
     for (const { type, value, compareValue, id: itemId } of data.conditions) {
       if (isConditionMet) break;
 
-      const firstValue = await renderString(
-        compareValue ?? prevData,
-        refData,
-        this.engine.isPopup
+      const firstValue = (
+        await renderString(
+          compareValue ?? prevData,
+          refData,
+          this.engine.isPopup
+        )
       ).value;
-      const secondValue = await renderString(
-        value,
-        refData,
-        this.engine.isPopup
+      const secondValue = (
+        await renderString(value, refData, this.engine.isPopup)
       ).value;
 
       Object.assign(replacedValue, firstValue.list, secondValue.list);

+ 1 - 1
src/workflowEngine/blocksHandler/handlerWebhook.js

@@ -28,7 +28,7 @@ export async function webhook({ data, id }, { refData }) {
 
     const newHeaders = [];
     for (const { value, name } of data.headers) {
-      const newValue = await renderString(value, refData, this.engine.isPopup)
+      const newValue = (await renderString(value, refData, this.engine.isPopup))
         .value;
 
       newHeaders.push({ name, value: newValue });

+ 3 - 3
src/workflowEngine/templating/index.js

@@ -2,7 +2,7 @@ import objectPath from 'object-path';
 import cloneDeep from 'lodash.clonedeep';
 import renderString from './renderString';
 
-export default async function ({ block, refKeys, data }) {
+export default async function ({ block, refKeys, data, isPopup }) {
   if (!refKeys || refKeys.length === 0) return block;
 
   const copyBlock = cloneDeep(block);
@@ -19,7 +19,7 @@ export default async function ({ block, refKeys, data }) {
     if (Array.isArray(currentData)) {
       for (let index = 0; index < currentData.length; index += 1) {
         const value = currentData[index];
-        const renderedValue = await renderString(value, data);
+        const renderedValue = await renderString(value, data, isPopup);
 
         addReplacedValue(renderedValue.list);
         objectPath.set(
@@ -29,7 +29,7 @@ export default async function ({ block, refKeys, data }) {
         );
       }
     } else if (typeof currentData === 'string') {
-      const renderedValue = await renderString(currentData, data);
+      const renderedValue = await renderString(currentData, data, isPopup);
 
       addReplacedValue(renderedValue.list);
       objectPath.set(copyBlock.data, blockDataKey, renderedValue.value);