Browse Source

fix: error when using conditions block

Ahmad Kholid 3 years ago
parent
commit
0f8fd0fd2a

+ 5 - 2
src/background/workflow-engine/blocks-handler/handler-conditions.js

@@ -19,8 +19,11 @@ function conditions({ data, outputs }, { prevBlockData, refData }) {
     data.conditions.forEach(({ type, value, compareValue }, index) => {
       if (isConditionMatch) return;
 
-      const firstValue = mustacheReplacer(compareValue ?? prevData, refData);
-      const secondValue = mustacheReplacer(value, refData);
+      const firstValue = mustacheReplacer({
+        str: compareValue ?? prevData,
+        data: refData,
+      });
+      const secondValue = mustacheReplacer({ str: value, data: refData });
 
       const isMatch = compareBlockValue(type, firstValue, secondValue);
 

+ 1 - 0
src/manifest.json

@@ -31,6 +31,7 @@
     "proxy",
     "alarms",
     "storage",
+    "debugger",
     "webNavigation",
     "unlimitedStorage",
     "<all_urls>"

+ 1 - 1
src/utils/reference-data/mustache-replacer.js

@@ -31,7 +31,7 @@ export default function ({ str, data, block }) {
       const { dataKey, path } = keyParser(key);
       result = getObjectPath(data[dataKey], path) ?? match;
     }
-    if (block.name === 'webhook') {
+    if (block && block.name === 'webhook') {
       return JSON.stringify(result);
     }
     return typeof result === 'string' ? result : JSON.stringify(result);