mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Angular: auto-migrate graph panel when angular is disabled (#59247)
This commit is contained in:
parent
5fe35e4860
commit
5888f53aab
@ -37,6 +37,7 @@ jest.mock('@grafana/runtime', () => ({
|
|||||||
featureToggles: {
|
featureToggles: {
|
||||||
newVariables: false,
|
newVariables: false,
|
||||||
},
|
},
|
||||||
|
angularSupportEnabled: true,
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -237,11 +237,17 @@ export class PanelModel implements DataConfigSource, IPanelModel {
|
|||||||
|
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
case 'graph':
|
case 'graph':
|
||||||
if (config?.featureToggles?.autoMigrateGraphPanels) {
|
if (config.featureToggles?.autoMigrateGraphPanels || !config.angularSupportEnabled) {
|
||||||
this.autoMigrateFrom = this.type;
|
this.autoMigrateFrom = this.type;
|
||||||
this.type = 'timeseries';
|
this.type = 'timeseries';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'table-old':
|
||||||
|
if (!config.angularSupportEnabled) {
|
||||||
|
this.autoMigrateFrom = this.type;
|
||||||
|
this.type = 'table';
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'heatmap-new':
|
case 'heatmap-new':
|
||||||
this.autoMigrateFrom = this.type;
|
this.autoMigrateFrom = this.type;
|
||||||
this.type = 'heatmap';
|
this.type = 'heatmap';
|
||||||
@ -416,7 +422,7 @@ export class PanelModel implements DataConfigSource, IPanelModel {
|
|||||||
const version = getPluginVersion(plugin);
|
const version = getPluginVersion(plugin);
|
||||||
|
|
||||||
if (this.autoMigrateFrom) {
|
if (this.autoMigrateFrom) {
|
||||||
const wasAngular = this.autoMigrateFrom === 'graph';
|
const wasAngular = this.autoMigrateFrom === 'graph' || this.autoMigrateFrom === 'table-old';
|
||||||
this.callPanelTypeChangeHandler(
|
this.callPanelTypeChangeHandler(
|
||||||
plugin,
|
plugin,
|
||||||
this.autoMigrateFrom,
|
this.autoMigrateFrom,
|
||||||
|
@ -7,6 +7,7 @@ import angular from 'angular';
|
|||||||
import { configure } from 'enzyme';
|
import { configure } from 'enzyme';
|
||||||
|
|
||||||
import { EventBusSrv } from '@grafana/data';
|
import { EventBusSrv } from '@grafana/data';
|
||||||
|
import { GrafanaBootConfig } from '@grafana/runtime';
|
||||||
import 'blob-polyfill';
|
import 'blob-polyfill';
|
||||||
import 'mutationobserver-shim';
|
import 'mutationobserver-shim';
|
||||||
import './mocks/workers';
|
import './mocks/workers';
|
||||||
@ -18,6 +19,16 @@ const testAppEvents = new EventBusSrv();
|
|||||||
const global = window as any;
|
const global = window as any;
|
||||||
global.$ = global.jQuery = $;
|
global.$ = global.jQuery = $;
|
||||||
|
|
||||||
|
// mock the default window.grafanaBootData settings
|
||||||
|
const settings: Partial<GrafanaBootConfig> = {
|
||||||
|
angularSupportEnabled: true,
|
||||||
|
};
|
||||||
|
global.grafanaBootData = {
|
||||||
|
settings,
|
||||||
|
user: {},
|
||||||
|
navTree: [],
|
||||||
|
};
|
||||||
|
|
||||||
// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
|
// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
|
||||||
Object.defineProperty(global, 'matchMedia', {
|
Object.defineProperty(global, 'matchMedia', {
|
||||||
writable: true,
|
writable: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user