#223: Added import and export protections for subflow

This commit is contained in:
frikky
2021-01-22 13:55:04 +01:00
parent 09002f4aa3
commit 73b7469107
2 changed files with 50 additions and 14 deletions
+32 -7
View File
@@ -2332,15 +2332,40 @@ func saveWorkflow(resp http.ResponseWriter, request *http.Request) {
trigger.Status = "stopped" trigger.Status = "stopped"
} }
} else if trigger.TriggerType == "SUBFLOW" { } else if trigger.TriggerType == "SUBFLOW" {
for _, param := range trigger.Parameters { for index, param := range trigger.Parameters {
if len(param.Value) == 0 && param.Name != "argument" { if len(param.Value) == 0 && param.Name != "argument" {
workflow.IsValid = false log.Printf("Param: %#v", param)
workflow.Errors = []string{"Trigger is missing a parameter: %s", param.Name} if param.Name == "user_apikey" {
apikey := ""
if len(user.ApiKey) > 0 {
apikey = user.ApiKey
} else {
user, err = generateApikey(ctx, user)
if err != nil {
workflow.IsValid = false
workflow.Errors = []string{"Trigger is missing a parameter: %s", param.Name}
log.Printf("No type specified for user input node") log.Printf("No type specified for user input node")
resp.WriteHeader(401) resp.WriteHeader(401)
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Trigger %s is missing the parameter %s"}`, trigger.Label, param.Name))) resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Trigger %s is missing the parameter %s"}`, trigger.Label, param.Name)))
return return
}
apikey = user.ApiKey
}
log.Printf("[INFO] Set apikey in subflow trigger for user during save")
trigger.Parameters[index].Value = apikey
} else {
workflow.IsValid = false
workflow.Errors = []string{"Trigger is missing a parameter: %s", param.Name}
log.Printf("No type specified for user input node")
resp.WriteHeader(401)
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Trigger %s is missing the parameter %s"}`, trigger.Label, param.Name)))
return
}
} }
} }
} else if trigger.TriggerType == "WEBHOOK" && trigger.Status != "uninitialized" { } else if trigger.TriggerType == "WEBHOOK" && trigger.Status != "uninitialized" {
+18 -7
View File
@@ -234,8 +234,8 @@ const Workflows = (props) => {
color: "#ffffff", color: "#ffffff",
width: "100%", width: "100%",
display: "flex", display: "flex",
minWidth: 1366, minWidth: 1024,
maxWidth: 1766, maxWidth: 1024,
margin: "auto", margin: "auto",
maxHeight: "90vh", maxHeight: "90vh",
} }
@@ -393,8 +393,15 @@ const Workflows = (props) => {
data["owner"] = "" data["owner"] = ""
for (var key in data.triggers) { for (var key in data.triggers) {
if (data.triggers[key].status == "running") { const trigger = data.triggers[key]
data.triggers[key].status = "stopped" if (trigger.app_name === "Shuffle Workflow") {
if (trigger.parameters.length > 2) {
trigger.parameters[2].value = ""
}
}
if (trigger.status == "running") {
trigger.status = "stopped"
} }
} }
@@ -402,6 +409,8 @@ const Workflows = (props) => {
data.actions[key].authentication_id = "" data.actions[key].authentication_id = ""
} }
//return
data["org"] = [] data["org"] = []
data["org_id"] = "" data["org_id"] = ""
data.execution_org = {"id": ""} data.execution_org = {"id": ""}
@@ -907,7 +916,7 @@ const Workflows = (props) => {
</div> </div>
: :
<h4> <h4>
Executions have been moved to the Workflow itself. <Link to={`/workflows/${selectedWorkflow.id}?view=executions`} style={{textDecoration: "none", color: "#f85a3e"}}>Click here to see them</Link> Executions have been moved to the Workflow itself. <div/><Link to={`/workflows/${selectedWorkflow.id}?view=executions`} style={{textDecoration: "none", color: "#f85a3e"}}>Click here to see them</Link>
</h4> </h4>
) )
} }
@@ -1230,10 +1239,11 @@ const Workflows = (props) => {
</div> </div>
<div style={{flex: viewSize.executionsView, marginLeft: "10px", marginRight: "10px"}}> <div style={{flex: viewSize.executionsView, marginLeft: "10px", marginRight: "10px"}}>
<div style={{display: "flex"}}> <div style={{display: "flex"}}>
<div style={{flex: "10"}}> <div style={{flex: 10}}>
<h2>Executions: {selectedWorkflow.name}</h2> <h2>Executions: {selectedWorkflow.name}</h2>
</div> </div>
<div style={{flex: "1"}}> {/*
<div style={{flex: 1}}>
<Button color="primary" style={{marginTop: "20px"}} variant="text" onClick={() => { <Button color="primary" style={{marginTop: "20px"}} variant="text" onClick={() => {
alert.info("Refreshing executions"); alert.info("Refreshing executions");
//getWorkflowExecution(selectedWorkflow.id) //getWorkflowExecution(selectedWorkflow.id)
@@ -1241,6 +1251,7 @@ const Workflows = (props) => {
<CachedIcon /> <CachedIcon />
</Button> </Button>
</div> </div>
*/}
</div> </div>
<Divider style={{marginBottom: "10px", height: "1px", width: "100%", backgroundColor: dividerColor}}/> <Divider style={{marginBottom: "10px", height: "1px", width: "100%", backgroundColor: dividerColor}}/>
<div style={scrollStyle}> <div style={scrollStyle}>