Skip to content

Commit

Permalink
Address BE review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
KinyaElGrande committed Mar 26, 2024
1 parent 55d99f3 commit 64d5780
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 120 deletions.
16 changes: 8 additions & 8 deletions server/compose/envoy/store_decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,28 +163,28 @@ func decodePageRefs(p *types.Page) (refs map[string]envoyx.Ref) {
for index, b := range p.Blocks {
switch b.Kind {
case "RecordList":
refs = envoyx.MergeRefs(refs, getPageBlockRecordListRefs(b, index))
refs = envoyx.MergeRefs(refs, getPageBlockRecordListRefs(b.Options, index))

case "Automation":
refs = envoyx.MergeRefs(refs, getPageBlockAutomationRefs(b, index))
refs = envoyx.MergeRefs(refs, getPageBlockAutomationRefs(b.Options, index))

case "RecordOrganizer":
refs = envoyx.MergeRefs(refs, getPageBlockRecordOrganizerRefs(b, index))
refs = envoyx.MergeRefs(refs, getPageBlockRecordOrganizerRefs(b.Options, index))

case "Chart":
refs = envoyx.MergeRefs(refs, getPageBlockChartRefs(b, index))
refs = envoyx.MergeRefs(refs, getPageBlockChartRefs(b.Options, index))

case "Calendar":
refs = envoyx.MergeRefs(refs, getPageBlockCalendarRefs(b, index))
refs = envoyx.MergeRefs(refs, getPageBlockCalendarRefs(b.Options, index))

case "Metric":
refs = envoyx.MergeRefs(refs, getPageBlockMetricRefs(b, index))
refs = envoyx.MergeRefs(refs, getPageBlockMetricRefs(b.Options, index))

case "Comment":
refs = envoyx.MergeRefs(refs, getPageBlockCommentRefs(b, index))
refs = envoyx.MergeRefs(refs, getPageBlockCommentRefs(b.Options, index))

case "Progress":
refs = envoyx.MergeRefs(refs, getPageBlockProgressRefs(b, index))
refs = envoyx.MergeRefs(refs, getPageBlockProgressRefs(b.Options, index))
}
}

Expand Down
107 changes: 44 additions & 63 deletions server/compose/envoy/yaml_decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,74 +73,55 @@ func (d *auxYamlDoc) unmarshalPageBlocksNode(r *types.Page, n *yaml.Node) (refs
refs = map[string]envoyx.Ref{}

for index, b := range r.Blocks {
switch b.Kind {
case "RecordList":
refs = envoyx.MergeRefs(refs, getPageBlockRecordListRefs(b, index))

case "Automation":
refs = envoyx.MergeRefs(refs, getPageBlockAutomationRefs(b, index))

case "RecordOrganizer":
refs = envoyx.MergeRefs(refs, getPageBlockRecordOrganizerRefs(b, index))

case "Chart":
refs = envoyx.MergeRefs(refs, getPageBlockChartRefs(b, index))

case "Calendar":
refs = envoyx.MergeRefs(refs, getPageBlockCalendarRefs(b, index))

case "Metric":
refs = envoyx.MergeRefs(refs, getPageBlockMetricRefs(b, index))

case "Comment":
refs = envoyx.MergeRefs(refs, getPageBlockCommentRefs(b, index))

case "Progress":
refs = envoyx.MergeRefs(refs, getPageBlockProgressRefs(b, index))
}
idents, err = unmarshalResourceBlocksNode(b.Kind, b.Options, index, refs)
}

return
}

func (d *auxYamlDoc) unmarshalNamespaceBlocksNode(r *types.Namespace, n *yaml.Node) (refs map[string]envoyx.Ref, idents envoyx.Identifiers, err error) {
refs = map[string]envoyx.Ref{}

for index, b := range r.Blocks {
switch b.Kind {
case "RecordList":
refs = envoyx.MergeRefs(refs, getPageBlockRecordListRefs(b, index))
for index, gBlock := range r.Blocks {
idents, err = unmarshalResourceBlocksNode(gBlock.Kind, gBlock.Options, index, refs)
}

return
}

case "Automation":
refs = envoyx.MergeRefs(refs, getPageBlockAutomationRefs(b, index))
func unmarshalResourceBlocksNode(kind string, options map[string]interface{}, index int, refs map[string]envoyx.Ref) (idents envoyx.Identifiers, err error) {
switch kind {
case "RecordList":
refs = envoyx.MergeRefs(refs, getPageBlockRecordListRefs(options, index))

case "RecordOrganizer":
refs = envoyx.MergeRefs(refs, getPageBlockRecordOrganizerRefs(b, index))
case "Automation":
refs = envoyx.MergeRefs(refs, getPageBlockAutomationRefs(options, index))

case "Chart":
refs = envoyx.MergeRefs(refs, getPageBlockChartRefs(b, index))
case "RecordOrganizer":
refs = envoyx.MergeRefs(refs, getPageBlockRecordOrganizerRefs(options, index))

case "Calendar":
refs = envoyx.MergeRefs(refs, getPageBlockCalendarRefs(b, index))
case "Chart":
refs = envoyx.MergeRefs(refs, getPageBlockChartRefs(options, index))

case "Metric":
refs = envoyx.MergeRefs(refs, getPageBlockMetricRefs(b, index))
case "Calendar":
refs = envoyx.MergeRefs(refs, getPageBlockCalendarRefs(options, index))

case "Comment":
refs = envoyx.MergeRefs(refs, getPageBlockCommentRefs(b, index))
case "Metric":
refs = envoyx.MergeRefs(refs, getPageBlockMetricRefs(options, index))

case "Progress":
refs = envoyx.MergeRefs(refs, getPageBlockProgressRefs(b, index))
}
case "Comment":
refs = envoyx.MergeRefs(refs, getPageBlockCommentRefs(options, index))

case "Progress":
refs = envoyx.MergeRefs(refs, getPageBlockProgressRefs(options, index))
}

return
}

func getPageBlockRecordListRefs(b types.PageBlock, index int) (refs map[string]envoyx.Ref) {
func getPageBlockRecordListRefs(options map[string]interface{}, index int) (refs map[string]envoyx.Ref) {
refs = make(map[string]envoyx.Ref)

id := optString(b.Options, "module", "moduleID")
id := optString(options, "module", "moduleID")
if id == "" || id == "0" {
return
}
Expand All @@ -153,10 +134,10 @@ func getPageBlockRecordListRefs(b types.PageBlock, index int) (refs map[string]e
return
}

func getPageBlockChartRefs(b types.PageBlock, index int) (refs map[string]envoyx.Ref) {
func getPageBlockChartRefs(options map[string]interface{}, index int) (refs map[string]envoyx.Ref) {
refs = make(map[string]envoyx.Ref)

id := optString(b.Options, "chart", "chartID")
id := optString(options, "chart", "chartID")
if id == "" || id == "0" {
return
}
Expand All @@ -169,10 +150,10 @@ func getPageBlockChartRefs(b types.PageBlock, index int) (refs map[string]envoyx
return
}

func getPageBlockCalendarRefs(b types.PageBlock, index int) (refs map[string]envoyx.Ref) {
func getPageBlockCalendarRefs(options map[string]interface{}, index int) (refs map[string]envoyx.Ref) {
refs = make(map[string]envoyx.Ref)

ff, _ := b.Options["feeds"].([]interface{})
ff, _ := options["feeds"].([]interface{})
for j, f := range ff {
feed, _ := f.(map[string]interface{})
opt, _ := (feed["options"]).(map[string]interface{})
Expand All @@ -191,10 +172,10 @@ func getPageBlockCalendarRefs(b types.PageBlock, index int) (refs map[string]env
return
}

func getPageBlockMetricRefs(b types.PageBlock, index int) (refs map[string]envoyx.Ref) {
func getPageBlockMetricRefs(options map[string]interface{}, index int) (refs map[string]envoyx.Ref) {
refs = make(map[string]envoyx.Ref)

mm, _ := b.Options["metrics"].([]interface{})
mm, _ := options["metrics"].([]interface{})
for j, m := range mm {
mops, _ := m.(map[string]interface{})

Expand All @@ -212,26 +193,26 @@ func getPageBlockMetricRefs(b types.PageBlock, index int) (refs map[string]envoy
return
}

func getPageBlockCommentRefs(b types.PageBlock, index int) (refs map[string]envoyx.Ref) {
func getPageBlockCommentRefs(options map[string]interface{}, index int) (refs map[string]envoyx.Ref) {
// Same difference
return getPageBlockRecordListRefs(b, index)
return getPageBlockRecordListRefs(options, index)
}

func getPageBlockProgressRefs(b types.PageBlock, index int) (refs map[string]envoyx.Ref) {
func getPageBlockProgressRefs(options map[string]interface{}, index int) (refs map[string]envoyx.Ref) {
refs = make(map[string]envoyx.Ref)
var aux *envoyx.Ref

aux = getPageBlockProgressValueRefs(b.Options["minValue"])
aux = getPageBlockProgressValueRefs(options["minValue"])
if aux != nil {
refs[fmt.Sprintf("Blocks.%d.Options.minValue.ModuleID", index)] = *aux
}

aux = getPageBlockProgressValueRefs(b.Options["maxValue"])
aux = getPageBlockProgressValueRefs(options["maxValue"])
if aux != nil {
refs[fmt.Sprintf("Blocks.%d.Options.maxValue.ModuleID", index)] = *aux
}

aux = getPageBlockProgressValueRefs(b.Options["value"])
aux = getPageBlockProgressValueRefs(options["value"])
if aux != nil {
refs[fmt.Sprintf("Blocks.%d.Options.value.ModuleID", index)] = *aux
}
Expand Down Expand Up @@ -260,15 +241,15 @@ func getPageBlockProgressValueRefs(val any) (ref *envoyx.Ref) {
}
}

func getPageBlockRecordOrganizerRefs(b types.PageBlock, index int) (refs map[string]envoyx.Ref) {
func getPageBlockRecordOrganizerRefs(options map[string]interface{}, index int) (refs map[string]envoyx.Ref) {
// Same difference
return getPageBlockRecordListRefs(b, index)
return getPageBlockRecordListRefs(options, index)
}

func getPageBlockAutomationRefs(b types.PageBlock, index int) (refs map[string]envoyx.Ref) {
func getPageBlockAutomationRefs(options map[string]interface{}, index int) (refs map[string]envoyx.Ref) {
refs = make(map[string]envoyx.Ref)

bb, _ := b.Options["buttons"].([]interface{})
bb, _ := options["buttons"].([]interface{})
for buttonIx, b := range bb {
button, _ := b.(map[string]interface{})
id := optString(button, "workflow", "workflowID")
Expand Down
Loading

0 comments on commit 64d5780

Please sign in to comment.