mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
SearchV2: Fix reading library panels (#92961)
* Fix reading of library panel field * Add test to check reading of library panel field
This commit is contained in:
@@ -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/"
|
||||
|
||||
30
pkg/services/store/kind/dashboard/testdata/panel-with-library-panel-field-info.json
vendored
Normal file
30
pkg/services/store/kind/dashboard/testdata/panel-with-library-panel-field-info.json
vendored
Normal file
@@ -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": ""
|
||||
}
|
||||
83
pkg/services/store/kind/dashboard/testdata/panel-with-library-panel-field.json
vendored
Normal file
83
pkg/services/store/kind/dashboard/testdata/panel-with-library-panel-field.json
vendored
Normal file
@@ -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": ""
|
||||
}
|
||||
Reference in New Issue
Block a user