* 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 * migrate to v12 * extract defaults outside the func * lint * lint * add missing showValues prop * update * add context and fix latest version * add context * generate snapshots * v13 should be no-op * clean up * fix tests * fix test * 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 * es int --------- Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
package schemaversion
|
|
|
|
import "context"
|
|
|
|
// V12 migrates template variables to update their refresh and hide properties.
|
|
// This migration ensures that:
|
|
// 1. Variables with refresh=true get refresh=1, and variables with refresh=false get refresh=0
|
|
// 2. Variables with hideVariable=true get hide=2 (hide variable)
|
|
// 3. Variables with hideLabel=true get hide=1 (hide label)
|
|
//
|
|
// Example before migration:
|
|
//
|
|
// "templating": {
|
|
// "list": [
|
|
// { "type": "query", "name": "var1", "refresh": true, "hideVariable": true },
|
|
// { "type": "query", "name": "var2", "refresh": false, "hideLabel": true }
|
|
// ]
|
|
// }
|
|
//
|
|
// Example after migration:
|
|
//
|
|
// "templating": {
|
|
// "list": [
|
|
// { "type": "query", "name": "var1", "refresh": 1, "hide": 2 },
|
|
// { "type": "query", "name": "var2", "refresh": 0, "hide": 1 }
|
|
// ]
|
|
// }
|
|
func V12(_ context.Context, dashboard map[string]interface{}) error {
|
|
dashboard["schemaVersion"] = 12
|
|
|
|
templating, ok := dashboard["templating"].(map[string]interface{})
|
|
if !ok {
|
|
return nil
|
|
}
|
|
|
|
list, ok := templating["list"].([]interface{})
|
|
if !ok {
|
|
return nil
|
|
}
|
|
|
|
for _, v := range list {
|
|
variable, ok := v.(map[string]interface{})
|
|
if !ok {
|
|
continue
|
|
}
|
|
|
|
// Update refresh property
|
|
if _, hasRefresh := variable["refresh"]; hasRefresh {
|
|
if GetBoolValue(variable, "refresh") {
|
|
variable["refresh"] = 1
|
|
} else {
|
|
variable["refresh"] = 0
|
|
}
|
|
}
|
|
|
|
// Update hide property based on hideVariable and hideLabel
|
|
// hideVariable takes priority over hideLabel
|
|
if GetBoolValue(variable, "hideVariable") {
|
|
variable["hide"] = 2
|
|
} else if GetBoolValue(variable, "hideLabel") {
|
|
variable["hide"] = 1
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|