From 8cfba1ac306b93d264d8032e4e259af55daf7c83 Mon Sep 17 00:00:00 2001 From: Frikky Date: Mon, 18 Dec 2023 13:40:39 +0100 Subject: [PATCH] Added App Auth name editing and dynamic auth during workflow run --- backend/go-app/go.mod | 2 +- backend/go-app/go.sum | 2 + frontend/src/views/Admin.jsx | 67 ++++++++++++++++++++++---- frontend/src/views/AngularWorkflow.jsx | 1 + 4 files changed, 61 insertions(+), 11 deletions(-) diff --git a/backend/go-app/go.mod b/backend/go-app/go.mod index 82995baa..056ab254 100644 --- a/backend/go-app/go.mod +++ b/backend/go-app/go.mod @@ -18,7 +18,7 @@ require ( github.com/gorilla/mux v1.8.0 github.com/h2non/filetype v1.1.3 github.com/satori/go.uuid v1.2.0 - github.com/shuffle/shuffle-shared v0.5.31 + github.com/shuffle/shuffle-shared v0.5.44 golang.org/x/crypto v0.14.0 google.golang.org/api v0.125.0 google.golang.org/grpc v1.55.0 diff --git a/backend/go-app/go.sum b/backend/go-app/go.sum index 3f77bb07..0358ac5c 100644 --- a/backend/go-app/go.sum +++ b/backend/go-app/go.sum @@ -426,6 +426,8 @@ github.com/shuffle/shuffle-shared v0.5.30 h1:ORWjQU3UJhdZY5mRsAoR2hvftNcJmiEekNK github.com/shuffle/shuffle-shared v0.5.30/go.mod h1:X613gbo0dT3fnYvXDRwjQZyLC+T49T2nSQOrCV5QMlI= github.com/shuffle/shuffle-shared v0.5.31 h1:OV4IIfKWWFW66WjGvyXOmmsSz3p8pW9L1ge1mDo8ftM= github.com/shuffle/shuffle-shared v0.5.31/go.mod h1:X613gbo0dT3fnYvXDRwjQZyLC+T49T2nSQOrCV5QMlI= +github.com/shuffle/shuffle-shared v0.5.44 h1:6WiFPIsij+IWvXY7vzVX7cUicb+PYOzhTbWF/gDmYeU= +github.com/shuffle/shuffle-shared v0.5.44/go.mod h1:X613gbo0dT3fnYvXDRwjQZyLC+T49T2nSQOrCV5QMlI= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= diff --git a/frontend/src/views/Admin.jsx b/frontend/src/views/Admin.jsx index 9a7884b0..7663aa70 100755 --- a/frontend/src/views/Admin.jsx +++ b/frontend/src/views/Admin.jsx @@ -748,11 +748,20 @@ If you're interested, please let me know a time that works for you, or set up a .then((response) => response.json().then((responseJson) => { if (responseJson["success"] === false) { - toast("Failed changing authentication"); + // Check if .reason exists + if (responseJson.reason !== undefined) { + toast("Failed changing authentication: " + responseJson.reason); + } else { + toast("Failed changing authentication"); + } } else { //toast("Successfully password!") setSelectedUserModalOpen(false); getAppAuthentication(); + + + setSelectedAuthentication({}); + setSelectedAuthenticationModalOpen(false); } }) ) @@ -813,7 +822,8 @@ If you're interested, please let me know a time that works for you, or set up a const data = { id: id, action: parentAction !== undefined && parentAction !== null ? parentAction : "assign_everywhere", - }; + } + const url = globalUrl + "/api/v1/apps/authentication/" + id + "/config"; fetch(url, { @@ -1798,17 +1808,53 @@ If you're interested, please let me know a time that works for you, or set up a > - Edit authentication for {selectedAuthentication.app.name} ( + Edit authentication for {selectedAuthentication.app.name.replaceAll("_", " ")} ( {selectedAuthentication.label}) + + You can not see the previous values for an authentication while editing. This is to keep your data secure. You can overwrite one- or multiple fields at a time. + + + Authentication Label + + { + selectedAuthentication.label = e.target.value + }} + /> + + {selectedAuthentication.fields.map((data, index) => { + var fieldname = data.key.replaceAll("_", " ") + if (fieldname.endsWith(" basic")) { + fieldname = fieldname.substring(0, fieldname.length - 6) + } + //console.log("DATA: ", data, selectedAuthentication) return (
- {data.key} + {fieldname} { var error = false; + var fails = 0 for (var key in authenticationFields) { const item = authenticationFields[key]; if (item.value.length === 0) { + fails += 1 console.log("ITEM: ", item); //var currentnode = cy.getElementById(data.id) var textfield = document.getElementById( @@ -1866,14 +1914,13 @@ If you're interested, please let me know a time that works for you, or set up a } } - if (error) { - toast("All fields must have a new value"); + if (error && fails === authenticationFields.length) { + toast("Updating auth with new name only") + saveAuthentication(selectedAuthentication); } else { toast("Saving new version of this authentication"); selectedAuthentication.fields = authenticationFields; saveAuthentication(selectedAuthentication); - setSelectedAuthentication({}); - setSelectedAuthenticationModalOpen(false); } }} color="primary" @@ -3732,7 +3779,7 @@ If you're interested, please let me know a time that works for you, or set up a }} /> {/* diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index 53a43232..9ccbd3c5 100755 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -1824,6 +1824,7 @@ const AngularWorkflow = (defaultprops) => { setExecutionModalOpen(true); setExecutionModalView(1); start(); + navigate(`/workflows/${props.match.params.key}?execution_id=${responseJson.execution_id}`) }) .catch((error) => { //toast(error.toString());