mirror of https://github.com/grafana/grafana.git
Dashboard migration: v14 Broken dash repro (#110405)
* Broken dash repro * Fix V16 migration to preserve panels when rows array is empty - Fixed bug where panels were deleted when migrating dashboards with empty rows array - Updated v16.go to match frontend implementation behavior - Added test case for empty rows scenario in v16_test.go - Renamed test files to v16.empty-rows-and-panels-array.json for clarity - All migration tests passing (419 test cases)
This commit is contained in:
parent
3056924d10
commit
322adac5fc
|
@ -37,7 +37,6 @@ func upgradeToGridLayout(dashboard map[string]interface{}) {
|
||||||
|
|
||||||
// Handle empty rows
|
// Handle empty rows
|
||||||
if len(rows) == 0 {
|
if len(rows) == 0 {
|
||||||
dashboard["panels"] = []interface{}{}
|
|
||||||
delete(dashboard, "rows")
|
delete(dashboard, "rows")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -1392,6 +1392,72 @@ func TestV16(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "should preserve existing panels when rows array is empty",
|
||||||
|
input: map[string]interface{}{
|
||||||
|
"schemaVersion": 15,
|
||||||
|
"rows": []interface{}{},
|
||||||
|
"panels": []interface{}{
|
||||||
|
map[string]interface{}{
|
||||||
|
"id": 1,
|
||||||
|
"type": "graph",
|
||||||
|
"title": "Existing Panel",
|
||||||
|
"datasource": map[string]interface{}{
|
||||||
|
"uid": "test-ds",
|
||||||
|
},
|
||||||
|
"gridPos": map[string]interface{}{
|
||||||
|
"h": 8,
|
||||||
|
"w": 12,
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
map[string]interface{}{
|
||||||
|
"id": 2,
|
||||||
|
"type": "stat",
|
||||||
|
"title": "Another Panel",
|
||||||
|
"gridPos": map[string]interface{}{
|
||||||
|
"h": 8,
|
||||||
|
"w": 12,
|
||||||
|
"x": 12,
|
||||||
|
"y": 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expected: map[string]interface{}{
|
||||||
|
"schemaVersion": 16,
|
||||||
|
// panels should be preserved exactly as they were
|
||||||
|
"panels": []interface{}{
|
||||||
|
map[string]interface{}{
|
||||||
|
"id": 1,
|
||||||
|
"type": "graph",
|
||||||
|
"title": "Existing Panel",
|
||||||
|
"datasource": map[string]interface{}{
|
||||||
|
"uid": "test-ds",
|
||||||
|
},
|
||||||
|
"gridPos": map[string]interface{}{
|
||||||
|
"h": 8,
|
||||||
|
"w": 12,
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
map[string]interface{}{
|
||||||
|
"id": 2,
|
||||||
|
"type": "stat",
|
||||||
|
"title": "Another Panel",
|
||||||
|
"gridPos": map[string]interface{}{
|
||||||
|
"h": 8,
|
||||||
|
"w": 12,
|
||||||
|
"x": 12,
|
||||||
|
"y": 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// rows field should be removed
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
runMigrationTests(t, tests, schemaversion.V16)
|
runMigrationTests(t, tests, schemaversion.V16)
|
||||||
|
|
1077
apps/dashboard/pkg/migration/testdata/input/v16.empty-rows-and-panels-array.json
vendored
Normal file
1077
apps/dashboard/pkg/migration/testdata/input/v16.empty-rows-and-panels-array.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1055
apps/dashboard/pkg/migration/testdata/output/v16.empty-rows-and-panels-array.json
vendored
Normal file
1055
apps/dashboard/pkg/migration/testdata/output/v16.empty-rows-and-panels-array.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue