From 856daaacda4b09929e6f58a211e81914c7e3d10c Mon Sep 17 00:00:00 2001 From: frikky Date: Thu, 28 Jul 2022 02:19:05 +0200 Subject: [PATCH] Fixed minor frontend issues related to unparsable data --- backend/go-app/go.mod | 2 +- frontend/src/components/Header.js | 1 - frontend/src/components/ShuffleCodeEditor.jsx | 109 +++++++++--------- frontend/src/views/AngularWorkflow.jsx | 13 ++- 4 files changed, 67 insertions(+), 58 deletions(-) diff --git a/backend/go-app/go.mod b/backend/go-app/go.mod index 1e9f553a..a72efb22 100644 --- a/backend/go-app/go.mod +++ b/backend/go-app/go.mod @@ -24,7 +24,7 @@ require ( github.com/h2non/filetype v1.1.3 github.com/nirasan/go-oauth-pkce-code-verifier v0.0.0-20170819232839-0fbfe93532da // indirect github.com/satori/go.uuid v1.2.0 - github.com/shuffle/shuffle-shared v0.2.72 + github.com/shuffle/shuffle-shared v0.2.73 go4.org v0.0.0-20201209231011-d4a079459e60 // indirect golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce google.golang.org/api v0.65.0 diff --git a/frontend/src/components/Header.js b/frontend/src/components/Header.js index 337580ef..92f1d5a1 100644 --- a/frontend/src/components/Header.js +++ b/frontend/src/components/Header.js @@ -723,7 +723,6 @@ const Header = (props) => { userdata.orgs.splice(foundIndex+1, 1) } else { console.log("ORG NOT FOUND IN LIST: ", childorg) - } // This is stupid :) diff --git a/frontend/src/components/ShuffleCodeEditor.jsx b/frontend/src/components/ShuffleCodeEditor.jsx index 20aaca45..150cb8e2 100644 --- a/frontend/src/components/ShuffleCodeEditor.jsx +++ b/frontend/src/components/ShuffleCodeEditor.jsx @@ -342,77 +342,82 @@ const CodeEditor = (props) => { const expectedOutput = (input) => { const found = input.match(/[$]{1}([a-zA-Z0-9_-]+\.?){1}([a-zA-Z0-9#_-]+\.?){0,}/g) + //console.log(found) // Whelp this is inefficient af. Single loop pls // When the found array is empty. - for (var i = 0; i < found.length; i++) { - try { - found[i] = found[i].toLowerCase() + try { + for (var i = 0; i < found.length; i++) { + try { + found[i] = found[i].toLowerCase() - var valuefound = false - for (var j = 0; j < actionlist.length; j++) { - if(found[i].slice(1,).toLowerCase() === actionlist[j].autocomplete.toLowerCase()){ - valuefound = true - try { - input = input.replace(found[i], JSON.stringify(actionlist[j].example)); - } catch (e) { - input = input.replace(found[i], actionlist[j].example) + var valuefound = false + for (var j = 0; j < actionlist.length; j++) { + if(found[i].slice(1,).toLowerCase() === actionlist[j].autocomplete.toLowerCase()){ + valuefound = true + try { + input = input.replace(found[i], JSON.stringify(actionlist[j].example)); + } catch (e) { + input = input.replace(found[i], actionlist[j].example) + } + } else { } - } else { } - } - if (!valuefound && availableVariables.includes(found[i])) { - var shouldbreak = false - for (var k=0; k < actionlist.length; k++){ - var parsedPaths = [] - if (typeof actionlist[k].example === "object") { - parsedPaths = GetParsedPaths(actionlist[k].example, ""); - } + if (!valuefound && availableVariables.includes(found[i])) { + var shouldbreak = false + for (var k=0; k < actionlist.length; k++){ + var parsedPaths = [] + if (typeof actionlist[k].example === "object") { + parsedPaths = GetParsedPaths(actionlist[k].example, ""); + } - for (var key in parsedPaths) { - const fullpath = "$"+actionlist[k].autocomplete.toLowerCase()+parsedPaths[key].autocomplete - if (fullpath === found[i]) { - //if (actionlist[k].example === undefined) { - // actionlist[k].example = "TMP" - //} + for (var key in parsedPaths) { + const fullpath = "$"+actionlist[k].autocomplete.toLowerCase()+parsedPaths[key].autocomplete + if (fullpath === found[i]) { + //if (actionlist[k].example === undefined) { + // actionlist[k].example = "TMP" + //} - try { - var new_input = FindJsonPath(fullpath, actionlist[k].example) - } catch (e) { - console.log("ERR IN INPUT: ", e) - } - - if (typeof new_input === "object") { - new_input = JSON.stringify(new_input) - } else { - if (typeof new_input === "string") { - new_input = new_input - } else { - new_input = "" + try { + var new_input = FindJsonPath(fullpath, actionlist[k].example) + } catch (e) { + console.log("ERR IN INPUT: ", e) } + + if (typeof new_input === "object") { + new_input = JSON.stringify(new_input) + } else { + if (typeof new_input === "string") { + new_input = new_input + } else { + new_input = "" + } + } + + input = input.replace(found[i], new_input) + + //} catch (e) { + // input = input.replace(found[i], actionlist[k].example) + //} + + shouldbreak = true + break } + } - input = input.replace(found[i], new_input) - - //} catch (e) { - // input = input.replace(found[i], actionlist[k].example) - //} - - shouldbreak = true + if (shouldbreak) { break } } - - if (shouldbreak) { - break - } } + } catch (e) { + console.log("Replace error: ", e) } - } catch (e) { - console.log("Replace error: ", e) } + } catch (e) { + } const tmpValidation = validateJson(input.valueOf()) diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index bdc66c9a..124d78d5 100644 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -414,9 +414,11 @@ const AngularWorkflow = (defaultprops) => { console.log("RESPONSE FOR APP: ", responseJson.reason); if (responseJson.reason !== undefined && responseJson.reason !== undefined && responseJson.reason.length > 0) { - selectedApp.documentation = responseJson.reason - setSelectedApp(selectedApp) - setUpdate(Math.random()) + if (!responseJson.reason.includes("404: Not Found") && responseJson.reason.length > 50) { + selectedApp.documentation = responseJson.reason + setSelectedApp(selectedApp) + setUpdate(Math.random()) + } } } @@ -6167,8 +6169,11 @@ const AngularWorkflow = (defaultprops) => { //newSelectedAction.parameters[newParamIndex].value = param.value } - // Not doing options fields + if (newSelectedAction.parameters === undefined || newSelectedAction.parameters === null) { + continue + } + // Not doing options fields const newParamIndex = newSelectedAction.parameters.findIndex(paramdata => paramdata.name === param.name) if (newParamIndex < 0) { continue