Fix workflow importing and referencing

* Page blocks used invalid ref. formats & value setters.
* Some default values were skipped due to how yaml decoder works.
This commit is contained in:
Tomaž Jerman
2023-04-02 11:11:19 +02:00
parent ef94c90da1
commit b041e4fb32
4 changed files with 58 additions and 2 deletions
+2 -2
View File
@@ -261,14 +261,14 @@ func getPageBlockAutomationRefs(b types.PageBlock, index int) (refs map[string]e
refs = make(map[string]envoyx.Ref)
bb, _ := b.Options["buttons"].([]interface{})
for _, b := range bb {
for buttonIx, b := range bb {
button, _ := b.(map[string]interface{})
id := optString(button, "workflow", "workflowID")
if id == "" || id == "0" {
return
}
refs[fmt.Sprintf("Blocks.%d.Options.WorkflowID", index)] = envoyx.Ref{
refs[fmt.Sprintf("Blocks.%d.Options.buttons.%d.WorkflowID", index, buttonIx)] = envoyx.Ref{
ResourceType: automationTypes.WorkflowResourceType,
Identifiers: envoyx.MakeIdentifiers(id),
}
+8
View File
@@ -432,6 +432,14 @@ func (b *PageBlock) setOptionValue(path []string, pos uint, value any) (err erro
case "chartID", "ChartID":
b.Options["chartID"] = cast.ToString(value)
case "buttons":
switch path[2] {
case "workflowID", "WorkflowID":
button := (b.Options["buttons"].([]any))[cast.ToInt(path[1])].(map[string]interface{})
button["workflowID"] = cast.ToString(value)
delete(button, "workflow")
}
}
return