#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{}
|
user.ActiveOrg.Users = []User{}
|
||||||
workflow.ExecutingOrg = user.ActiveOrg
|
workflow.ExecutingOrg = user.ActiveOrg
|
||||||
workflow.OrgId = user.ActiveOrg.Id
|
workflow.OrgId = user.ActiveOrg.Id
|
||||||
|
log.Printf("TRIGGERS: %d", len(workflow.Triggers))
|
||||||
|
|
||||||
ctx := context.Background()
|
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)
|
||||||
err = increaseStatisticsField(ctx, "total_workflows", workflow.ID, 1, workflow.OrgId)
|
//if err != nil {
|
||||||
if err != nil {
|
// log.Printf("Failed to increase total workflows stats: %s", err)
|
||||||
log.Printf("Failed to increase total workflows stats: %s", err)
|
//}
|
||||||
}
|
|
||||||
|
|
||||||
if len(workflow.Actions) == 0 {
|
if len(workflow.Actions) == 0 {
|
||||||
workflow.Actions = []Action{}
|
workflow.Actions = []Action{}
|
||||||
@@ -1724,14 +1724,56 @@ func setNewWorkflow(resp http.ResponseWriter, request *http.Request) {
|
|||||||
|
|
||||||
workflow.Actions = []Action{}
|
workflow.Actions = []Action{}
|
||||||
for _, item := range workflow.Actions {
|
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()
|
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)
|
newActions = append(newActions, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
newTriggers := []Trigger{}
|
newTriggers := []Trigger{}
|
||||||
for _, item := range workflow.Triggers {
|
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()
|
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)
|
newTriggers = append(newTriggers, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1765,6 +1807,7 @@ func setNewWorkflow(resp http.ResponseWriter, request *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Printf("Saved new workflow %s with name %s", workflow.ID, workflow.Name)
|
||||||
//memcacheName := fmt.Sprintf("%s_workflows", user.Username)
|
//memcacheName := fmt.Sprintf("%s_workflows", user.Username)
|
||||||
//memcache.Delete(ctx, memcacheName)
|
//memcache.Delete(ctx, memcacheName)
|
||||||
|
|
||||||
|
|||||||
@@ -251,14 +251,16 @@ const AngularWorkflow = (props) => {
|
|||||||
if (responseJson !== undefined) {
|
if (responseJson !== undefined) {
|
||||||
setWorkflows(responseJson)
|
setWorkflows(responseJson)
|
||||||
|
|
||||||
const trigger = workflow.triggers[trigger_index]
|
if (trigger_index > -1) {
|
||||||
if (trigger.parameters.length >= 3) {
|
const trigger = workflow.triggers[trigger_index]
|
||||||
for (var key in trigger.parameters) {
|
if (trigger.parameters.length >= 3) {
|
||||||
const param = trigger.parameters[key]
|
for (var key in trigger.parameters) {
|
||||||
if (param.name === "workflow") {
|
const param = trigger.parameters[key]
|
||||||
const sub = responseJson.find(data => data.id === param.value)
|
if (param.name === "workflow") {
|
||||||
if (sub !== undefined && subworkflow.id !== sub.id) {
|
const sub = responseJson.find(data => data.id === param.value)
|
||||||
setSubworkflow(sub)
|
if (sub !== undefined && subworkflow.id !== sub.id) {
|
||||||
|
setSubworkflow(sub)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1517,6 +1519,8 @@ const AngularWorkflow = (props) => {
|
|||||||
getAppAuthentication()
|
getAppAuthentication()
|
||||||
getEnvironments()
|
getEnvironments()
|
||||||
getWorkflowExecution(props.match.params.key)
|
getWorkflowExecution(props.match.params.key)
|
||||||
|
getAvailableWorkflows(-1)
|
||||||
|
getSettings()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3034,7 +3038,7 @@ const AngularWorkflow = (props) => {
|
|||||||
if (Object.getOwnPropertyNames(selectedAction).length > 0 && selectedActionParameters.length > 0) {
|
if (Object.getOwnPropertyNames(selectedAction).length > 0 && selectedActionParameters.length > 0) {
|
||||||
return (
|
return (
|
||||||
<div style={{marginTop: "30px"}}>
|
<div style={{marginTop: "30px"}}>
|
||||||
<b>Arguments</b>
|
<b>Parameters</b>
|
||||||
{selectedActionParameters.map((data, count) => {
|
{selectedActionParameters.map((data, count) => {
|
||||||
if (data.variant === "") {
|
if (data.variant === "") {
|
||||||
data.variant = "STATIC_VALUE"
|
data.variant = "STATIC_VALUE"
|
||||||
@@ -4518,11 +4522,6 @@ const AngularWorkflow = (props) => {
|
|||||||
setConditionValue(conditionValue)
|
setConditionValue(conditionValue)
|
||||||
setVariableAnchorEl(null)
|
setVariableAnchorEl(null)
|
||||||
}} key={"ends with"}>ends with</MenuItem>
|
}} 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) => {
|
<MenuItem style={menuItemStyle} onClick={(e) => {
|
||||||
conditionValue.value = "contains"
|
conditionValue.value = "contains"
|
||||||
setConditionValue(conditionValue)
|
setConditionValue(conditionValue)
|
||||||
@@ -5017,11 +5016,11 @@ const AngularWorkflow = (props) => {
|
|||||||
workflow.triggers[selectedTriggerIndex].parameters[1] = {"name": "argument", "value": ""}
|
workflow.triggers[selectedTriggerIndex].parameters[1] = {"name": "argument", "value": ""}
|
||||||
workflow.triggers[selectedTriggerIndex].parameters[2] = {"name": "user_apikey", "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) {
|
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}
|
workflow.triggers[selectedTriggerIndex].parameters[2] = {"name": "user_apikey", "value": userSettings.apikey}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<div style={appApiViewStyle}>
|
<div style={appApiViewStyle}>
|
||||||
@@ -5054,7 +5053,7 @@ const AngularWorkflow = (props) => {
|
|||||||
<Divider style={{marginTop: "20px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
|
<Divider style={{marginTop: "20px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
|
||||||
<div style={{flex: "6", marginTop: "20px"}}>
|
<div style={{flex: "6", marginTop: "20px"}}>
|
||||||
<div>
|
<div>
|
||||||
<b>Arguments</b>
|
<b>Parameters</b>
|
||||||
<div style={{marginTop: "20px", marginBottom: "7px", display: "flex"}}>
|
<div style={{marginTop: "20px", marginBottom: "7px", display: "flex"}}>
|
||||||
<div style={{width: "17px", height: "17px", borderRadius: 17 / 2, backgroundColor: "#f85a3e", marginRight: "10px"}}/>
|
<div style={{width: "17px", height: "17px", borderRadius: 17 / 2, backgroundColor: "#f85a3e", marginRight: "10px"}}/>
|
||||||
<div style={{flex: "10"}}>
|
<div style={{flex: "10"}}>
|
||||||
@@ -5121,6 +5120,32 @@ const AngularWorkflow = (props) => {
|
|||||||
setWorkflow(workflow)
|
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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -5222,18 +5247,25 @@ const AngularWorkflow = (props) => {
|
|||||||
<Divider style={{marginTop: "20px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
|
<Divider style={{marginTop: "20px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
|
||||||
<div style={{flex: "6", marginTop: "20px"}}>
|
<div style={{flex: "6", marginTop: "20px"}}>
|
||||||
<div>
|
<div>
|
||||||
<b>Arguments</b>
|
<b>Parameters</b>
|
||||||
<div style={{marginTop: "20px", marginBottom: "7px", display: "flex"}}>
|
<div style={{marginTop: "20px", marginBottom: "7px", display: "flex"}}>
|
||||||
<div style={{width: "17px", height: "17px", borderRadius: 17 / 2, backgroundColor: "#f85a3e", marginRight: "10px"}}/>
|
<div style={{width: "17px", height: "17px", borderRadius: 17 / 2, backgroundColor: "#f85a3e", marginRight: "10px"}}/>
|
||||||
<div style={{flex: "10"}}>
|
<div style={{flex: "10"}}>
|
||||||
<b>Webhook URI: </b>
|
<b>Webhook URI </b>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<TextField
|
<TextField
|
||||||
style={{backgroundColor: inputColor, borderRadius: borderRadius,}}
|
style={{backgroundColor: inputColor, borderRadius: borderRadius,}}
|
||||||
|
id="webhook_uri_field"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
//alert.info("Saved URI to clipboard")
|
var copyText = document.getElementById("webhook_uri_field");
|
||||||
console.log("Copy to clipboooooard")
|
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={{
|
InputProps={{
|
||||||
style:{
|
style:{
|
||||||
@@ -5557,7 +5589,7 @@ const AngularWorkflow = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
<Divider style={{marginTop: "20px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
|
<Divider style={{marginTop: "20px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
|
||||||
<div style={{flex: "6", marginTop: "20px"}}>
|
<div style={{flex: "6", marginTop: "20px"}}>
|
||||||
<b>Arguments</b>
|
<b>Parameters</b>
|
||||||
<div style={{marginTop: "20px", marginBottom: "7px", display: "flex"}}>
|
<div style={{marginTop: "20px", marginBottom: "7px", display: "flex"}}>
|
||||||
<div style={{width: "17px", height: "17px", borderRadius: 17 / 2, backgroundColor: "#f85a3e", marginRight: "10px"}}/>
|
<div style={{width: "17px", height: "17px", borderRadius: 17 / 2, backgroundColor: "#f85a3e", marginRight: "10px"}}/>
|
||||||
<div style={{flex: "10"}}>
|
<div style={{flex: "10"}}>
|
||||||
@@ -5679,7 +5711,7 @@ const AngularWorkflow = (props) => {
|
|||||||
if (Object.getOwnPropertyNames(selectedTrigger).length > 0 && workflow.triggers[selectedTriggerIndex] !== undefined) {
|
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) {
|
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 = []
|
||||||
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"}}'}
|
workflow.triggers[selectedTriggerIndex].parameters[1] = {"name": "execution_argument", "value": '{"example": {"json": "is cool"}}'}
|
||||||
setWorkflow(workflow)
|
setWorkflow(workflow)
|
||||||
}
|
}
|
||||||
@@ -5766,7 +5798,7 @@ const AngularWorkflow = (props) => {
|
|||||||
<Divider style={{marginTop: "20px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
|
<Divider style={{marginTop: "20px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
|
||||||
<div style={{flex: "6", marginTop: "20px"}}>
|
<div style={{flex: "6", marginTop: "20px"}}>
|
||||||
<div>
|
<div>
|
||||||
<b>Arguments</b>
|
<b>Parameters</b>
|
||||||
<div style={{marginTop: "20px", marginBottom: "7px", display: "flex"}}>
|
<div style={{marginTop: "20px", marginBottom: "7px", display: "flex"}}>
|
||||||
<div style={{width: "17px", height: "17px", borderRadius: 17 / 2, backgroundColor: "#f85a3e", marginRight: "10px"}}/>
|
<div style={{width: "17px", height: "17px", borderRadius: 17 / 2, backgroundColor: "#f85a3e", marginRight: "10px"}}/>
|
||||||
<div style={{flex: "10"}}>
|
<div style={{flex: "10"}}>
|
||||||
|
|||||||
@@ -704,7 +704,7 @@ const Apps = (props) => {
|
|||||||
|
|
||||||
{selectedAction.parameters !== undefined && selectedAction.parameters !== null ?
|
{selectedAction.parameters !== undefined && selectedAction.parameters !== null ?
|
||||||
<div style={{marginTop: 15, marginBottom: 15}}>
|
<div style={{marginTop: 15, marginBottom: 15}}>
|
||||||
<b>Arguments</b>
|
<b>Parameters</b>
|
||||||
{selectedAction.parameters.map(data => {
|
{selectedAction.parameters.map(data => {
|
||||||
var itemColor = "#f85a3e"
|
var itemColor = "#f85a3e"
|
||||||
if (!data.required) {
|
if (!data.required) {
|
||||||
|
|||||||
Reference in New Issue
Block a user