Explorar el Código

feat: stop loop option in loop breakpoint block

Ahmad Kholid hace 2 años
padre
commit
73f6577ce3

+ 1 - 1
src/background/workflowEngine/blocksHandler/handlerBlocksGroup.js

@@ -27,7 +27,7 @@ function blocksGroup({ data, id }, { prevBlockData }) {
           if (!acc.connections[outputId]) {
             acc.connections[outputId] = [];
           }
-          acc.connections[outputId].push(nextBlock);
+          acc.connections[outputId].push({ id: nextBlock });
         }
 
         return acc;

+ 4 - 3
src/background/workflowEngine/blocksHandler/handlerLoopBreakpoint.js

@@ -11,11 +11,12 @@ function loopBreakpoint(block, { prevBlockData }) {
           : currentLoop.index <= currentLoop.data.length - 1;
     }
 
-    if (
+    const continueLoop =
       currentLoop &&
       currentLoop.index < currentLoop.maxLoop - 1 &&
-      validLoopData
-    ) {
+      validLoopData;
+
+    if (!block.data.clearLoop && continueLoop) {
       resolve({
         data: '',
         nextBlockId: [{ id: currentLoop.blockId }],

+ 5 - 1
src/background/workflowEngine/worker.js

@@ -94,7 +94,11 @@ class Worker {
   }
 
   executeNextBlocks(connections, prevBlockData) {
-    connections.forEach(({ id, targetHandle, sourceHandle }, index) => {
+    connections.forEach((connection, index) => {
+      const { id, targetHandle, sourceHandle } =
+        typeof connection === 'string'
+          ? { id: connection, targetHandle: '', sourceHandle: '' }
+          : connection;
       const execParam = { prevBlockData, targetHandle, sourceHandle };
 
       if (index === 0) {

+ 7 - 0
src/components/block/BlockLoopBreakpoint.vue

@@ -24,6 +24,13 @@
       required
       @input="handleInput"
     />
+    <ui-checkbox
+      :value="data.clearLoop"
+      class="mt-2"
+      @change="$emit('update', { clearLoop: $event })"
+    >
+      Stop loop
+    </ui-checkbox>
     <Handle :id="`${id}-output-1`" type="source" :position="Position.Right" />
   </ui-card>
 </template>

+ 1 - 0
src/utils/shared.js

@@ -736,6 +736,7 @@ export const tasks = {
     data: {
       disableBlock: false,
       loopId: '',
+      clearLoop: false,
     },
   },
   'blocks-group': {