From 59d90d1c28f41d0e16ce6e15283c887024fc8041 Mon Sep 17 00:00:00 2001 From: frikky Date: Fri, 14 Jan 2022 15:58:15 +0100 Subject: [PATCH] Showing the correct parents in autocompletion --- frontend/src/components/ParsedAction.jsx | 57 +--------------------- frontend/src/views/AngularWorkflow.jsx | 60 +++++++----------------- 2 files changed, 18 insertions(+), 99 deletions(-) diff --git a/frontend/src/components/ParsedAction.jsx b/frontend/src/components/ParsedAction.jsx index aa0485dc..7b9acce2 100644 --- a/frontend/src/components/ParsedAction.jsx +++ b/frontend/src/components/ParsedAction.jsx @@ -162,6 +162,7 @@ const ParsedAction = (props) => { appAuthentication, getAppAuthentication, actionDelayChange, + getParents, isCloud, } = props; @@ -186,62 +187,6 @@ const ParsedAction = (props) => { "parse(", "join(", ]; - const getParents = (action) => { - if (cy === undefined) { - return []; - } - - var allkeys = [action.id]; - var handled = []; - var results = []; - - while (true) { - for (var key in allkeys) { - var currentnode = cy.getElementById(allkeys[key]); - if (currentnode === undefined) { - continue; - } - - if (handled.includes(currentnode.data("id"))) { - continue; - } else { - // Get the name / label here too? - handled.push(currentnode.data("id")); - results.push(currentnode.data()); - } - - if (currentnode.length === 0) { - continue; - } - - const incomingEdges = currentnode.incomers("edge"); - if (incomingEdges.length === 0) { - continue; - } - - for (var i = 0; i < incomingEdges.length; i++) { - var tmp = incomingEdges[i]; - if (!allkeys.includes(tmp.data().source)) { - allkeys.push(tmp.data().source); - } - } - } - if (results.length === allkeys.length) { - break; - } - } - - // Some obscure bug made this have to be done.. zz - results = results.filter( - (data) => - data !== undefined && action !== undefined && data.id !== action.id - ); - results = results.filter( - (data) => data !== undefined && data.type !== "TRIGGER" - ); - results.push({ label: "Execution Argument", type: "INTERNAL" }); - return results; - }; const getApp = (appId, setApp) => { fetch(globalUrl + "/api/v1/apps/" + appId + "/config?openapi=false", { diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index 1ed01c7b..7f7a0827 100644 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -2362,6 +2362,7 @@ const AngularWorkflow = (defaultprops) => { } } + console.log("DATA: ", data) setSelectedTriggerIndex(trigger_index); setSelectedTrigger(data); setSelectedActionEnvironment(data.env); @@ -5527,8 +5528,12 @@ const AngularWorkflow = (defaultprops) => { for (var i = 0; i < incomingEdges.length; i++) { var tmp = incomingEdges[i]; - if (!allkeys.includes(tmp.data().source)) { - allkeys.push(tmp.data().source); + if (tmp.data("decorator")) { + continue + } + + if (!allkeys.includes(tmp.data("source"))) { + allkeys.push(tmp.data("source")); } } } @@ -5540,9 +5545,10 @@ const AngularWorkflow = (defaultprops) => { iterations += 1; } - // Remove self + // Remove on the end as we don't want to remove everything results = results.filter((data) => data.id !== action.id); - results = results.filter((data) => data.type !== "TRIGGER"); + results = results.filter((data) => data.type === "ACTION" || data.app_name === "Shuffle Workflow" || data.app_name === "User Input"); + console.log("RESULTS:", results) results.push({ label: "Execution Argument", type: "INTERNAL" }); return results; }; @@ -7302,44 +7308,11 @@ const AngularWorkflow = (defaultprops) => { continue; } - foundResult.result = foundResult.result.trim(); - foundResult.result = foundResult.result - .split(" None") - .join(' "None"'); - foundResult.result = foundResult.result - .split(" False") - .join(" false"); - foundResult.result = foundResult.result - .split(" True") - .join(" true"); - - var jsonvalid = true; - try { - if ( - !foundResult.result.includes("{") && - !foundResult.result.includes("[") - ) { - jsonvalid = false; - } - } catch (e) { - try { - foundResult.result = foundResult.result.split("'").join('"'); - if ( - !foundResult.result.includes("{") && - !foundResult.result.includes("[") - ) { - jsonvalid = false; - } - } catch (e) { - jsonvalid = false; - } - } - - // Finds the FIRST json only - if (jsonvalid) { - exampledata = JSON.parse(foundResult.result); - break; - } + const validated = validateJson(foundResult.result) + if (validated.valid) { + exampledata = validateJson.result + break + } } } @@ -7350,7 +7323,7 @@ const AngularWorkflow = (defaultprops) => { name: item.label, autocomplete: `${item.label.split(" ").join("_")}`, example: exampledata, - }; + } actionlist.push(actionvalue); } } @@ -10181,6 +10154,7 @@ const AngularWorkflow = (defaultprops) => {