From baf5a1d1411ee7e5f297aba099e735ebeee3ab83 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Wed, 22 Mar 2023 21:02:36 -0700 Subject: [PATCH] Angular: Rename autoMigrateGraphPanels feature flag to autoMigrateOldPanels (#65243) --- .../dev-dashboards/migrations/migrations.json | 346 ++++++++++++++++++ devenv/jsonnet/dev-dashboards.libsonnet | 7 + .../feature-toggles/index.md | 24 +- .../src/types/featureToggles.gen.ts | 2 +- pkg/services/featuremgmt/registry.go | 4 +- pkg/services/featuremgmt/service.go | 14 +- pkg/services/featuremgmt/toggles_gen.csv | 2 +- pkg/services/featuremgmt/toggles_gen.go | 6 +- .../features/dashboard/state/PanelModel.ts | 4 +- 9 files changed, 384 insertions(+), 25 deletions(-) create mode 100644 devenv/dev-dashboards/migrations/migrations.json diff --git a/devenv/dev-dashboards/migrations/migrations.json b/devenv/dev-dashboards/migrations/migrations.json new file mode 100644 index 00000000000..282052491e2 --- /dev/null +++ b/devenv/dev-dashboards/migrations/migrations.json @@ -0,0 +1,346 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "links": [ + { + "asDropdown": false, + "icon": "dashboard", + "includeVars": false, + "keepTime": false, + "tags": [], + "targetBlank": true, + "title": "Auto migrate (TRUE)", + "tooltip": "", + "type": "link", + "url": "/d/cdd412c4/?__feature.autoMigrateOldPanels=true" + }, + { + "asDropdown": false, + "icon": "external link", + "includeVars": false, + "keepTime": false, + "tags": [], + "targetBlank": true, + "title": "Auto migrate (FALSE)", + "tooltip": "", + "type": "link", + "url": "/d/cdd412c4/?__feature.autoMigrateOldPanels=false" + } + ], + "liveNow": false, + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "testdata", + "uid": "PD8C576611E62080A" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 11, + "w": 15, + "x": 0, + "y": 0 + }, + "hiddenSeries": false, + "id": 4, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "percentage": false, + "pluginVersion": "9.5.0-pre", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "testdata", + "uid": "PD8C576611E62080A" + }, + "refId": "A", + "scenarioId": "random_walk", + "seriesCount": 3 + } + ], + "thresholds": [], + "timeRegions": [], + "title": "Flot graph", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "timeseries", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "logBase": 1, + "show": true + }, + { + "format": "short", + "logBase": 1, + "show": true + } + ], + "yaxis": { + "align": false + } + }, + { + "datasource": { + "type": "testdata", + "uid": "PD8C576611E62080A" + }, + "gridPos": { + "h": 11, + "w": 9, + "x": 15, + "y": 0 + }, + "id": 6, + "options": { + "code": { + "language": "plaintext", + "showLineNumbers": false, + "showMiniMap": false + }, + "content": "# Graph panel >> Timeseries panel\n\nKnown issues:\n* hiding null/empty series\n* time regions", + "mode": "markdown" + }, + "pluginVersion": "9.5.0-pre", + "title": "Status + Notes", + "type": "text" + }, + { + "columns": [], + "datasource": { + "type": "testdata", + "uid": "PD8C576611E62080A" + }, + "fontSize": "100%", + "gridPos": { + "h": 10, + "w": 15, + "x": 0, + "y": 11 + }, + "id": 2, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "showRowNums": false + }, + "pluginVersion": "9.5.0-pre", + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + }, + { + "alias": "", + "align": "right", + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "datasource": { + "type": "testdata", + "uid": "PD8C576611E62080A" + }, + "refId": "A", + "scenarioId": "random_walk_table" + } + ], + "title": "Table (old)", + "transform": "table", + "transformations": [ + { + "id": "merge", + "options": { + "reducers": [] + } + } + ], + "type": "table-old" + }, + { + "datasource": { + "type": "testdata", + "uid": "PD8C576611E62080A" + }, + "gridPos": { + "h": 10, + "w": 9, + "x": 15, + "y": 11 + }, + "id": 7, + "options": { + "code": { + "language": "plaintext", + "showLineNumbers": false, + "showMiniMap": false + }, + "content": "# Table (old) >> Table\n\nKnown issues:\n* wrapping text\n* style changes", + "mode": "markdown" + }, + "pluginVersion": "9.5.0-pre", + "title": "Status + Notes", + "type": "text" + } + ], + "refresh": "", + "schemaVersion": 35, + "style": "dark", + "tags": [ + "gdev", + "migrations", + "angular" + ], + "templating": { + "list": [] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Devenv - Panel migrations", + "uid": "cdd412c4", + "version": 9, + "weekStart": "" + } \ No newline at end of file diff --git a/devenv/jsonnet/dev-dashboards.libsonnet b/devenv/jsonnet/dev-dashboards.libsonnet index 4434c26994d..dbae311f9ce 100644 --- a/devenv/jsonnet/dev-dashboards.libsonnet +++ b/devenv/jsonnet/dev-dashboards.libsonnet @@ -373,6 +373,13 @@ local dashboard = grafana.dashboard; id: 0, } }, + dashboard.new('migrations', import '../dev-dashboards/migrations/migrations.json') + + resource.addMetadata('folder', 'dev-dashboards') + + { + spec+: { + id: 0, + } + }, dashboard.new('mssql_fakedata', import '../dev-dashboards/datasource-mssql/mssql_fakedata.json') + resource.addMetadata('folder', 'dev-dashboards') + { diff --git a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md index f52a3ad6937..18abd6091cb 100644 --- a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md +++ b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md @@ -34,18 +34,18 @@ Some stable features are enabled by default. You can disable a stable feature by ## Beta feature toggles -| Feature toggle name | Description | -| --------------------------------- | ------------------------------------------------------------------------------- | -| `trimDefaults` | Use cue schema to remove values that will be applied automatically | -| `panelTitleSearch` | Search for dashboards using panel title | -| `prometheusAzureOverrideAudience` | Experimental. Allow override default AAD audience for Azure Prometheus endpoint | -| `migrationLocking` | Lock database during migrations | -| `newDBLibrary` | Use jmoiron/sqlx rather than xorm for a few backend services | -| `validateDashboardsOnSave` | Validate dashboard JSON POSTed to api/dashboards/db | -| `autoMigrateGraphPanels` | Replace the angular graph panel with timeseries | -| `topnav` | Displays new top nav and page layouts | -| `accessControlOnCall` | Access control primitives for OnCall | -| `alertingNoNormalState` | Stop maintaining state of alerts that are not firing | +| Feature toggle name | Description | +| --------------------------------- | ---------------------------------------------------------------------------------- | +| `trimDefaults` | Use cue schema to remove values that will be applied automatically | +| `panelTitleSearch` | Search for dashboards using panel title | +| `prometheusAzureOverrideAudience` | Experimental. Allow override default AAD audience for Azure Prometheus endpoint | +| `migrationLocking` | Lock database during migrations | +| `newDBLibrary` | Use jmoiron/sqlx rather than xorm for a few backend services | +| `validateDashboardsOnSave` | Validate dashboard JSON POSTed to api/dashboards/db | +| `autoMigrateOldPanels` | Migrate old angular panels to supported versions (graph, table-old, worldmap, etc) | +| `topnav` | Displays new top nav and page layouts | +| `accessControlOnCall` | Access control primitives for OnCall | +| `alertingNoNormalState` | Stop maintaining state of alerts that are not firing | ## Alpha feature toggles diff --git a/packages/grafana-data/src/types/featureToggles.gen.ts b/packages/grafana-data/src/types/featureToggles.gen.ts index f0a1ab161d6..8753dabbe3e 100644 --- a/packages/grafana-data/src/types/featureToggles.gen.ts +++ b/packages/grafana-data/src/types/featureToggles.gen.ts @@ -43,7 +43,7 @@ export interface FeatureToggles { traceToMetrics?: boolean; newDBLibrary?: boolean; validateDashboardsOnSave?: boolean; - autoMigrateGraphPanels?: boolean; + autoMigrateOldPanels?: boolean; prometheusWideSeries?: boolean; canvasPanelNesting?: boolean; scenes?: boolean; diff --git a/pkg/services/featuremgmt/registry.go b/pkg/services/featuremgmt/registry.go index ac8a478cd74..d4d2241e1b8 100644 --- a/pkg/services/featuremgmt/registry.go +++ b/pkg/services/featuremgmt/registry.go @@ -169,8 +169,8 @@ var ( Owner: grafanaAsCodeSquad, }, { - Name: "autoMigrateGraphPanels", - Description: "Replace the angular graph panel with timeseries", + Name: "autoMigrateOldPanels", + Description: "Migrate old angular panels to supported versions (graph, table-old, worldmap, etc)", State: FeatureStateBeta, FrontendOnly: true, Owner: grafanaDatavizSquad, diff --git a/pkg/services/featuremgmt/service.go b/pkg/services/featuremgmt/service.go index d963d9e2f28..27bcb81c53c 100644 --- a/pkg/services/featuremgmt/service.go +++ b/pkg/services/featuremgmt/service.go @@ -42,11 +42,17 @@ func ProvideManagerService(cfg *setting.Cfg, licensing licensing.Licensing) (*Fe for key, val := range flags { flag, ok := mgmt.flags[key] if !ok { - flag = &FeatureFlag{ - Name: key, - State: FeatureStateUnknown, + switch key { + // renamed the flag so it supports more panels + case "autoMigrateGraphPanels": + flag = mgmt.flags[FlagAutoMigrateOldPanels] + default: + flag = &FeatureFlag{ + Name: key, + State: FeatureStateUnknown, + } + mgmt.flags[key] = flag } - mgmt.flags[key] = flag } flag.Expression = fmt.Sprintf("%t", val) // true | false } diff --git a/pkg/services/featuremgmt/toggles_gen.csv b/pkg/services/featuremgmt/toggles_gen.csv index d2eaa563be5..57c76967ea6 100644 --- a/pkg/services/featuremgmt/toggles_gen.csv +++ b/pkg/services/featuremgmt/toggles_gen.csv @@ -24,7 +24,7 @@ datasourceQueryMultiStatus,alpha,@grafana/plugins-platform-backend,false,false,f traceToMetrics,alpha,@grafana/observability-traces-and-profiling,false,false,false,true newDBLibrary,beta,@grafana/backend-platform,false,false,false,false validateDashboardsOnSave,beta,@grafana/grafana-as-code,false,false,true,false -autoMigrateGraphPanels,beta,@grafana/dataviz-squad,false,false,false,true +autoMigrateOldPanels,beta,@grafana/dataviz-squad,false,false,false,true prometheusWideSeries,alpha,@grafana/observability-metrics,false,false,false,false canvasPanelNesting,alpha,@grafana/dataviz-squad,false,false,false,true scenes,alpha,@grafana/dashboards-squad,false,false,false,true diff --git a/pkg/services/featuremgmt/toggles_gen.go b/pkg/services/featuremgmt/toggles_gen.go index 85dc2ae81fb..fdf4acfe100 100644 --- a/pkg/services/featuremgmt/toggles_gen.go +++ b/pkg/services/featuremgmt/toggles_gen.go @@ -107,9 +107,9 @@ const ( // Validate dashboard JSON POSTed to api/dashboards/db FlagValidateDashboardsOnSave = "validateDashboardsOnSave" - // FlagAutoMigrateGraphPanels - // Replace the angular graph panel with timeseries - FlagAutoMigrateGraphPanels = "autoMigrateGraphPanels" + // FlagAutoMigrateOldPanels + // Migrate old angular panels to supported versions (graph, table-old, worldmap, etc) + FlagAutoMigrateOldPanels = "autoMigrateOldPanels" // FlagPrometheusWideSeries // Enable wide series responses in the Prometheus datasource diff --git a/public/app/features/dashboard/state/PanelModel.ts b/public/app/features/dashboard/state/PanelModel.ts index 579b003fa61..81aa95b3031 100644 --- a/public/app/features/dashboard/state/PanelModel.ts +++ b/public/app/features/dashboard/state/PanelModel.ts @@ -237,13 +237,13 @@ export class PanelModel implements DataConfigSource, IPanelModel { switch (this.type) { case 'graph': - if (config.featureToggles?.autoMigrateGraphPanels || !config.angularSupportEnabled) { + if (config.featureToggles?.autoMigrateOldPanels || !config.angularSupportEnabled) { this.autoMigrateFrom = this.type; this.type = 'timeseries'; } break; case 'table-old': - if (!config.angularSupportEnabled) { + if (config.featureToggles?.autoMigrateOldPanels || !config.angularSupportEnabled) { this.autoMigrateFrom = this.type; this.type = 'table'; }