Skip to content

Commit 65bf4ee

Browse files
committed
fix: updates for lalit
1 parent 7453c52 commit 65bf4ee

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

shared.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6554,13 +6554,20 @@ func diffWorkflows(oldWorkflow Workflow, parentWorkflow Workflow, update bool) {
65546554
}
65556555
}
65566556

6557+
6558+
for _, trigger := range childWorkflow.Triggers {
6559+
6560+
65576561
if len(addedTriggers) > 0 {
6562+
log.Printf("[DEBUG] Triggers added: %d", len(addedTriggers))
65586563
triggers := childTriggers
65596564
for _, trigger := range parentWorkflow.Triggers {
65606565
if !ArrayContains(addedTriggers, trigger.ID) {
65616566
continue
65626567
}
65636568

6569+
log.Printf("[DEBUG] ID of the added trigger: %s", trigger.ID)
6570+
65646571
triggers = append(triggers, trigger)
65656572
}
65666573

@@ -6583,7 +6590,9 @@ func diffWorkflows(oldWorkflow Workflow, parentWorkflow Workflow, update bool) {
65836590
}
65846591

65856592
if len(updatedTriggers) > 0 {
6593+
log.Printf("[DEBUG] Triggers updated: %d", len(updatedTriggers))
65866594
for _, action := range updatedTriggers {
6595+
log.Printf("[DEBUG] ID of the updated trigger: %s", action.ID)
65876596
for index, childAction := range childWorkflow.Triggers {
65886597
if childAction.ID != action.ID {
65896598
continue
@@ -6795,6 +6804,22 @@ func diffWorkflows(oldWorkflow Workflow, parentWorkflow Workflow, update bool) {
67956804
}
67966805
}
67976806

6807+
// Old childWorkflow triggers:
6808+
for _, oldTrigger := range oldWorkflow.Triggers {
6809+
// params
6810+
for _, param := range oldTrigger.Parameters {
6811+
log.Printf("[DEBUG] Old trigger %s (%s) has param %s and value: %s", oldTrigger.Label, oldTrigger.ID, param.Name, param.Value)
6812+
}
6813+
}
6814+
6815+
// to be updated triggers
6816+
for _, trigger := range newTriggers {
6817+
// params
6818+
for _, param := range trigger.Parameters {
6819+
log.Printf("[DEBUG] New trigger %s (%s) has param %s and value: %s", trigger.Label, trigger.ID, param.Name, param.Value)
6820+
}
6821+
}
6822+
67986823
childWorkflow.Actions = newActions
67996824
childWorkflow.Triggers = newTriggers
68006825
childWorkflow.Branches = newBranches
@@ -9652,6 +9677,8 @@ func GenerateWorkflowFromParent(ctx context.Context, workflow Workflow, parentOr
96529677
// E.g. for webhooks, how do we have a URL correctly, and start/stop properly?
96539678
newWf.Triggers[triggerIndex].Status = "uninitialized"
96549679
if newWf.Triggers[triggerIndex].TriggerType == "WEBHOOK" {
9680+
oldID := newWf.Triggers[triggerIndex].ID
9681+
newWf.Triggers[triggerIndex].ID = uuid.NewV4().String()
96559682
for paramIndex, param := range newWf.Triggers[triggerIndex].Parameters {
96569683
if param.Name == "url" {
96579684
newWf.Triggers[triggerIndex].Parameters[paramIndex].Value = ""
@@ -9660,6 +9687,19 @@ func GenerateWorkflowFromParent(ctx context.Context, workflow Workflow, parentOr
96609687
if param.Name == "tmp" {
96619688
newWf.Triggers[triggerIndex].Parameters[paramIndex].Value = ""
96629689
}
9690+
9691+
newWf.Triggers[triggerIndex].ReplacementForTrigger = oldID
9692+
9693+
// edit all branch source ids where the ID is changed
9694+
for branchIndex, branch := range newWf.Branches {
9695+
if branch.SourceID == oldID {
9696+
newWf.Branches[branchIndex].SourceID = newWf.Triggers[triggerIndex].ID
9697+
}
9698+
9699+
if branch.DestinationID == oldID {
9700+
newWf.Branches[branchIndex].DestinationID = newWf.Triggers[triggerIndex].ID
9701+
}
9702+
}
96639703
}
96649704
}
96659705
}

structs.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,8 +1206,9 @@ type Trigger struct {
12061206
SourceWorkflow string `json:"source_workflow" yaml:"source_workflow" datastore:"source_workflow"`
12071207
ExecutionDelay int64 `json:"execution_delay" yaml:"execution_delay" datastore:"execution_delay"`
12081208
AppAssociation WorkflowApp `json:"app_association" yaml:"app_association" datastore:"app_association"`
1209-
12101209
ParentControlled bool `json:"parent_controlled" datastore:"parent_controlled"` // If the parent workflow node exists, and shouldn't be editable by child workflow
1210+
1211+
ReplacementForTrigger string `json:"replacement_for_trigger" datastore:"replacement_for_trigger"` // If this trigger is a replacement for another trigger
12111212
}
12121213

12131214
type Branch struct {

0 commit comments

Comments
 (0)