SearchV2: Fix reading library panels (#92961)

* Fix reading of library panel field
* Add test to check reading of library panel field
pull/92979/head
Arati R. 9 months ago committed by GitHub
parent ebd17adecf
commit 47cd8288cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      pkg/services/store/kind/dashboard/dashboard.go
  2. 1
      pkg/services/store/kind/dashboard/dashboard_test.go
  3. 30
      pkg/services/store/kind/dashboard/testdata/panel-with-library-panel-field-info.json
  4. 83
      pkg/services/store/kind/dashboard/testdata/panel-with-library-panel-field.json

@ -396,9 +396,13 @@ func readpanelInfo(iter *jsoniter.Iterator, lookup DatasourceLookup) panelInfo {
panel.PluginVersion = iter.ReadString() // since 7x (the saved version for the plugin model)
case "libraryPanel":
var v map[string]string
var v map[string]interface{}
iter.ReadVal(&v)
panel.LibraryPanel = v["uid"]
if uid, ok := v["uid"]; ok {
if u, isString := uid.(string); isString {
panel.LibraryPanel = u
}
}
case "datasource":
targets.addDatasource(iter)

@ -70,6 +70,7 @@ func TestReadDashboard(t *testing.T) {
"mixed-datasource-with-variable",
"special-datasource-types",
"panels-without-datasources",
"panel-with-library-panel-field",
}
devdash := "../../../../../devenv/dev-dashboards/"

@ -0,0 +1,30 @@
{
"id": 345,
"title": "The libraryPanel field should get read properly despite the version being an integer",
"tags": null,
"datasource": [
{
"uid": "default.uid",
"type": "default.type"
}
],
"panels": [
{
"id": 454,
"title": "Example title",
"type": "timeseries",
"libraryPanel": "dfkljg98345dkf",
"datasource": [
{
"uid": "default.uid",
"type": "default.type"
}
]
}
],
"schemaVersion": 39,
"linkCount": 0,
"timeFrom": "now-6h",
"timeTo": "now",
"timezone": ""
}

@ -0,0 +1,83 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "datasource",
"uid": "grafana"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "The libraryPanel field should get read properly despite the version being an integer",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 345,
"links": [],
"panels": [
{
"description": "",
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 15
},
"id": 454,
"libraryPanel": {
"name": "example name",
"uid": "dfkljg98345dkf",
"version": 2001
},
"options": {
"legend": {
"calcs": [],
"displayMode": "hidden",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"datasource": {
"type": "graphite",
"uid": "000000001"
},
"refId": "A"
}
],
"title": "Example title",
"transparent": true,
"type": "timeseries"
}
],
"preload": false,
"refresh": "",
"schemaVersion": 39,
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "The libraryPanel field should get read properly despite the version being an integer",
"uid": "sdjf03945834sdkf",
"version": 33,
"weekStart": ""
}
Loading…
Cancel
Save