diff --git a/backend/go-app/walkoff.go b/backend/go-app/walkoff.go index 4d7eab27..a47a6506 100644 --- a/backend/go-app/walkoff.go +++ b/backend/go-app/walkoff.go @@ -1638,13 +1638,13 @@ func setNewWorkflow(resp http.ResponseWriter, request *http.Request) { user.ActiveOrg.Users = []User{} workflow.ExecutingOrg = user.ActiveOrg workflow.OrgId = user.ActiveOrg.Id + log.Printf("TRIGGERS: %d", len(workflow.Triggers)) ctx := context.Background() - log.Printf("Saved new workflow %s with name %s", workflow.ID, workflow.Name) - err = increaseStatisticsField(ctx, "total_workflows", workflow.ID, 1, workflow.OrgId) - if err != nil { - log.Printf("Failed to increase total workflows stats: %s", err) - } + //err = increaseStatisticsField(ctx, "total_workflows", workflow.ID, 1, workflow.OrgId) + //if err != nil { + // log.Printf("Failed to increase total workflows stats: %s", err) + //} if len(workflow.Actions) == 0 { workflow.Actions = []Action{} @@ -1724,14 +1724,56 @@ func setNewWorkflow(resp http.ResponseWriter, request *http.Request) { workflow.Actions = []Action{} for _, item := range workflow.Actions { + oldId := item.ID + sourceIndexes := []int{} + destinationIndexes := []int{} + for branchIndex, branch := range workflow.Branches { + if branch.SourceID == oldId { + sourceIndexes = append(sourceIndexes, branchIndex) + } + + if branch.DestinationID == oldId { + destinationIndexes = append(destinationIndexes, branchIndex) + } + } + item.ID = uuid.NewV4().String() + for _, index := range sourceIndexes { + workflow.Branches[index].SourceID = item.ID + } + + for _, index := range destinationIndexes { + workflow.Branches[index].DestinationID = item.ID + } + newActions = append(newActions, item) } newTriggers := []Trigger{} for _, item := range workflow.Triggers { - item.Status = "uninitialized" + oldId := item.ID + sourceIndexes := []int{} + destinationIndexes := []int{} + for branchIndex, branch := range workflow.Branches { + if branch.SourceID == oldId { + sourceIndexes = append(sourceIndexes, branchIndex) + } + + if branch.DestinationID == oldId { + destinationIndexes = append(destinationIndexes, branchIndex) + } + } + item.ID = uuid.NewV4().String() + for _, index := range sourceIndexes { + workflow.Branches[index].SourceID = item.ID + } + + for _, index := range destinationIndexes { + workflow.Branches[index].DestinationID = item.ID + } + + item.Status = "uninitialized" newTriggers = append(newTriggers, item) } @@ -1765,6 +1807,7 @@ func setNewWorkflow(resp http.ResponseWriter, request *http.Request) { return } + log.Printf("Saved new workflow %s with name %s", workflow.ID, workflow.Name) //memcacheName := fmt.Sprintf("%s_workflows", user.Username) //memcache.Delete(ctx, memcacheName) diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index d9558537..d5480ac3 100644 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -251,14 +251,16 @@ const AngularWorkflow = (props) => { if (responseJson !== undefined) { setWorkflows(responseJson) - const trigger = workflow.triggers[trigger_index] - if (trigger.parameters.length >= 3) { - for (var key in trigger.parameters) { - const param = trigger.parameters[key] - if (param.name === "workflow") { - const sub = responseJson.find(data => data.id === param.value) - if (sub !== undefined && subworkflow.id !== sub.id) { - setSubworkflow(sub) + if (trigger_index > -1) { + const trigger = workflow.triggers[trigger_index] + if (trigger.parameters.length >= 3) { + for (var key in trigger.parameters) { + const param = trigger.parameters[key] + if (param.name === "workflow") { + const sub = responseJson.find(data => data.id === param.value) + if (sub !== undefined && subworkflow.id !== sub.id) { + setSubworkflow(sub) + } } } } @@ -1517,6 +1519,8 @@ const AngularWorkflow = (props) => { getAppAuthentication() getEnvironments() getWorkflowExecution(props.match.params.key) + getAvailableWorkflows(-1) + getSettings() return } @@ -3034,7 +3038,7 @@ const AngularWorkflow = (props) => { if (Object.getOwnPropertyNames(selectedAction).length > 0 && selectedActionParameters.length > 0) { return (