mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
PublicDashboards: Add support for recorded queries used in Mixed ds (#70096)
This commit is contained in:
parent
cc72fe17d5
commit
3413e1497e
@ -224,9 +224,9 @@ func getUniqueDashboardDatasourceUids(dashboard *simplejson.Json) []string {
|
||||
|
||||
// if uid is for a mixed datasource, get the datasource uids from the targets
|
||||
if uid == "-- Mixed --" {
|
||||
for _, target := range panel.Get("targets").MustArray() {
|
||||
target := simplejson.NewFromAny(target)
|
||||
datasourceUid := target.Get("datasource").Get("uid").MustString()
|
||||
for _, targetObj := range panel.Get("targets").MustArray() {
|
||||
target := simplejson.NewFromAny(targetObj)
|
||||
datasourceUid := getDataSourceUidFromJson(target)
|
||||
if _, ok := exists[datasourceUid]; !ok {
|
||||
datasourceUids = append(datasourceUids, datasourceUid)
|
||||
exists[datasourceUid] = true
|
||||
|
@ -136,6 +136,15 @@ const (
|
||||
"interval": "",
|
||||
"legendFormat": "",
|
||||
"refId": "A"
|
||||
},
|
||||
{
|
||||
"datasource": "6SOeCRrVk",
|
||||
"exemplar": true,
|
||||
"expr": "test{id=\"f0dd9b69-ad04-4342-8e79-ced8c245683b\", name=\"test\"}",
|
||||
"hide": false,
|
||||
"interval": "",
|
||||
"legendFormat": "",
|
||||
"refId": "B"
|
||||
}
|
||||
],
|
||||
"title": "Panel Title",
|
||||
@ -1156,9 +1165,10 @@ func TestGetUniqueDashboardDatasourceUids(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
uids := getUniqueDashboardDatasourceUids(json)
|
||||
require.Len(t, uids, 2)
|
||||
require.Len(t, uids, 3)
|
||||
require.Equal(t, "abc123", uids[0])
|
||||
require.Equal(t, "_yxMP8Ynk", uids[1])
|
||||
require.Equal(t, "6SOeCRrVk", uids[1])
|
||||
require.Equal(t, "_yxMP8Ynk", uids[2])
|
||||
})
|
||||
|
||||
t.Run("can get no datasource uids from empty dashboard", func(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user