mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
testdata: scenarios returned are now sorted in a consistent way (#17181)
This makes sure the scenarios returned from API are sorted in a consistent way and by that makes the values in scenario drop down always presented ordered instead of jumping around.
This commit is contained in:
parent
b695dcd0eb
commit
c82df97bb2
@ -2,6 +2,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/api/dtos"
|
"github.com/grafana/grafana/pkg/api/dtos"
|
||||||
"github.com/grafana/grafana/pkg/bus"
|
"github.com/grafana/grafana/pkg/bus"
|
||||||
@ -66,7 +67,14 @@ func (hs *HTTPServer) QueryMetrics(c *m.ReqContext, reqDto dtos.MetricRequest) R
|
|||||||
func GetTestDataScenarios(c *m.ReqContext) Response {
|
func GetTestDataScenarios(c *m.ReqContext) Response {
|
||||||
result := make([]interface{}, 0)
|
result := make([]interface{}, 0)
|
||||||
|
|
||||||
for _, scenario := range testdata.ScenarioRegistry {
|
scenarioIds := make([]string, 0)
|
||||||
|
for id := range testdata.ScenarioRegistry {
|
||||||
|
scenarioIds = append(scenarioIds, id)
|
||||||
|
}
|
||||||
|
sort.Strings(scenarioIds)
|
||||||
|
|
||||||
|
for _, scenarioId := range scenarioIds {
|
||||||
|
scenario := testdata.ScenarioRegistry[scenarioId]
|
||||||
result = append(result, map[string]interface{}{
|
result = append(result, map[string]interface{}{
|
||||||
"id": scenario.Id,
|
"id": scenario.Id,
|
||||||
"name": scenario.Name,
|
"name": scenario.Name,
|
||||||
|
Loading…
Reference in New Issue
Block a user