Started looking at ways to parse invalid JSON patterns

This commit is contained in:
frikky
2022-02-16 20:14:52 +01:00
parent be31c329de
commit 8af27d2800
4 changed files with 430 additions and 395 deletions
+24 -1
View File
@@ -16,6 +16,7 @@ import urllib.parse
import jinja2 import jinja2
from io import BytesIO from io import BytesIO
from liquid import Liquid from liquid import Liquid
#import barely_json
runtime = os.getenv("SHUFFLE_SWARM_CONFIG", "") runtime = os.getenv("SHUFFLE_SWARM_CONFIG", "")
@@ -171,6 +172,7 @@ class AppBase:
# Try it with some magic # Try it with some magic
self.logger.info(f"""[DEBUG] Inside Send result with status {action_result["status"]}""") self.logger.info(f"""[DEBUG] Inside Send result with status {action_result["status"]}""")
#if isinstance(action_result,
# FIXME: Add cleanup of parameters to not send to frontend here # FIXME: Add cleanup of parameters to not send to frontend here
params = {} params = {}
@@ -1745,7 +1747,7 @@ class AppBase:
basejson = json.loads(baseresult) basejson = json.loads(baseresult)
except json.decoder.JSONDecodeError as e: except json.decoder.JSONDecodeError as e:
try: try:
baseresult = baseresult.replace("\'", "\"") #baseresult = baseresult.replace("\'", "\"")
basejson = json.loads(baseresult) basejson = json.loads(baseresult)
except json.decoder.JSONDecodeError as e: except json.decoder.JSONDecodeError as e:
print("Parser issue with JSON: %s" % e) print("Parser issue with JSON: %s" % e)
@@ -2333,6 +2335,27 @@ class AppBase:
return True, "" return True, ""
#
#
#
#
# CONT
# CONT
# CONT
# CONT
# CONT
# CONT
# CONT
# CONT
# CONT
# CONT
# CONT
# CONT
# CONT
#
#
#
#
# THE START IS ACTUALLY RIGHT HERE :O # THE START IS ACTUALLY RIGHT HERE :O
# Checks whether conditions are met, otherwise set # Checks whether conditions are met, otherwise set
+12 -1
View File
@@ -5177,8 +5177,19 @@ func handleCloudSetup(resp http.ResponseWriter, request *http.Request) {
_, err = handleStopCloudSync(syncPath, *org) _, err = handleStopCloudSync(syncPath, *org)
if err != nil { if err != nil {
ret := shuffle.ResultChecker{
Success: false,
Reason: err,
}
resp.WriteHeader(401) resp.WriteHeader(401)
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "%s"}`, err))) b, err := json.Marshal(requestData)
if err != nil {
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "%s"}`, err)))
return
}
resp.Write([]byte(fmt.Sprintf(b)))
} else { } else {
resp.WriteHeader(200) resp.WriteHeader(200)
resp.Write([]byte(fmt.Sprintf(`{"success": true, "reason": "Successfully disabled cloud sync for org."}`))) resp.Write([]byte(fmt.Sprintf(`{"success": true, "reason": "Successfully disabled cloud sync for org."}`)))
+1 -1
View File
@@ -542,7 +542,7 @@ const ParsedAction = (props) => {
} }
} }
console.log("ACTIONLIST: ", actionlist) //console.log("ACTIONLIST: ", actionlist)
setActionlist(actionlist); setActionlist(actionlist);
} }
} }
+393 -392
View File
@@ -735,200 +735,202 @@ const AngularWorkflow = (defaultprops) => {
// Loop nodes and find results // Loop nodes and find results
// Update on every interval? idk // Update on every interval? idk
if (JSON.stringify(responseJson) !== JSON.stringify(executionData)) { ReactDOM.unstable_batchedUpdates(() => {
// FIXME: If another is selected, don't edit.. if (JSON.stringify(responseJson) !== JSON.stringify(executionData)) {
// Doesn't work because this is some async garbage // FIXME: If another is selected, don't edit..
if ( // Doesn't work because this is some async garbage
executionData.execution_id === undefined || if (
(responseJson.execution_id === executionData.execution_id && executionData.execution_id === undefined ||
responseJson.results !== undefined && (responseJson.execution_id === executionData.execution_id &&
responseJson.results !== null) responseJson.results !== undefined &&
) { responseJson.results !== null)
if ( ) {
executionData.status !== responseJson.status || if (
executionData.result !== responseJson.result || executionData.status !== responseJson.status ||
executionData.results.length !== responseJson.results.length executionData.result !== responseJson.result ||
) { executionData.results.length !== responseJson.results.length
setExecutionData(responseJson); ) {
} else { setExecutionData(responseJson);
console.log("NOT updating state."); } else {
} console.log("NOT updating state.");
} }
} }
}
if (responseJson.execution_id !== executionRequest.execution_id) { if (responseJson.execution_id !== executionRequest.execution_id) {
cy.elements().removeClass( cy.elements().removeClass(
"success-highlight failure-highlight executing-highlight" "success-highlight failure-highlight executing-highlight"
); );
return; return;
} }
if (responseJson.results !== null && responseJson.results.length > 0) { if (responseJson.results !== null && responseJson.results.length > 0) {
for (var key in responseJson.results) { for (var key in responseJson.results) {
var item = responseJson.results[key]; var item = responseJson.results[key];
var currentnode = cy.getElementById(item.action.id); var currentnode = cy.getElementById(item.action.id);
if (currentnode.length === 0) { if (currentnode.length === 0) {
continue; continue;
} }
currentnode = currentnode[0]; currentnode = currentnode[0];
const outgoingEdges = currentnode.outgoers("edge"); const outgoingEdges = currentnode.outgoers("edge");
const incomingEdges = currentnode.incomers("edge"); const incomingEdges = currentnode.incomers("edge");
switch (item.status) { switch (item.status) {
case "EXECUTING": case "EXECUTING":
currentnode.removeClass("not-executing-highlight"); currentnode.removeClass("not-executing-highlight");
currentnode.removeClass("success-highlight"); currentnode.removeClass("success-highlight");
currentnode.removeClass("failure-highlight"); currentnode.removeClass("failure-highlight");
currentnode.removeClass("shuffle-hover-highlight"); currentnode.removeClass("shuffle-hover-highlight");
currentnode.removeClass("awaiting-data-highlight"); currentnode.removeClass("awaiting-data-highlight");
incomingEdges.addClass("success-highlight"); incomingEdges.addClass("success-highlight");
currentnode.addClass("executing-highlight"); currentnode.addClass("executing-highlight");
break; break;
case "SKIPPED": case "SKIPPED":
currentnode.removeClass("not-executing-highlight"); currentnode.removeClass("not-executing-highlight");
currentnode.removeClass("success-highlight"); currentnode.removeClass("success-highlight");
currentnode.removeClass("failure-highlight"); currentnode.removeClass("failure-highlight");
currentnode.removeClass("shuffle-hover-highlight"); currentnode.removeClass("shuffle-hover-highlight");
currentnode.removeClass("awaiting-data-highlight"); currentnode.removeClass("awaiting-data-highlight");
currentnode.removeClass("executing-highlight"); currentnode.removeClass("executing-highlight");
currentnode.addClass("skipped-highlight"); currentnode.addClass("skipped-highlight");
break; break;
case "WAITING": case "WAITING":
currentnode.removeClass("not-executing-highlight"); currentnode.removeClass("not-executing-highlight");
currentnode.removeClass("success-highlight"); currentnode.removeClass("success-highlight");
currentnode.removeClass("failure-highlight"); currentnode.removeClass("failure-highlight");
currentnode.removeClass("shuffle-hover-highlight"); currentnode.removeClass("shuffle-hover-highlight");
currentnode.removeClass("awaiting-data-highlight"); currentnode.removeClass("awaiting-data-highlight");
currentnode.addClass("executing-highlight"); currentnode.addClass("executing-highlight");
if (!visited.includes(item.action.label)) { if (!visited.includes(item.action.label)) {
if (executionRunning) { if (executionRunning) {
visited.push(item.action.label); visited.push(item.action.label);
setVisited(visited); setVisited(visited);
} }
} }
// FIXME - add outgoing nodes to executing // FIXME - add outgoing nodes to executing
//const outgoingNodes = outgoingEdges.find().data().target //const outgoingNodes = outgoingEdges.find().data().target
if (outgoingEdges.length > 0) { if (outgoingEdges.length > 0) {
outgoingEdges.addClass("success-highlight"); outgoingEdges.addClass("success-highlight");
} }
break; break;
case "SUCCESS": case "SUCCESS":
currentnode.removeClass("not-executing-highlight"); currentnode.removeClass("not-executing-highlight");
currentnode.removeClass("executing-highlight"); currentnode.removeClass("executing-highlight");
currentnode.removeClass("failure-highlight"); currentnode.removeClass("failure-highlight");
currentnode.removeClass("shuffle-hover-highlight"); currentnode.removeClass("shuffle-hover-highlight");
currentnode.removeClass("awaiting-data-highlight"); currentnode.removeClass("awaiting-data-highlight");
currentnode.addClass("success-highlight"); currentnode.addClass("success-highlight");
incomingEdges.addClass("success-highlight"); incomingEdges.addClass("success-highlight");
outgoingEdges.addClass("success-highlight"); outgoingEdges.addClass("success-highlight");
if ( if (
visited !== undefined && visited !== undefined &&
visited !== null && visited !== null &&
!visited.includes(item.action.label) !visited.includes(item.action.label)
) { ) {
if (executionRunning) { if (executionRunning) {
visited.push(item.action.label); visited.push(item.action.label);
setVisited(visited); setVisited(visited);
} }
} }
// FIXME - add outgoing nodes to executing // FIXME - add outgoing nodes to executing
//const outgoingNodes = outgoingEdges.find().data().target //const outgoingNodes = outgoingEdges.find().data().target
if (outgoingEdges.length > 0) { if (outgoingEdges.length > 0) {
for (var i = 0; i < outgoingEdges.length; i++) { for (var i = 0; i < outgoingEdges.length; i++) {
const edge = outgoingEdges[i]; const edge = outgoingEdges[i];
const targetnode = cy.getElementById(edge.data().target); const targetnode = cy.getElementById(edge.data().target);
if ( if (
targetnode !== undefined && targetnode !== undefined &&
!targetnode.classes().includes("success-highlight") && !targetnode.classes().includes("success-highlight") &&
!targetnode.classes().includes("failure-highlight") !targetnode.classes().includes("failure-highlight")
) { ) {
targetnode.removeClass("not-executing-highlight"); targetnode.removeClass("not-executing-highlight");
targetnode.removeClass("success-highlight"); targetnode.removeClass("success-highlight");
targetnode.removeClass("shuffle-hover-highlight"); targetnode.removeClass("shuffle-hover-highlight");
targetnode.removeClass("failure-highlight"); targetnode.removeClass("failure-highlight");
targetnode.removeClass("awaiting-data-highlight"); targetnode.removeClass("awaiting-data-highlight");
targetnode.addClass("executing-highlight"); targetnode.addClass("executing-highlight");
} }
} }
} }
break; break;
case "FAILURE": case "FAILURE":
//When status comes as failure, allow user to start workflow execution //When status comes as failure, allow user to start workflow execution
if (executionRunning) { if (executionRunning) {
setExecutionRunning(false); setExecutionRunning(false);
} }
currentnode.removeClass("not-executing-highlight"); currentnode.removeClass("not-executing-highlight");
currentnode.removeClass("executing-highlight"); currentnode.removeClass("executing-highlight");
currentnode.removeClass("success-highlight"); currentnode.removeClass("success-highlight");
currentnode.removeClass("awaiting-data-highlight"); currentnode.removeClass("awaiting-data-highlight");
currentnode.removeClass("shuffle-hover-highlight"); currentnode.removeClass("shuffle-hover-highlight");
currentnode.addClass("failure-highlight"); currentnode.addClass("failure-highlight");
if (!visited.includes(item.action.label)) { if (!visited.includes(item.action.label)) {
if ( if (
item.action.result !== undefined && item.action.result !== undefined &&
item.action.result !== null && item.action.result !== null &&
!item.action.result.includes("failed condition") !item.action.result.includes("failed condition")
) { ) {
alert.error( alert.error(
"Error for " + "Error for " +
item.action.label + item.action.label +
" with result " + " with result " +
item.result item.result
); );
} }
visited.push(item.action.label); visited.push(item.action.label);
setVisited(visited); setVisited(visited);
} }
break; break;
case "AWAITING_DATA": case "AWAITING_DATA":
currentnode.removeClass("not-executing-highlight"); currentnode.removeClass("not-executing-highlight");
currentnode.removeClass("executing-highlight"); currentnode.removeClass("executing-highlight");
currentnode.removeClass("success-highlight"); currentnode.removeClass("success-highlight");
currentnode.removeClass("failure-highlight"); currentnode.removeClass("failure-highlight");
currentnode.removeClass("shuffle-hover-highlight"); currentnode.removeClass("shuffle-hover-highlight");
currentnode.addClass("awaiting-data-highlight"); currentnode.addClass("awaiting-data-highlight");
break; break;
default: default:
console.log("DEFAULT?"); console.log("DEFAULT?");
break; break;
} }
} }
} }
if ( if (
responseJson.status === "ABORTED" || responseJson.status === "ABORTED" ||
responseJson.status === "STOPPED" || responseJson.status === "STOPPED" ||
responseJson.status === "FAILURE" || responseJson.status === "FAILURE" ||
responseJson.status === "WAITING" responseJson.status === "WAITING"
) { ) {
stop(); stop();
if (executionRunning) { if (executionRunning) {
setExecutionRunning(false); setExecutionRunning(false);
} }
var curelements = cy.elements(); var curelements = cy.elements();
for (var i = 0; i < curelements.length; i++) { for (var i = 0; i < curelements.length; i++) {
if (curelements[i].classes().includes("executing-highlight")) { if (curelements[i].classes().includes("executing-highlight")) {
curelements[i].removeClass("executing-highlight"); curelements[i].removeClass("executing-highlight");
curelements[i].addClass("failure-highlight"); curelements[i].addClass("failure-highlight");
} }
} }
getWorkflowExecution(props.match.params.key, ""); getWorkflowExecution(props.match.params.key, "");
} else if (responseJson.status === "FINISHED") { } else if (responseJson.status === "FINISHED") {
setExecutionRunning(false); setExecutionRunning(false);
stop(); stop();
getWorkflowExecution(props.match.params.key, ""); getWorkflowExecution(props.match.params.key, "");
setUpdate(Math.random()); setUpdate(Math.random());
} }
})
}; };
const sendStreamRequest = (body) => { const sendStreamRequest = (body) => {
@@ -973,253 +975,252 @@ const AngularWorkflow = (defaultprops) => {
return; return;
} }
setSavingState(2); setSavingState(2);
// This might not be the right course of action, but seems logical, as items could be running already // This might not be the right course of action, but seems logical, as items could be running already
// Makes it possible to update with a version in current render // Makes it possible to update with a version in current render
stop(); stop();
var useworkflow = workflow; var useworkflow = workflow;
if (curworkflow !== undefined) { if (curworkflow !== undefined) {
useworkflow = curworkflow; useworkflow = curworkflow;
} }
var cyelements = cy.elements(); var cyelements = cy.elements();
var newActions = []; var newActions = [];
var newTriggers = []; var newTriggers = [];
var newBranches = []; var newBranches = [];
var newVBranches = []; var newVBranches = [];
var newComments = []; var newComments = [];
for (var key in cyelements) { for (var key in cyelements) {
if (cyelements[key].data === undefined) { if (cyelements[key].data === undefined) {
continue; continue;
} }
var type = cyelements[key].data()["type"]; var type = cyelements[key].data()["type"];
if (type === undefined) { if (type === undefined) {
if ( if (
cyelements[key].data().source === undefined || cyelements[key].data().source === undefined ||
cyelements[key].data().target === undefined cyelements[key].data().target === undefined
) { ) {
continue; continue;
} }
var parsedElement = { var parsedElement = {
id: cyelements[key].data().id, id: cyelements[key].data().id,
source_id: cyelements[key].data().source, source_id: cyelements[key].data().source,
destination_id: cyelements[key].data().target, destination_id: cyelements[key].data().target,
conditions: cyelements[key].data().conditions, conditions: cyelements[key].data().conditions,
decorator: cyelements[key].data().decorator, decorator: cyelements[key].data().decorator,
}; };
if (parsedElement.decorator) { if (parsedElement.decorator) {
newVBranches.push(parsedElement); newVBranches.push(parsedElement);
} else { } else {
newBranches.push(parsedElement); newBranches.push(parsedElement);
} }
} else { } else {
if (type === "ACTION") { if (type === "ACTION") {
const cyelement = cyelements[key].data(); const cyelement = cyelements[key].data();
const elementid = const elementid =
cyelement.id === undefined || cyelement.id === null cyelement.id === undefined || cyelement.id === null
? cyelement["_id"] ? cyelement["_id"]
: cyelement.id; : cyelement.id;
var curworkflowAction = useworkflow.actions.find( var curworkflowAction = useworkflow.actions.find(
(a) => (a) =>
a !== undefined && a !== undefined &&
(a["id"] === elementid || a["_id"] === elementid) (a["id"] === elementid || a["_id"] === elementid)
); );
if (curworkflowAction === undefined) { if (curworkflowAction === undefined) {
curworkflowAction = cyelements[key].data(); curworkflowAction = cyelements[key].data();
} }
curworkflowAction.position = cyelements[key].position(); curworkflowAction.position = cyelements[key].position();
// workaround to fix some edgecases // workaround to fix some edgecases
if ( if (
curworkflowAction.parameters === "" || curworkflowAction.parameters === "" ||
curworkflowAction.parameters === null curworkflowAction.parameters === null
) { ) {
curworkflowAction.parameters = []; curworkflowAction.parameters = [];
} }
if ( if (
curworkflowAction.example === undefined || curworkflowAction.example === undefined ||
curworkflowAction.example === "" || curworkflowAction.example === "" ||
curworkflowAction.example === null curworkflowAction.example === null
) { ) {
if (cyelements[key].data().example !== undefined) { if (cyelements[key].data().example !== undefined) {
curworkflowAction.example = cyelements[key].data().example; curworkflowAction.example = cyelements[key].data().example;
} }
} }
// Override just in this place // Override just in this place
curworkflowAction.errors = []; curworkflowAction.errors = [];
curworkflowAction.isValid = true; curworkflowAction.isValid = true;
// Cleans up OpenAPI items // Cleans up OpenAPI items
var newparams = []; var newparams = [];
for (var key in curworkflowAction.parameters) { for (var key in curworkflowAction.parameters) {
const thisitem = curworkflowAction.parameters[key]; const thisitem = curworkflowAction.parameters[key];
if (thisitem.name.startsWith("${") && thisitem.name.endsWith("}")) { if (thisitem.name.startsWith("${") && thisitem.name.endsWith("}")) {
continue; continue;
} }
newparams.push(thisitem); newparams.push(thisitem);
} }
curworkflowAction.parameters = newparams; curworkflowAction.parameters = newparams;
newActions.push(curworkflowAction); newActions.push(curworkflowAction);
} else if (type === "TRIGGER") { } else if (type === "TRIGGER") {
var curworkflowTrigger = useworkflow.triggers.find( var curworkflowTrigger = useworkflow.triggers.find(
(a) => a.id === cyelements[key].data()["id"] (a) => a.id === cyelements[key].data()["id"]
); );
if (curworkflowTrigger === undefined) { if (curworkflowTrigger === undefined) {
curworkflowTrigger = cyelements[key].data(); curworkflowTrigger = cyelements[key].data();
} }
curworkflowTrigger.position = cyelements[key].position(); curworkflowTrigger.position = cyelements[key].position();
newTriggers.push(curworkflowTrigger); newTriggers.push(curworkflowTrigger);
} else if (type === "COMMENT") { } else if (type === "COMMENT") {
if (useworkflow.comments === undefined) { if (useworkflow.comments === undefined) {
useworkflow.comments = []; useworkflow.comments = [];
} }
var curworkflowComment = useworkflow.comments.find( var curworkflowComment = useworkflow.comments.find(
(a) => a.id === cyelements[key].data()["id"] (a) => a.id === cyelements[key].data()["id"]
) )
if (curworkflowComment === undefined) { if (curworkflowComment === undefined) {
curworkflowComment = cyelements[key].data(); curworkflowComment = cyelements[key].data();
} }
const parsedHeight = parseInt(curworkflowComment["height"]) const parsedHeight = parseInt(curworkflowComment["height"])
if (!isNaN(parsedHeight)) { if (!isNaN(parsedHeight)) {
curworkflowComment.height = parsedHeight curworkflowComment.height = parsedHeight
} else { } else {
curworkflowComment.width = 150 curworkflowComment.width = 150
} }
const parsedWidth = parseInt(curworkflowComment["width"]) const parsedWidth = parseInt(curworkflowComment["width"])
if (!isNaN(parsedWidth)) { if (!isNaN(parsedWidth)) {
curworkflowComment.width = parsedWidth curworkflowComment.width = parsedWidth
} else { } else {
curworkflowComment.width = 200 curworkflowComment.width = 200
} }
curworkflowComment.position = cyelements[key].position(); curworkflowComment.position = cyelements[key].position();
//console.log(curworkflowComment) //console.log(curworkflowComment)
newComments.push(curworkflowComment); newComments.push(curworkflowComment);
} else { } else {
alert.info("No handler for type: " + type); alert.info("No handler for type: " + type);
} }
} }
} }
useworkflow.actions = newActions; useworkflow.actions = newActions;
useworkflow.triggers = newTriggers; useworkflow.triggers = newTriggers;
useworkflow.branches = newBranches; useworkflow.branches = newBranches;
useworkflow.comments = newComments; useworkflow.comments = newComments;
useworkflow.visual_branches = newVBranches; useworkflow.visual_branches = newVBranches;
// Errors are backend defined // Errors are backend defined
useworkflow.errors = []; useworkflow.errors = [];
useworkflow.previously_saved = true; useworkflow.previously_saved = true;
if (cy !== undefined) { if (cy !== undefined) {
// scale: 0.3, // scale: 0.3,
// bg: "#27292d", // bg: "#27292d",
const cyImageData = cy.png({ const cyImageData = cy.png({
output: "base64uri", output: "base64uri",
maxWidth: 480, maxWidth: 480,
maxHeight: 270, maxHeight: 270,
}) })
console.log("CY: ", cyImageData) if (cyImageData !== undefined && cyImageData !== null && cyImageData.length > 0) {
if (cyImageData !== undefined && cyImageData !== null && cyImageData.length > 0) { useworkflow.image = cyImageData
useworkflow.image = cyImageData }
} }
}
setLastSaved(true); setLastSaved(true);
fetch(globalUrl + "/api/v1/workflows/" + props.match.params.key, { fetch(globalUrl + "/api/v1/workflows/" + props.match.params.key, {
method: "PUT", method: "PUT",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
Accept: "application/json", Accept: "application/json",
}, },
body: JSON.stringify(useworkflow), body: JSON.stringify(useworkflow),
credentials: "include", credentials: "include",
}) })
.then((response) => { .then((response) => {
setSavingState(0); setSavingState(0);
if (response.status !== 200) { if (response.status !== 200) {
console.log("Status not 200 for setting workflows :O!"); console.log("Status not 200 for setting workflows :O!");
} }
return response.json(); return response.json();
}) })
.then((responseJson) => { .then((responseJson) => {
if (executionArgument !== undefined && startNode !== undefined) { if (executionArgument !== undefined && startNode !== undefined) {
//console.log("Running execution AFTER saving"); //console.log("Running execution AFTER saving");
executeWorkflow(executionArgument, startNode, true); executeWorkflow(executionArgument, startNode, true);
return; return;
} }
if (!responseJson.success) { if (!responseJson.success) {
console.log(responseJson); console.log(responseJson);
if (responseJson.reason !== undefined && responseJson.reason !== null) { if (responseJson.reason !== undefined && responseJson.reason !== null) {
alert.error("Failed to save: " + responseJson.reason); alert.error("Failed to save: " + responseJson.reason);
} else { } else {
alert.error("Failed to save. Please contact your admin if this is unexpected.") alert.error("Failed to save. Please contact your admin if this is unexpected.")
} }
} else { } else {
if ( if (
responseJson.new_id !== undefined && responseJson.new_id !== undefined &&
responseJson.new_id !== null responseJson.new_id !== null
) { ) {
window.location.pathname = "/workflows/" + responseJson.new_id; window.location.pathname = "/workflows/" + responseJson.new_id;
} }
success = true; success = true;
if (responseJson.errors !== undefined) { if (responseJson.errors !== undefined) {
workflow.errors = responseJson.errors; workflow.errors = responseJson.errors;
if (responseJson.errors.length === 0) { if (responseJson.errors.length === 0) {
workflow.isValid = true; workflow.isValid = true;
workflow.is_valid = true; workflow.is_valid = true;
const cyelements = cy.elements(); const cyelements = cy.elements();
for (var i = 0; i < cyelements.length; i++) { for (var i = 0; i < cyelements.length; i++) {
cyelements[i].removeStyle(); cyelements[i].removeStyle();
cyelements[i].data().is_valid = true; cyelements[i].data().is_valid = true;
cyelements[i].data().errors = []; cyelements[i].data().errors = [];
} }
for (var key in workflow.actions) { for (var key in workflow.actions) {
workflow.actions[key].is_valid = true; workflow.actions[key].is_valid = true;
workflow.actions[key].errors = []; workflow.actions[key].errors = [];
} }
} }
for (var key in workflow.errors) { for (var key in workflow.errors) {
alert.info(workflow.errors[key]); alert.info(workflow.errors[key]);
} }
setWorkflow(workflow); setWorkflow(workflow);
} }
setSavingState(1); setSavingState(1);
setTimeout(() => { setTimeout(() => {
setSavingState(0); setSavingState(0);
}, 1500); }, 1500);
} }
}) })
.catch((error) => { .catch((error) => {
setSavingState(0); setSavingState(0);
alert.error(error.toString()); alert.error(error.toString());
}); });
return success; return success;
}; };