Sfoglia il codice sorgente

chore: Allow entity key ordering for actionless components

jamesread 7 mesi fa
parent
commit
dcb5bd0c82
1 ha cambiato i file con 5 aggiunte e 0 eliminazioni
  1. 5 0
      service/internal/api/dashboards.go

+ 5 - 0
service/internal/api/dashboards.go

@@ -182,6 +182,11 @@ func entityKeyLess(a, b string) bool {
 func sortDashboardComponents(components []*apiv1.DashboardComponent) []*apiv1.DashboardComponent {
 func sortDashboardComponents(components []*apiv1.DashboardComponent) []*apiv1.DashboardComponent {
 	sort.Slice(components, func(i, j int) bool {
 	sort.Slice(components, func(i, j int) bool {
 		if components[i].Action == nil || components[j].Action == nil {
 		if components[i].Action == nil || components[j].Action == nil {
+			if components[i].EntityKey != "" && components[j].EntityKey != "" &&
+				components[i].EntityKey != components[j].EntityKey {
+				return entityKeyLess(components[i].EntityKey, components[j].EntityKey)
+			}
+
 			return components[i].Title < components[j].Title
 			return components[i].Title < components[j].Title
 		}
 		}