DashboardMigration: V16 was removing panels when repeatInteration is null (#110151)
This commit is contained in:
@@ -66,7 +66,7 @@ func upgradeToGridLayout(dashboard map[string]interface{}) {
|
||||
}
|
||||
|
||||
// Skip repeated rows (line 1031-1033 in TS)
|
||||
if _, hasRepeatIteration := row["repeatIteration"]; hasRepeatIteration {
|
||||
if repeatIteration, hasRepeatIteration := row["repeatIteration"]; hasRepeatIteration && repeatIteration != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -283,7 +283,11 @@ func getMaxPanelID(rows []interface{}) int {
|
||||
func shouldShowRows(rows []interface{}) bool {
|
||||
for _, rowInterface := range rows {
|
||||
if row, ok := rowInterface.(map[string]interface{}); ok {
|
||||
if GetBoolValue(row, "collapse") || GetBoolValue(row, "showTitle") || GetStringValue(row, "repeat") != "" {
|
||||
collapse := GetBoolValue(row, "collapse")
|
||||
showTitle := GetBoolValue(row, "showTitle")
|
||||
repeat := GetStringValue(row, "repeat")
|
||||
|
||||
if collapse || showTitle || repeat != "" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,63 @@ import (
|
||||
|
||||
func TestV16(t *testing.T) {
|
||||
tests := []migrationTestCase{
|
||||
{
|
||||
name: "should handle repeatIteration null",
|
||||
input: map[string]interface{}{
|
||||
"schemaVersion": 15,
|
||||
"rows": []interface{}{
|
||||
map[string]interface{}{
|
||||
"collapse": false,
|
||||
"showTitle": true,
|
||||
"title": "Overview",
|
||||
"type": "row",
|
||||
"repeat": nil,
|
||||
"repeatIteration": nil,
|
||||
"repeatRowId": nil,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": 2,
|
||||
"type": "stat",
|
||||
"span": 12,
|
||||
"title": "Customer Stats",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"schemaVersion": 16,
|
||||
"panels": []interface{}{
|
||||
// The stat panel should be processed and added
|
||||
map[string]interface{}{
|
||||
"id": 2,
|
||||
"type": "stat",
|
||||
"title": "Customer Stats",
|
||||
"gridPos": map[string]interface{}{
|
||||
"x": 0,
|
||||
"y": 1,
|
||||
"w": 24,
|
||||
"h": 7, // default height
|
||||
},
|
||||
},
|
||||
// The row panel should be created because showTitle is true
|
||||
map[string]interface{}{
|
||||
"id": 3, // Next ID after max panel ID (2)
|
||||
"type": "row",
|
||||
"title": "Overview",
|
||||
"collapsed": false,
|
||||
"repeat": "",
|
||||
"panels": []interface{}{},
|
||||
"gridPos": map[string]interface{}{
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 24,
|
||||
"h": 7, // default height
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "should create proper grid",
|
||||
input: map[string]interface{}{
|
||||
|
||||
Reference in New Issue
Block a user