#222: Fixed bug where copy workflow doesn't copy everything
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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 (
|
||||
<div style={{marginTop: "30px"}}>
|
||||
<b>Arguments</b>
|
||||
<b>Parameters</b>
|
||||
{selectedActionParameters.map((data, count) => {
|
||||
if (data.variant === "") {
|
||||
data.variant = "STATIC_VALUE"
|
||||
@@ -4518,11 +4522,6 @@ const AngularWorkflow = (props) => {
|
||||
setConditionValue(conditionValue)
|
||||
setVariableAnchorEl(null)
|
||||
}} key={"ends with"}>ends with</MenuItem>
|
||||
<MenuItem style={menuItemStyle} onClick={(e) => {
|
||||
conditionValue.value = "endswith"
|
||||
setConditionValue(conditionValue)
|
||||
setVariableAnchorEl(null)
|
||||
}} key={"ends with"}>ends with</MenuItem>
|
||||
<MenuItem style={menuItemStyle} onClick={(e) => {
|
||||
conditionValue.value = "contains"
|
||||
setConditionValue(conditionValue)
|
||||
@@ -5017,11 +5016,11 @@ const AngularWorkflow = (props) => {
|
||||
workflow.triggers[selectedTriggerIndex].parameters[1] = {"name": "argument", "value": ""}
|
||||
workflow.triggers[selectedTriggerIndex].parameters[2] = {"name": "user_apikey", "value": ""}
|
||||
|
||||
console.log(userSettings)
|
||||
console.log("SETTINGS: ", userSettings)
|
||||
if (userSettings !== undefined && userSettings !== null && userSettings.apikey !== null && userSettings.apikey !== undefined && userSettings.apikey.length > 0) {
|
||||
workflow.triggers[selectedTriggerIndex].parameters[2] = {"name": "user_apikey", "value": userSettings.apikey}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(
|
||||
<div style={appApiViewStyle}>
|
||||
@@ -5054,7 +5053,7 @@ const AngularWorkflow = (props) => {
|
||||
<Divider style={{marginTop: "20px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
|
||||
<div style={{flex: "6", marginTop: "20px"}}>
|
||||
<div>
|
||||
<b>Arguments</b>
|
||||
<b>Parameters</b>
|
||||
<div style={{marginTop: "20px", marginBottom: "7px", display: "flex"}}>
|
||||
<div style={{width: "17px", height: "17px", borderRadius: 17 / 2, backgroundColor: "#f85a3e", marginRight: "10px"}}/>
|
||||
<div style={{flex: "10"}}>
|
||||
@@ -5121,6 +5120,32 @@ const AngularWorkflow = (props) => {
|
||||
setWorkflow(workflow)
|
||||
}}
|
||||
/>
|
||||
<div style={{marginTop: "20px", marginBottom: "7px", display: "flex"}}>
|
||||
<div style={{width: "17px", height: "17px", borderRadius: 17 / 2, backgroundColor: "#f85a3e", marginRight: "10px"}}/>
|
||||
<div style={{flex: "10"}}>
|
||||
<b>API-key: </b>
|
||||
</div>
|
||||
</div>
|
||||
<TextField
|
||||
style={{backgroundColor: inputColor, borderRadius: borderRadius,}}
|
||||
InputProps={{
|
||||
style:{
|
||||
color: "white",
|
||||
marginLeft: "5px",
|
||||
maxWidth: "95%",
|
||||
fontSize: "1em",
|
||||
height: 50,
|
||||
},
|
||||
}}
|
||||
fullWidth
|
||||
color="primary"
|
||||
placeholder="Your apikey"
|
||||
defaultValue={workflow.triggers[selectedTriggerIndex].parameters[2].value}
|
||||
onBlur={(e) => {
|
||||
workflow.triggers[selectedTriggerIndex].parameters[2].value = e.target.value
|
||||
setWorkflow(workflow)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -5222,18 +5247,25 @@ const AngularWorkflow = (props) => {
|
||||
<Divider style={{marginTop: "20px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
|
||||
<div style={{flex: "6", marginTop: "20px"}}>
|
||||
<div>
|
||||
<b>Arguments</b>
|
||||
<b>Parameters</b>
|
||||
<div style={{marginTop: "20px", marginBottom: "7px", display: "flex"}}>
|
||||
<div style={{width: "17px", height: "17px", borderRadius: 17 / 2, backgroundColor: "#f85a3e", marginRight: "10px"}}/>
|
||||
<div style={{flex: "10"}}>
|
||||
<b>Webhook URI: </b>
|
||||
<b>Webhook URI </b>
|
||||
</div>
|
||||
</div>
|
||||
<TextField
|
||||
style={{backgroundColor: inputColor, borderRadius: borderRadius,}}
|
||||
id="webhook_uri_field"
|
||||
onClick={() => {
|
||||
//alert.info("Saved URI to clipboard")
|
||||
console.log("Copy to clipboooooard")
|
||||
var copyText = document.getElementById("webhook_uri_field");
|
||||
navigator.clipboard.writeText(copyText.value)
|
||||
copyText.select();
|
||||
copyText.setSelectionRange(0, 99999); /* For mobile devices */
|
||||
|
||||
/* Copy the text inside the text field */
|
||||
document.execCommand("copy");
|
||||
alert.success("Copied Webhook URL")
|
||||
}}
|
||||
InputProps={{
|
||||
style:{
|
||||
@@ -5557,7 +5589,7 @@ const AngularWorkflow = (props) => {
|
||||
</div>
|
||||
<Divider style={{marginTop: "20px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
|
||||
<div style={{flex: "6", marginTop: "20px"}}>
|
||||
<b>Arguments</b>
|
||||
<b>Parameters</b>
|
||||
<div style={{marginTop: "20px", marginBottom: "7px", display: "flex"}}>
|
||||
<div style={{width: "17px", height: "17px", borderRadius: 17 / 2, backgroundColor: "#f85a3e", marginRight: "10px"}}/>
|
||||
<div style={{flex: "10"}}>
|
||||
@@ -5679,7 +5711,7 @@ const AngularWorkflow = (props) => {
|
||||
if (Object.getOwnPropertyNames(selectedTrigger).length > 0 && workflow.triggers[selectedTriggerIndex] !== undefined) {
|
||||
if (workflow.triggers[selectedTriggerIndex].parameters === undefined || workflow.triggers[selectedTriggerIndex].parameters === null || workflow.triggers[selectedTriggerIndex].parameters.length === 0) {
|
||||
workflow.triggers[selectedTriggerIndex].parameters = []
|
||||
workflow.triggers[selectedTriggerIndex].parameters[0] = {"name": "cron", "value": "*/2 * * * *"}
|
||||
workflow.triggers[selectedTriggerIndex].parameters[0] = {"name": "cron", "value": "120"}
|
||||
workflow.triggers[selectedTriggerIndex].parameters[1] = {"name": "execution_argument", "value": '{"example": {"json": "is cool"}}'}
|
||||
setWorkflow(workflow)
|
||||
}
|
||||
@@ -5766,7 +5798,7 @@ const AngularWorkflow = (props) => {
|
||||
<Divider style={{marginTop: "20px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
|
||||
<div style={{flex: "6", marginTop: "20px"}}>
|
||||
<div>
|
||||
<b>Arguments</b>
|
||||
<b>Parameters</b>
|
||||
<div style={{marginTop: "20px", marginBottom: "7px", display: "flex"}}>
|
||||
<div style={{width: "17px", height: "17px", borderRadius: 17 / 2, backgroundColor: "#f85a3e", marginRight: "10px"}}/>
|
||||
<div style={{flex: "10"}}>
|
||||
|
||||
@@ -704,7 +704,7 @@ const Apps = (props) => {
|
||||
|
||||
{selectedAction.parameters !== undefined && selectedAction.parameters !== null ?
|
||||
<div style={{marginTop: 15, marginBottom: 15}}>
|
||||
<b>Arguments</b>
|
||||
<b>Parameters</b>
|
||||
{selectedAction.parameters.map(data => {
|
||||
var itemColor = "#f85a3e"
|
||||
if (!data.required) {
|
||||
|
||||
Reference in New Issue
Block a user