4d3c5d1550
* migrate to v19 * migrate to v18 * Migration to be verified: v17 Convert minSpan to maxPerRow in panels * Migration to be verified: 16 Grid layout migration * Refactor v17 and v19 migrations to use shared helper functions * Migration to be verified: 15 No-op migration for schema consistency * Migration to be verified: 14 Shared crosshair to graph tooltip migration * cleanup * wip * complete migration * fix lint issues * refactor and test with minimal graph config * update tests * extract defaults outside the func * lint * lint * add missing showValues prop * add context and fix latest version * generate snapshots * v13 should be no-op * clean up * remove v28 * remove singlestat migraiton from frontend migrator because this is an automigration * remove unused function * Remove v24 table plugin logic * cleanup * remove plugin version for automigrate as it was used only in v24 and v28 that have been removed * cleanup --------- Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
99 lines
2.1 KiB
Go
99 lines
2.1 KiB
Go
package schemaversion
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// V24 migration handles setting autoMigrateFrom
|
|
// This is a hacky way that matches frontend's logic
|
|
// For reason see https://github.com/grafana/grafana/pull/102146
|
|
// The issue is that if panel is "table" and it has styles, it should be migrated to "table-old"
|
|
|
|
// Example before migration:
|
|
// {
|
|
// "id": 4,
|
|
// "type": "table",
|
|
// "title": "Table with Timeseries to Rows Transform",
|
|
// "description": "Tests migration of timeseries_to_rows transform to seriesToRows transformation.",
|
|
// "styles": [
|
|
// {
|
|
// "pattern": "/.*/",
|
|
// "unit": "short"
|
|
// }
|
|
// ],
|
|
// "transform": "timeseries_to_rows",
|
|
// "targets": [{ "refId": "A" }]
|
|
// }
|
|
//
|
|
// Example after migration:
|
|
// {
|
|
// "autoMigrateFrom": "table-old",
|
|
// "datasource": {
|
|
// "apiVersion": "v1",
|
|
// "type": "prometheus",
|
|
// "uid": "default-ds-uid"
|
|
// },
|
|
// "description": "Tests migration of timeseries_to_rows transform to seriesToRows transformation.",
|
|
// "id": 4,
|
|
// "styles": [
|
|
// {
|
|
// "pattern": "/.*/",
|
|
// "unit": "short"
|
|
// }
|
|
// ],
|
|
// "targets": [
|
|
// {
|
|
// "datasource": {
|
|
// "apiVersion": "v1",
|
|
// "type": "prometheus",
|
|
// "uid": "default-ds-uid"
|
|
// },
|
|
// "refId": "A"
|
|
// }
|
|
// ],
|
|
// "title": "Table with Timeseries to Rows Transform",
|
|
// "transform": "timeseries_to_rows",
|
|
// "type": "table"
|
|
// }
|
|
|
|
func V24(_ context.Context, dashboard map[string]interface{}) error {
|
|
dashboard["schemaVersion"] = 24
|
|
|
|
panels, ok := dashboard["panels"].([]interface{})
|
|
if !ok {
|
|
return nil
|
|
}
|
|
|
|
for _, panel := range panels {
|
|
panelMap, ok := panel.(map[string]interface{})
|
|
if !ok {
|
|
continue
|
|
}
|
|
|
|
wasAngularTable := panelMap["type"] == "table"
|
|
wasReactTable := panelMap["table"] == "table2"
|
|
|
|
if wasAngularTable && panelMap["styles"] == nil {
|
|
continue
|
|
}
|
|
|
|
if !wasAngularTable || wasReactTable {
|
|
continue
|
|
}
|
|
|
|
var currentType string
|
|
if wasAngularTable {
|
|
currentType = "table-old"
|
|
} else {
|
|
currentType = "table"
|
|
}
|
|
|
|
if currentType == "table-old" {
|
|
panelMap["autoMigrateFrom"] = "table-old"
|
|
panelMap["type"] = "table"
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|