Migration v42: HideFrom tooltip consistency migration (#110517)

* Migration to be verified: v42 HideFrom tooltip migration

* snap update

* make gen cue

* Add comments of 42 being the final version
This commit is contained in:
Dominik Prokop
2025-09-05 15:07:30 +02:00
committed by GitHub
parent 801fde02a7
commit b4e63c36c3
59 changed files with 934 additions and 69 deletions
@@ -78,7 +78,7 @@ lineage: schemas: [{
// Version of the JSON schema, incremented each time a Grafana update brings
// changes to said schema.
schemaVersion: uint16 | *41
schemaVersion: uint16 | *42
// Version of the dashboard, incremented each time the dashboard is updated.
version?: uint32
@@ -78,7 +78,7 @@ lineage: schemas: [{
// Version of the JSON schema, incremented each time a Grafana update brings
// changes to said schema.
schemaVersion: uint16 | *41
schemaVersion: uint16 | *42
// Version of the dashboard, incremented each time the dashboard is updated.
version?: uint32
@@ -278,15 +278,15 @@ func TestConversionMetrics(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{UID: "test-uid-2"},
Spec: common.Unstructured{Object: map[string]any{
"title": "test dashboard",
"schemaVersion": 41,
"schemaVersion": 42,
}},
},
target: &dashv0.Dashboard{},
expectSuccess: true,
expectedSourceAPI: dashv1.APIVERSION,
expectedTargetAPI: dashv0.APIVERSION,
expectedSourceSchema: "41",
expectedTargetSchema: "41", // V1→V0 keeps same schema version
expectedSourceSchema: "42",
expectedTargetSchema: "42", // V1→V0 keeps same schema version
},
{
name: "successful v2alpha1 to v2beta1 conversion",
@@ -600,7 +600,7 @@ func TestConversionLogging(t *testing.T) {
"targetVersionAPI": dashv1.APIVERSION,
"dashboardUID": "test-uid-log-1",
"sourceSchemaVersion": "20",
"targetSchemaVersion": fmt.Sprintf("%d", 41), // LATEST_VERSION
"targetSchemaVersion": fmt.Sprintf("%d", 42), // LATEST_VERSION
},
},
{
@@ -620,7 +620,7 @@ func TestConversionLogging(t *testing.T) {
"targetVersionAPI": dashv1.APIVERSION,
"dashboardUID": "test-uid-log-2",
"sourceSchemaVersion": "5",
"targetSchemaVersion": fmt.Sprintf("%d", 41), // LATEST_VERSION
"targetSchemaVersion": fmt.Sprintf("%d", 42), // LATEST_VERSION
},
},
}
@@ -8,7 +8,7 @@ import (
const (
MIN_VERSION = 13
LATEST_VERSION = 41
LATEST_VERSION = 42
// The pluginVersion to set after simulating auto-migrate for angular panels
pluginVersionForAutoMigrate = "12.1.0"
@@ -66,6 +66,7 @@ func GetMigrations(dsInfoProvider DataSourceInfoProvider) map[int]SchemaVersionM
39: V39,
40: V40,
41: V41,
42: V42,
}
}
@@ -0,0 +1,102 @@
package schemaversion
import "context"
// V42 ensures that when a field is hidden from visualization, it is also hidden from tooltips.
//
// This migration addresses the inconsistency where fields could be hidden from visualizations
// (hideFrom.viz = true) but would still appear in tooltips. To prevent user confusion and ensure
// consistent behavior, this migration automatically sets hideFrom.tooltip = true for any field
// configuration override that has hideFrom.viz = true.
//
// The migration specifically targets field configuration overrides, including the special
// __systemRef override, and updates the hideFrom object to include tooltip: true whenever
// viz: true is found.
//
// Example transformation:
//
// Before migration:
//
// fieldConfig: {
// overrides: [{
// properties: [{
// id: "custom.hideFrom",
// value: { viz: true }
// }]
// }]
// }
//
// After migration:
//
// fieldConfig: {
// overrides: [{
// properties: [{
// id: "custom.hideFrom",
// value: { viz: true, tooltip: true }
// }]
// }]
// }
func V42(_ context.Context, dash map[string]interface{}) error {
dash["schemaVersion"] = int(42)
// Get panels from dashboard
panels, ok := dash["panels"].([]interface{})
if !ok {
return nil
}
// Process each panel
for _, panelInterface := range panels {
panel, ok := panelInterface.(map[string]interface{})
if !ok {
continue
}
migrateHideFromForPanel(panel)
}
return nil
}
// migrateHideFromForPanel processes a single panel and its nested panels
func migrateHideFromForPanel(panel map[string]interface{}) {
// Process the panel's field config
if fieldConfig, ok := panel["fieldConfig"].(map[string]interface{}); ok {
if overrides, ok := fieldConfig["overrides"].([]interface{}); ok {
for _, overrideInterface := range overrides {
override, ok := overrideInterface.(map[string]interface{})
if !ok {
continue
}
if properties, ok := override["properties"].([]interface{}); ok {
for _, propertyInterface := range properties {
property, ok := propertyInterface.(map[string]interface{})
if !ok {
continue
}
// Check if this is a custom.hideFrom property
if id, ok := property["id"].(string); ok && id == "custom.hideFrom" {
if value, ok := property["value"].(map[string]interface{}); ok {
// If viz is true, also set tooltip to true
if GetBoolValue(value, "viz") {
value["tooltip"] = true
}
}
}
}
}
}
}
}
// Process nested panels (for rows)
if nestedPanels, ok := panel["panels"].([]interface{}); ok {
for _, nestedPanelInterface := range nestedPanels {
if nestedPanel, ok := nestedPanelInterface.(map[string]interface{}); ok {
migrateHideFromForPanel(nestedPanel)
}
}
}
}
@@ -0,0 +1,422 @@
package schemaversion_test
import (
"testing"
"github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion"
)
func TestV42(t *testing.T) {
tests := []migrationTestCase{
{
name: "hideFrom.viz = true should also set hideFrom.tooltip = true",
input: map[string]interface{}{
"title": "Test Dashboard",
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"title": "Panel 1",
"fieldConfig": map[string]interface{}{
"overrides": []interface{}{
map[string]interface{}{
"matcher": map[string]interface{}{
"id": "byName",
"options": "Field 1",
},
"properties": []interface{}{
map[string]interface{}{
"id": "custom.hideFrom",
"value": map[string]interface{}{
"viz": true,
},
},
},
},
},
},
},
},
},
expected: map[string]interface{}{
"title": "Test Dashboard",
"schemaVersion": 42,
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"title": "Panel 1",
"fieldConfig": map[string]interface{}{
"overrides": []interface{}{
map[string]interface{}{
"matcher": map[string]interface{}{
"id": "byName",
"options": "Field 1",
},
"properties": []interface{}{
map[string]interface{}{
"id": "custom.hideFrom",
"value": map[string]interface{}{
"viz": true,
"tooltip": true,
},
},
},
},
},
},
},
},
},
},
{
name: "hideFrom.viz = false should not change",
input: map[string]interface{}{
"title": "Test Dashboard",
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"title": "Panel 1",
"fieldConfig": map[string]interface{}{
"overrides": []interface{}{
map[string]interface{}{
"properties": []interface{}{
map[string]interface{}{
"id": "custom.hideFrom",
"value": map[string]interface{}{
"viz": false,
},
},
},
},
},
},
},
},
},
expected: map[string]interface{}{
"title": "Test Dashboard",
"schemaVersion": 42,
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"title": "Panel 1",
"fieldConfig": map[string]interface{}{
"overrides": []interface{}{
map[string]interface{}{
"properties": []interface{}{
map[string]interface{}{
"id": "custom.hideFrom",
"value": map[string]interface{}{
"viz": false,
},
},
},
},
},
},
},
},
},
},
{
name: "multiple panels with hideFrom.viz = true",
input: map[string]interface{}{
"title": "Test Dashboard",
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"fieldConfig": map[string]interface{}{
"overrides": []interface{}{
map[string]interface{}{
"properties": []interface{}{
map[string]interface{}{
"id": "custom.hideFrom",
"value": map[string]interface{}{
"viz": true,
},
},
},
},
},
},
},
map[string]interface{}{
"id": 2,
"fieldConfig": map[string]interface{}{
"overrides": []interface{}{
map[string]interface{}{
"properties": []interface{}{
map[string]interface{}{
"id": "custom.hideFrom",
"value": map[string]interface{}{
"viz": true,
"legend": false,
},
},
},
},
},
},
},
},
},
expected: map[string]interface{}{
"title": "Test Dashboard",
"schemaVersion": 42,
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"fieldConfig": map[string]interface{}{
"overrides": []interface{}{
map[string]interface{}{
"properties": []interface{}{
map[string]interface{}{
"id": "custom.hideFrom",
"value": map[string]interface{}{
"viz": true,
"tooltip": true,
},
},
},
},
},
},
},
map[string]interface{}{
"id": 2,
"fieldConfig": map[string]interface{}{
"overrides": []interface{}{
map[string]interface{}{
"properties": []interface{}{
map[string]interface{}{
"id": "custom.hideFrom",
"value": map[string]interface{}{
"viz": true,
"legend": false,
"tooltip": true,
},
},
},
},
},
},
},
},
},
},
{
name: "panel without hideFrom property",
input: map[string]interface{}{
"title": "Test Dashboard",
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"title": "Panel 1",
"fieldConfig": map[string]interface{}{
"overrides": []interface{}{
map[string]interface{}{
"properties": []interface{}{
map[string]interface{}{
"id": "unit",
"value": "short",
},
},
},
},
},
},
},
},
expected: map[string]interface{}{
"title": "Test Dashboard",
"schemaVersion": 42,
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"title": "Panel 1",
"fieldConfig": map[string]interface{}{
"overrides": []interface{}{
map[string]interface{}{
"properties": []interface{}{
map[string]interface{}{
"id": "unit",
"value": "short",
},
},
},
},
},
},
},
},
},
{
name: "nested panels in rows should also be migrated",
input: map[string]interface{}{
"title": "Test Dashboard",
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"type": "row",
"title": "Row 1",
"panels": []interface{}{
map[string]interface{}{
"id": 2,
"fieldConfig": map[string]interface{}{
"overrides": []interface{}{
map[string]interface{}{
"properties": []interface{}{
map[string]interface{}{
"id": "custom.hideFrom",
"value": map[string]interface{}{
"viz": true,
},
},
},
},
},
},
},
},
},
},
},
expected: map[string]interface{}{
"title": "Test Dashboard",
"schemaVersion": 42,
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"type": "row",
"title": "Row 1",
"panels": []interface{}{
map[string]interface{}{
"id": 2,
"fieldConfig": map[string]interface{}{
"overrides": []interface{}{
map[string]interface{}{
"properties": []interface{}{
map[string]interface{}{
"id": "custom.hideFrom",
"value": map[string]interface{}{
"viz": true,
"tooltip": true,
},
},
},
},
},
},
},
},
},
},
},
},
{
name: "__systemRef override should also be migrated",
input: map[string]interface{}{
"title": "Test Dashboard",
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"fieldConfig": map[string]interface{}{
"overrides": []interface{}{
map[string]interface{}{
"__systemRef": "hideSeriesFrom",
"matcher": map[string]interface{}{
"id": "byNames",
"options": map[string]interface{}{
"mode": "exclude",
"names": []interface{}{"foo"},
"prefix": "All except:",
"readOnly": true,
},
},
"properties": []interface{}{
map[string]interface{}{
"id": "custom.hideFrom",
"value": map[string]interface{}{
"legend": false,
"tooltip": false,
"viz": true,
},
},
},
},
},
},
},
},
},
expected: map[string]interface{}{
"title": "Test Dashboard",
"schemaVersion": 42,
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"fieldConfig": map[string]interface{}{
"overrides": []interface{}{
map[string]interface{}{
"__systemRef": "hideSeriesFrom",
"matcher": map[string]interface{}{
"id": "byNames",
"options": map[string]interface{}{
"mode": "exclude",
"names": []interface{}{"foo"},
"prefix": "All except:",
"readOnly": true,
},
},
"properties": []interface{}{
map[string]interface{}{
"id": "custom.hideFrom",
"value": map[string]interface{}{
"legend": false,
"tooltip": true,
"viz": true,
},
},
},
},
},
},
},
},
},
},
{
name: "dashboard without panels",
input: map[string]interface{}{
"title": "Test Dashboard",
},
expected: map[string]interface{}{
"title": "Test Dashboard",
"schemaVersion": 42,
},
},
{
name: "panel without fieldConfig",
input: map[string]interface{}{
"title": "Test Dashboard",
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"title": "Panel 1",
},
},
},
expected: map[string]interface{}{
"title": "Test Dashboard",
"schemaVersion": 42,
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"title": "Panel 1",
},
},
},
},
}
runMigrationTests(t, tests, schemaversion.V42)
}
@@ -0,0 +1,161 @@
{
"title": "v42 Migration Test - HideFrom Tooltip",
"schemaVersion": 41,
"panels": [
{
"id": 1,
"title": "Panel with hideFrom.viz = true",
"type": "timeseries",
"fieldConfig": {
"defaults": {},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Field1"
},
"properties": [
{
"id": "custom.hideFrom",
"value": {
"viz": true
}
}
]
}
]
}
},
{
"id": 2,
"title": "Panel with multiple overrides",
"type": "graph",
"fieldConfig": {
"defaults": {},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Field2"
},
"properties": [
{
"id": "custom.hideFrom",
"value": {
"viz": true,
"legend": false
}
}
]
},
{
"matcher": {
"id": "__systemRef",
"options": "hiddenSeries"
},
"properties": [
{
"id": "custom.hideFrom",
"value": {
"viz": true
}
}
]
}
]
}
},
{
"id": 3,
"type": "row",
"title": "Row with nested panels",
"collapsed": true,
"panels": [
{
"id": 4,
"title": "Nested panel with hideFrom",
"type": "stat",
"fieldConfig": {
"defaults": {},
"overrides": [
{
"matcher": {
"id": "byRegexp",
"options": "/.*/"
},
"properties": [
{
"id": "custom.hideFrom",
"value": {
"viz": true
}
}
]
}
]
}
},
{
"id": 5,
"title": "Panel without hideFrom",
"type": "table",
"fieldConfig": {
"defaults": {},
"overrides": [
{
"properties": [
{
"id": "unit",
"value": "short"
}
]
}
]
}
}
]
},
{
"id": 6,
"title": "Panel with viz false (should not be modified)",
"type": "gauge",
"fieldConfig": {
"defaults": {},
"overrides": [
{
"properties": [
{
"id": "custom.hideFrom",
"value": {
"viz": false,
"tooltip": false
}
}
]
}
]
}
},
{
"id": 7,
"title": "Panel with already set tooltip (should not be modified)",
"type": "barchart",
"fieldConfig": {
"defaults": {},
"overrides": [
{
"properties": [
{
"id": "custom.hideFrom",
"value": {
"viz": true,
"tooltip": false
}
}
]
}
]
}
}
]
}
@@ -125,7 +125,7 @@
}
],
"refresh": "1m",
"schemaVersion": 41,
"schemaVersion": 42,
"style": "dark",
"tags": [
"example-service",
@@ -3886,7 +3886,7 @@
}
],
"refresh": "1m",
"schemaVersion": 41,
"schemaVersion": 42,
"style": "dark",
"tags": [
"example-service",
@@ -3888,7 +3888,7 @@
}
],
"refresh": "1m",
"schemaVersion": 41,
"schemaVersion": 42,
"style": "dark",
"tags": [
"example-service",
@@ -2262,7 +2262,7 @@
}
],
"refresh": "5m",
"schemaVersion": 41,
"schemaVersion": 42,
"style": "dark",
"tags": [
"metrics",
@@ -62,7 +62,7 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"templating": {
"list": [
{
@@ -108,7 +108,7 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"templating": {
"list": [
{
@@ -938,7 +938,7 @@
}
],
"refresh": "30s",
"schemaVersion": 41,
"schemaVersion": 42,
"style": "dark",
"tags": [
"sample-monitoring"
@@ -482,6 +482,6 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"title": "V16 Grid Layout Migration Test Dashboard"
}
@@ -312,6 +312,6 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"title": "V17 MinSpan to MaxPerRow Migration Test Dashboard"
}
@@ -157,6 +157,6 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"title": "V18 Gauge Options Migration Test Dashboard"
}
@@ -201,6 +201,6 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"title": "V19 Panel Links Migration Test Dashboard"
}
@@ -215,7 +215,7 @@
}
],
"refresh": "5s",
"schemaVersion": 41,
"schemaVersion": 42,
"style": "dark",
"tags": [
"migration-test"
@@ -161,6 +161,6 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"title": "V21 Data Links Series to Field Migration Test Dashboard"
}
@@ -88,6 +88,6 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"title": "V22 Table Panel Styles Test"
}
@@ -30,7 +30,7 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"templating": {
"list": [
{
@@ -1369,5 +1369,5 @@
}
],
"refresh": "",
"schemaVersion": 41
}
"schemaVersion": 42
}
@@ -61,7 +61,7 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"templating": {
"list": [
{
@@ -68,5 +68,5 @@
}
],
"refresh": "",
"schemaVersion": 41
"schemaVersion": 42
}
@@ -64,7 +64,7 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"templating": {
"list": [
{
@@ -1,7 +1,7 @@
{
"panels": [],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"templating": {
"list": [
{
@@ -262,7 +262,7 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"templating": {
"list": [
{
@@ -535,7 +535,7 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"templating": {
"list": []
},
@@ -19,7 +19,7 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"templating": {
"list": [
{
@@ -368,6 +368,6 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"title": "V30 Value Mappings and Tooltip Options Migration Test Dashboard"
}
@@ -285,6 +285,6 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"title": "V31 LabelsToFields Merge Migration Test Dashboard"
}
@@ -124,7 +124,7 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"templating": {
"list": [
{
@@ -265,6 +265,6 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"title": "V33 Panel Datasource Name to Ref Test"
}
@@ -634,6 +634,6 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"title": "CloudWatch Multiple Statistics Test Dashboard"
}
@@ -255,6 +255,6 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"title": "X-Axis Visibility Test Dashboard"
}
@@ -322,7 +322,7 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"templating": {
"list": [
{
@@ -125,6 +125,6 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"title": "V37 Legend Normalization Test Dashboard"
}
@@ -218,6 +218,6 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"title": "V38 Table Migration Comprehensive Test Dashboard"
}
@@ -218,6 +218,6 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"title": "V38 Table Migration Test Dashboard"
}
@@ -154,6 +154,6 @@
}
],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"title": "V39 TimeSeriesTable Transformation Migration Test Dashboard"
}
@@ -1,7 +1,7 @@
{
"panels": [],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"time": {
"from": "now-6h",
"to": "now"
@@ -1,7 +1,7 @@
{
"panels": [],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"time": {
"from": "now-6h",
"to": "now"
@@ -1,7 +1,7 @@
{
"panels": [],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"time": {
"from": "now-6h",
"to": "now"
@@ -1,7 +1,7 @@
{
"panels": [],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"time": {
"from": "now-6h",
"to": "now"
@@ -1,7 +1,7 @@
{
"panels": [],
"refresh": "1m",
"schemaVersion": 41,
"schemaVersion": 42,
"time": {
"from": "now-6h",
"to": "now"
@@ -1,7 +1,7 @@
{
"panels": [],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"time": {
"from": "now-6h",
"to": "now"
@@ -1,7 +1,7 @@
{
"panels": [],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"time": {
"from": "now-6h",
"to": "now"
@@ -1,5 +1,5 @@
{
"schemaVersion": 41,
"schemaVersion": 42,
"timepicker": {
"refresh_intervals": [
"5s",
@@ -1,7 +1,7 @@
{
"panels": [],
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"time": {
"from": "now-6h",
"to": "now"
@@ -0,0 +1,165 @@
{
"panels": [
{
"fieldConfig": {
"defaults": {},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Field1"
},
"properties": [
{
"id": "custom.hideFrom",
"value": {
"tooltip": true,
"viz": true
}
}
]
}
]
},
"id": 1,
"title": "Panel with hideFrom.viz = true",
"type": "timeseries"
},
{
"fieldConfig": {
"defaults": {},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Field2"
},
"properties": [
{
"id": "custom.hideFrom",
"value": {
"legend": false,
"tooltip": true,
"viz": true
}
}
]
},
{
"matcher": {
"id": "__systemRef",
"options": "hiddenSeries"
},
"properties": [
{
"id": "custom.hideFrom",
"value": {
"tooltip": true,
"viz": true
}
}
]
}
]
},
"id": 2,
"title": "Panel with multiple overrides",
"type": "graph"
},
{
"collapsed": true,
"id": 3,
"panels": [
{
"fieldConfig": {
"defaults": {},
"overrides": [
{
"matcher": {
"id": "byRegexp",
"options": "/.*/"
},
"properties": [
{
"id": "custom.hideFrom",
"value": {
"tooltip": true,
"viz": true
}
}
]
}
]
},
"id": 4,
"title": "Nested panel with hideFrom",
"type": "stat"
},
{
"fieldConfig": {
"defaults": {},
"overrides": [
{
"properties": [
{
"id": "unit",
"value": "short"
}
]
}
]
},
"id": 5,
"title": "Panel without hideFrom",
"type": "table"
}
],
"title": "Row with nested panels",
"type": "row"
},
{
"fieldConfig": {
"defaults": {},
"overrides": [
{
"properties": [
{
"id": "custom.hideFrom",
"value": {
"tooltip": false,
"viz": false
}
}
]
}
]
},
"id": 6,
"title": "Panel with viz false (should not be modified)",
"type": "gauge"
},
{
"fieldConfig": {
"defaults": {},
"overrides": [
{
"properties": [
{
"id": "custom.hideFrom",
"value": {
"tooltip": true,
"viz": true
}
}
]
}
]
},
"id": 7,
"title": "Panel with already set tooltip (should not be modified)",
"type": "barchart"
}
],
"schemaVersion": 42,
"title": "v42 Migration Test - HideFrom Tooltip"
}
+1 -1
View File
@@ -74,7 +74,7 @@ lineage: schemas: [{
// Version of the JSON schema, incremented each time a Grafana update brings
// changes to said schema.
schemaVersion: uint16 | *41
schemaVersion: uint16 | *42
// Version of the dashboard, incremented each time the dashboard is updated.
version?: uint32
@@ -1209,7 +1209,7 @@ export const defaultDashboard: Partial<Dashboard> = {
graphTooltip: DashboardCursorSync.Off,
links: [],
panels: [],
schemaVersion: 41,
schemaVersion: 42,
tags: [],
timezone: 'browser',
};
+1 -1
View File
@@ -86,7 +86,7 @@ func NewSpec() *Spec {
Editable: (func(input bool) *bool { return &input })(true),
GraphTooltip: (func(input DashboardCursorSync) *DashboardCursorSync { return &input })(DashboardCursorSyncOff),
FiscalYearStartMonth: (func(input uint8) *uint8 { return &input })(0),
SchemaVersion: 41,
SchemaVersion: 42,
}
}
@@ -390,7 +390,7 @@ func runDashboardValidationTests(t *testing.T, ctx TestContext) {
},
"spec": map[string]interface{}{
"title": "Dashboard Title",
"schemaVersion": 41,
"schemaVersion": 42,
"editable": "elephant",
"time": 9000,
"uid": strings.Repeat("a", 100),
@@ -411,7 +411,7 @@ func runDashboardValidationTests(t *testing.T, ctx TestContext) {
},
"spec": map[string]interface{}{
"title": "Dashboard Title",
"schemaVersion": 41,
"schemaVersion": 42,
"editable": "elephant",
"time": 9000,
"uid": strings.Repeat("a", 100),
@@ -1015,7 +1015,7 @@ func createDashboardObject(t *testing.T, title string, folderUID string, generat
},
"spec": map[string]interface{}{
"title": title,
"schemaVersion": 41,
"schemaVersion": 42,
},
},
}
@@ -2038,7 +2038,7 @@ func runDashboardHttpTest(t *testing.T, ctx TestContext, foreignOrgCtx TestConte
},
"spec": {
"title": "%s",
"schemaVersion": 41,
"schemaVersion": 42,
"layout": {
"kind": "GridLayout",
"items": []
@@ -1681,7 +1681,7 @@ const v1ProvisionedDashboardResource = {
},
],
preload: false,
schemaVersion: 41,
schemaVersion: 42,
tags: [],
templating: {
list: [],
@@ -196,7 +196,7 @@ exports[`Given a scene with custom quick ranges should save quick ranges to save
],
"preload": false,
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"tags": [
"gdev",
"graph-ng",
@@ -655,7 +655,7 @@ exports[`transformSceneToSaveModel Given a scene with rows Should transform back
],
"preload": false,
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"tags": [
"templating",
"gdev",
@@ -922,7 +922,7 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
],
"preload": false,
"refresh": "5m",
"schemaVersion": 41,
"schemaVersion": 42,
"tags": [
"tag1",
"tag2",
@@ -1280,7 +1280,7 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
],
"preload": false,
"refresh": "",
"schemaVersion": 41,
"schemaVersion": 42,
"tags": [
"gdev",
"graph-ng",
@@ -73,6 +73,16 @@ type PanelSchemeUpgradeHandler = (panel: PanelModel) => PanelModel;
/**
* The current version of the dashboard schema.
*
* NOTE: Schema version 42 is the FINAL version for the v1 dashboard API.
* DO NOT increment this number or add new schema migrations.
*
* This is necessary due to the migration of the legacy dashboards API to the app platform.
*
* For panel-specific migrations, implement them as panel migrations in the
* individual panel plugin migration handlers instead of adding new schema versions.
*
* Legacy migration instructions (for reference only):
* To add a dashboard migration increment this number
* and then add your migration at the bottom of 'updateSchema'
* hint: search "Add migration here"
@@ -81,7 +91,7 @@ type PanelSchemeUpgradeHandler = (panel: PanelModel) => PanelModel;
* kinds/dashboard/dashboard_kind.cue
* Example PR: #87712
*/
export const DASHBOARD_SCHEMA_VERSION = 41;
export const DASHBOARD_SCHEMA_VERSION = 42;
export class DashboardMigrator {
dashboard: DashboardModel;
@@ -932,9 +942,13 @@ export class DashboardMigrator {
}
/**
* -==- Add migration here -==-
* Your migration should go below the previous
* block and above this (hopefully) helpful message.
* ⚠️ WARNING: DO NOT ADD NEW MIGRATIONS HERE ⚠️
*
* Schema version 42 is the FINAL version for the v1 dashboard API.
* This is due to the migration of the legacy dashboards API to the app platform.
*
* For panel-specific migrations, implement them as panel migrations in the
* individual panel plugin migration handlers instead of adding new schema versions.
*/
if (panelUpgrades.length === 0) {
@@ -25,7 +25,7 @@ import { DashboardModel } from './DashboardModel';
*
* 3. Why DashboardMigrator doesn't run on backendOutput:
* - DashboardMigrator.updateSchema() has an early return: `if (oldVersion === this.dashboard.schemaVersion) return;`
* - Since backendOutput.schemaVersion is already 41 (latest), no migration occurs
* - Since backendOutput.schemaVersion is already 42 (latest), no migration occurs
* - This ensures we compare the final migrated state from both paths
*
* 4. Benefits of this approach: