Fix dashboard migration discrepancies between backend and frontend implementations (use toEqual) (#110268)
**Highlights**
* **Single-version migrations**: add `targetVersion` to migrator & model, separate outputs, enforce exact version.
* **Datasource fixes**: include `apiVersion` in tests, empty-string → `{}`, preserve `{}` refs, drop unwanted defaults.
* **Panel defaults & nesting**: only top-level panels get defaults; preserve empty `transformations` context-aware; filter repeated panels.
* **Migration parity**
* V16: collapsed rows, grid height parsing (`px`).
* V17: omit `maxPerRow` when `minSpan=1`.
* V19–V20: cleanup defaults (`targetBlank`, style).
* V23–V24: template vars + table panel consistency.
* V28: full singlestat/stat parity, mappings & color.
* V30–V36: threshold logic, empty refs, nested targets.
* **Save-model cleanup**: replicate frontend defaults/filtering, drop null IDs, metadata, unused props.
* **Testing**: unified suites, dev dashboards (v42), full unit coverage for major migrations.
Co-authored-by: Ivan Ortega [ivanortegaalba@gmail.com](mailto:ivanortegaalba@gmail.com)
Co-authored-by: Dominik Prokop [dominik.prokop@grafana.com](mailto:dominik.prokop@grafana.com)
This commit is contained in:
co-authored by
Ivan Ortega [ivanortegaalba@gmail.com](mailto:ivanortegaalba@gmail.com)
Dominik Prokop [dominik.prokop@grafana.com](mailto:dominik.prokop@grafana.com)
parent
98fd3e8fe9
commit
a72e02f88a
@@ -97,12 +97,11 @@ func upgradeToGridLayout(dashboard map[string]interface{}) {
|
||||
if showRows {
|
||||
// add special row panel (lines 1041-1058 in TS)
|
||||
rowPanel = map[string]interface{}{
|
||||
"id": nextRowID,
|
||||
"type": "row",
|
||||
"title": GetStringValue(row, "title"),
|
||||
"collapsed": isCollapsed,
|
||||
"repeat": GetStringValue(row, "repeat"),
|
||||
"panels": []interface{}{},
|
||||
"id": nextRowID,
|
||||
"type": "row",
|
||||
"title": GetStringValue(row, "title"),
|
||||
"repeat": GetStringValue(row, "repeat"),
|
||||
"panels": []interface{}{},
|
||||
"gridPos": map[string]interface{}{
|
||||
"x": 0,
|
||||
"y": yPos,
|
||||
@@ -110,6 +109,12 @@ func upgradeToGridLayout(dashboard map[string]interface{}) {
|
||||
"h": rowGridHeight,
|
||||
},
|
||||
}
|
||||
|
||||
// Set collapsed property only if the original row had a collapse property
|
||||
// This matches the frontend behavior: rowPanel.collapsed = row.collapse
|
||||
if _, hasCollapse := row["collapse"]; hasCollapse {
|
||||
rowPanel["collapsed"] = isCollapsed
|
||||
}
|
||||
nextRowID++
|
||||
yPos++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user