From 033124b6ecc3ba7795b61c7b8d41a19951be53cc Mon Sep 17 00:00:00 2001 From: frikky Date: Tue, 13 Apr 2021 21:52:32 +0200 Subject: [PATCH] Bugfixes for workflows and executions --- backend/app_sdk/app_base.py | 11 +++++++++-- backend/go-app/go.sum | 2 ++ frontend/src/components/ConfigureWorkflow.jsx | 2 +- frontend/src/views/Admin.jsx | 2 +- frontend/src/views/AngularWorkflow.jsx | 3 +-- frontend/src/views/Apps.jsx | 4 ++-- frontend/src/views/Workflows.jsx | 4 ++-- 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index 29aa07cd..0fd4c9c2 100644 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -1592,16 +1592,15 @@ class AppBase: "matches regex", ] - # FIXME - what should I do here? if not condition["condition"]["value"] in available_checks: self.logger.warning("Skipping %s %s %s because %s is invalid." % (sourcevalue, condition["condition"]["value"], destinationvalue, condition["condition"]["value"])) continue #print(destinationvalue) # NEGATE - validation = run_validation(sourcevalue, condition["condition"]["value"], destinationvalue) # Configuration = negated because of WorkflowAppActionParam.. + validation = run_validation(sourcevalue, condition["condition"]["value"], destinationvalue) try: if condition["condition"]["configuration"]: validation = not validation @@ -1622,6 +1621,14 @@ class AppBase: # THE START IS ACTUALLY RIGHT HERE :O # Checks whether conditions are met, otherwise set branchcheck, tmpresult = check_branch_conditions(action, fullexecution) + if isinstance(tmpresult, object) or isinstance(tmpresult, list): + print("Fixing branch return as object -> string") + try: + tmpresult = tmpresult.replace("'", "\"") + tmpresult = json.dumps(tmpresult) + except json.decoder.JSONDecodeError as e: + print(f"[WARNING] Failed condition parsing {tmpresult} to string") + if not branchcheck: self.logger.info("Failed one or more branch conditions.") action_result["result"] = tmpresult diff --git a/backend/go-app/go.sum b/backend/go-app/go.sum index 1360ecc7..5890f5e5 100644 --- a/backend/go-app/go.sum +++ b/backend/go-app/go.sum @@ -102,6 +102,8 @@ github.com/frikky/shuffle-shared v0.0.23 h1:Pnlc2M6fHnFRLFd5K1iLTVv4/t4P04Ri1GJ5 github.com/frikky/shuffle-shared v0.0.23/go.mod h1:H7SqOta/EAYnfYuWzwzYSh/oWfF0kgnuaJTQNKQBvoQ= github.com/frikky/shuffle-shared v0.0.27 h1:BbibbAv3a5GWR/DfaoSC4D9+fh2cwSEvn9H+EVfd7BM= github.com/frikky/shuffle-shared v0.0.27/go.mod h1:H7SqOta/EAYnfYuWzwzYSh/oWfF0kgnuaJTQNKQBvoQ= +github.com/frikky/shuffle-shared v0.0.28 h1:VQqL3+ePwKSUxCOiCC8DpOEgbb2GhXI8XzFB/YlHbps= +github.com/frikky/shuffle-shared v0.0.28/go.mod h1:H7SqOta/EAYnfYuWzwzYSh/oWfF0kgnuaJTQNKQBvoQ= github.com/getkin/kin-openapi v0.8.0 h1:a6TQjTqwkyscC4/hShJX7WhCVE+4bi9lzw61XHQW5hE= github.com/getkin/kin-openapi v0.8.0/go.mod h1:zZQMFkVgRHCdhgb6ihCTIo9dyDZFvX0k/xAKqw1FhPw= github.com/getkin/kin-openapi v0.52.0 h1:6WqsF5d6PfJ8AscdD+9Rtb2RP2iBWyC7V6GcjssWg7M= diff --git a/frontend/src/components/ConfigureWorkflow.jsx b/frontend/src/components/ConfigureWorkflow.jsx index 5dba1179..215617ab 100644 --- a/frontend/src/components/ConfigureWorkflow.jsx +++ b/frontend/src/components/ConfigureWorkflow.jsx @@ -81,7 +81,7 @@ const Workflow = (props) => { "app": {}, } - const app = apps.find(app => app.name === action.app_name && (app.app_version === action.app_version || app.loop_versions.includes(action.app_version))) + const app = apps.find(app => app.name === action.app_name && (app.app_version === action.app_version || (app.loop_versions !== null && app.loop_versions.includes(action.app_version)))) if (app === undefined || app === null) { console.log("App not found!") diff --git a/frontend/src/views/Admin.jsx b/frontend/src/views/Admin.jsx index 3749f4d0..20a13eda 100644 --- a/frontend/src/views/Admin.jsx +++ b/frontend/src/views/Admin.jsx @@ -1111,7 +1111,7 @@ const Admin = (props) => { const generateApikey = (user) => { - const userId = isCloud ? user.username : user.id + const userId = user.id const data = { "user_id": userId } fetch(globalUrl + "/api/v1/generateapikey", { diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index 9b018e62..40d89fb4 100644 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -1326,8 +1326,7 @@ const AngularWorkflow = (props) => { return } - //console.log(apps) - const curapp = apps.find(a => a.name === curaction.app_name && (a.app_version === curaction.app_version || a.loop_versions.includes(curaction.app_version))) + const curapp = apps.find(a => a.name === curaction.app_name && ((a.app_version === curaction.app_version || (a.loop_versions !== null && a.loop_versions.includes(curaction.app_version))))) if (!curapp || curapp === undefined) { alert.error(`App ${curaction.app_name}:${curaction.app_version} not found. Is it activated?`) diff --git a/frontend/src/views/Apps.jsx b/frontend/src/views/Apps.jsx index d13c068a..bd344504 100644 --- a/frontend/src/views/Apps.jsx +++ b/frontend/src/views/Apps.jsx @@ -1461,7 +1461,7 @@ const Apps = (props) => { style={{backgroundColor: inputColor}} variant="outlined" margin="normal" - defaultValue={userdata.active_org.defaults.app_download_repo !== undefined && userdata.active_org.defaults.app_download_repo.length > 0 ? userdata.active_org.defaults.app_download_repo : "https://github.com/frikky/shuffle-apps"} + defaultValue={"https://github.com/frikky/shuffle-apps"} InputProps={{ style:{ color: "white", @@ -1479,7 +1479,7 @@ const Apps = (props) => { style={{backgroundColor: inputColor}} variant="outlined" margin="normal" - defaultValue={userdata.active_org.defaults.app_download_branch !== undefined && userdata.active_org.defaults.app_download_branch.length > 0 ? userdata.active_org.defaults.app_download_branch : downloadBranch} + defaultValue={downloadBranch} InputProps={{ style:{ color: "white", diff --git a/frontend/src/views/Workflows.jsx b/frontend/src/views/Workflows.jsx index bfca455f..d21af19a 100644 --- a/frontend/src/views/Workflows.jsx +++ b/frontend/src/views/Workflows.jsx @@ -1802,7 +1802,7 @@ const Workflows = (props) => { style={{backgroundColor: inputColor}} variant="outlined" margin="normal" - defaultValue={userdata.active_org.defaults.workflow_download_repo !== undefined && userdata.active_org.defaults.workflow_download_repo.length > 0 ? userdata.active_org.defaults.workflow_download_repo : downloadUrl} + defaultValue={downloadUrl} InputProps={{ style:{ color: "white", @@ -1821,7 +1821,7 @@ const Workflows = (props) => { style={{backgroundColor: inputColor}} variant="outlined" margin="normal" - defaultValue={userdata.active_org.defaults.workflow_download_branch !== undefined && userdata.active_org.defaults.workflow_download_branch.length > 0 ? userdata.active_org.defaults.workflow_download_branch : downloadBranch} + defaultValue={downloadBranch} InputProps={{ style:{ color: "white",