Public Dashboards Bug: Permissions error on panel when using mixed datasource with Enterprise (#51930)

Fixes pubdash bug for enterprise when pubdash panel uses a mixed datasource
This commit is contained in:
owensmallwood
2022-07-07 15:58:11 -06:00
committed by GitHub
parent e1d36754a1
commit 2aff83d4e1
4 changed files with 139 additions and 5 deletions
+16 -3
View File
@@ -11,9 +11,22 @@ func GetUniqueDashboardDatasourceUids(dashboard *simplejson.Json) []string {
for _, panelObj := range dashboard.Get("panels").MustArray() {
panel := simplejson.NewFromAny(panelObj)
uid := panel.Get("datasource").Get("uid").MustString()
if _, ok := exists[uid]; !ok {
datasourceUids = append(datasourceUids, uid)
exists[uid] = true
// 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()
if _, ok := exists[datasourceUid]; !ok {
datasourceUids = append(datasourceUids, datasourceUid)
exists[datasourceUid] = true
}
}
} else {
if _, ok := exists[uid]; !ok {
datasourceUids = append(datasourceUids, uid)
exists[uid] = true
}
}
}