mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboard: removes variables property (#23107)
This commit is contained in:
@@ -627,5 +627,11 @@ e2e.scenario({
|
||||
|
||||
// assert that move up works
|
||||
assertMoveUpItem(queryVariables);
|
||||
|
||||
e2e()
|
||||
.window()
|
||||
.then((win: any) => {
|
||||
logSection('This scenario ran with these featureToggles', win.grafanaBootData.settings.featureToggles);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -94,9 +94,6 @@ exports[`DashboardPage Dashboard init completed Should render dashboard grid 1`
|
||||
"timezone": "",
|
||||
"title": "My dashboard",
|
||||
"uid": null,
|
||||
"variables": Object {
|
||||
"list": Array [],
|
||||
},
|
||||
"version": 0,
|
||||
}
|
||||
}
|
||||
@@ -212,9 +209,6 @@ exports[`DashboardPage Dashboard init completed Should render dashboard grid 1`
|
||||
"timezone": "",
|
||||
"title": "My dashboard",
|
||||
"uid": null,
|
||||
"variables": Object {
|
||||
"list": Array [],
|
||||
},
|
||||
"version": 0,
|
||||
}
|
||||
}
|
||||
@@ -310,9 +304,6 @@ exports[`DashboardPage Dashboard init completed Should render dashboard grid 1`
|
||||
"timezone": "",
|
||||
"title": "My dashboard",
|
||||
"uid": null,
|
||||
"variables": Object {
|
||||
"list": Array [],
|
||||
},
|
||||
"version": 0,
|
||||
}
|
||||
}
|
||||
@@ -438,9 +429,6 @@ exports[`DashboardPage When dashboard has editview url state should render setti
|
||||
"timezone": "",
|
||||
"title": "My dashboard",
|
||||
"uid": null,
|
||||
"variables": Object {
|
||||
"list": Array [],
|
||||
},
|
||||
"version": 0,
|
||||
}
|
||||
}
|
||||
@@ -556,9 +544,6 @@ exports[`DashboardPage When dashboard has editview url state should render setti
|
||||
"timezone": "",
|
||||
"title": "My dashboard",
|
||||
"uid": null,
|
||||
"variables": Object {
|
||||
"list": Array [],
|
||||
},
|
||||
"version": 0,
|
||||
}
|
||||
}
|
||||
@@ -654,9 +639,6 @@ exports[`DashboardPage When dashboard has editview url state should render setti
|
||||
"timezone": "",
|
||||
"title": "My dashboard",
|
||||
"uid": null,
|
||||
"variables": Object {
|
||||
"list": Array [],
|
||||
},
|
||||
"version": 0,
|
||||
}
|
||||
}
|
||||
@@ -758,9 +740,6 @@ exports[`DashboardPage When dashboard has editview url state should render setti
|
||||
"timezone": "",
|
||||
"title": "My dashboard",
|
||||
"uid": null,
|
||||
"variables": Object {
|
||||
"list": Array [],
|
||||
},
|
||||
"version": 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,9 +256,6 @@ exports[`DashboardGrid Can render dashboard grid Should render 1`] = `
|
||||
"timezone": "",
|
||||
"title": "My dashboard",
|
||||
"uid": null,
|
||||
"variables": Object {
|
||||
"list": Array [],
|
||||
},
|
||||
"version": 0,
|
||||
}
|
||||
}
|
||||
@@ -507,9 +504,6 @@ exports[`DashboardGrid Can render dashboard grid Should render 1`] = `
|
||||
"timezone": "",
|
||||
"title": "My dashboard",
|
||||
"uid": null,
|
||||
"variables": Object {
|
||||
"list": Array [],
|
||||
},
|
||||
"version": 0,
|
||||
}
|
||||
}
|
||||
@@ -758,9 +752,6 @@ exports[`DashboardGrid Can render dashboard grid Should render 1`] = `
|
||||
"timezone": "",
|
||||
"title": "My dashboard",
|
||||
"uid": null,
|
||||
"variables": Object {
|
||||
"list": Array [],
|
||||
},
|
||||
"version": 0,
|
||||
}
|
||||
}
|
||||
@@ -1009,9 +1000,6 @@ exports[`DashboardGrid Can render dashboard grid Should render 1`] = `
|
||||
"timezone": "",
|
||||
"title": "My dashboard",
|
||||
"uid": null,
|
||||
"variables": Object {
|
||||
"list": Array [],
|
||||
},
|
||||
"version": 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import { DashboardMigrator } from './DashboardMigrator';
|
||||
import { AppEvent, dateTime, DateTimeInput, isDateTime, PanelEvents, TimeRange, TimeZone, toUtc } from '@grafana/data';
|
||||
import { UrlQueryValue } from '@grafana/runtime';
|
||||
import { CoreEvents, DashboardMeta, KIOSK_MODE_TV } from 'app/types';
|
||||
import { VariableModel } from '../../templating/types';
|
||||
import { getConfig } from '../../../core/config';
|
||||
import { getVariableClones, getVariables } from 'app/features/variables/state/selectors';
|
||||
import { variableAdapters } from 'app/features/variables/adapters';
|
||||
@@ -41,7 +40,6 @@ export class DashboardModel {
|
||||
private originalTime: any;
|
||||
timepicker: any;
|
||||
templating: { list: any[] };
|
||||
variables: { list: VariableModel[] };
|
||||
private originalTemplating: any;
|
||||
annotations: { list: any[] };
|
||||
refresh: any;
|
||||
@@ -93,7 +91,6 @@ export class DashboardModel {
|
||||
this.time = data.time || { from: 'now-6h', to: 'now' };
|
||||
this.timepicker = data.timepicker || {};
|
||||
this.templating = this.ensureListExist(data.templating);
|
||||
this.variables = this.ensureListExist(data.variables);
|
||||
this.annotations = this.ensureListExist(data.annotations);
|
||||
this.refresh = data.refresh;
|
||||
this.snapshot = data.snapshot;
|
||||
@@ -190,9 +187,6 @@ export class DashboardModel {
|
||||
// sort by keys
|
||||
copy = sortByKeys(copy);
|
||||
copy.getVariables = () => {
|
||||
if (getConfig().featureToggles.newVariables) {
|
||||
return copy.variables.list;
|
||||
}
|
||||
return copy.templating.list;
|
||||
};
|
||||
|
||||
@@ -205,6 +199,7 @@ export class DashboardModel {
|
||||
) {
|
||||
if (getConfig().featureToggles.newVariables) {
|
||||
this.updateTemplatingSaveModel(copy, defaults);
|
||||
return;
|
||||
}
|
||||
this.updateAngularTemplatingSaveModel(copy, defaults);
|
||||
}
|
||||
@@ -242,16 +237,16 @@ export class DashboardModel {
|
||||
copy: any,
|
||||
defaults: { saveTimerange: boolean; saveVariables: boolean } & CloneOptions
|
||||
) {
|
||||
const originalVariables = this.variables.list;
|
||||
const originalVariables = this.originalTemplating;
|
||||
const currentVariables = getVariableClones();
|
||||
|
||||
copy.variables = {
|
||||
copy.templating = {
|
||||
list: currentVariables.map(variable => variableAdapters.get(variable.type).getSaveModel(variable)),
|
||||
};
|
||||
|
||||
if (!defaults.saveVariables) {
|
||||
for (let i = 0; i < copy.variables.list.length; i++) {
|
||||
const current = copy.variables.list[i];
|
||||
for (let i = 0; i < copy.templating.list.length; i++) {
|
||||
const current = copy.templating.list[i];
|
||||
const original: any = _.find(originalVariables, { name: current.name, type: current.type });
|
||||
|
||||
if (!original) {
|
||||
@@ -259,9 +254,9 @@ export class DashboardModel {
|
||||
}
|
||||
|
||||
if (current.type === 'adhoc') {
|
||||
copy.variables.list[i].filters = original.filters;
|
||||
copy.templating.list[i].filters = original.filters;
|
||||
} else {
|
||||
copy.variables.list[i].current = original.current;
|
||||
copy.templating.list[i].current = original.current;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -940,21 +935,19 @@ export class DashboardModel {
|
||||
}
|
||||
|
||||
resetOriginalVariables(initial = false) {
|
||||
if (!getConfig().featureToggles.newVariables) {
|
||||
if (!getConfig().featureToggles.newVariables || initial) {
|
||||
this.originalTemplating = this.cloneVariablesFrom(this.templating.list);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!initial && getConfig().featureToggles.newVariables) {
|
||||
// since we never change the this.variables.list when running with variables
|
||||
// in redux we can use it instead of the originalTemplating.
|
||||
this.variables.list = this.cloneVariablesFrom(getVariables());
|
||||
}
|
||||
this.originalTemplating = this.cloneVariablesFrom(getVariableClones());
|
||||
}
|
||||
|
||||
hasVariableValuesChanged() {
|
||||
if (getConfig().featureToggles.newVariables) {
|
||||
return this.hasVariablesChanged(this.variables.list, getVariables());
|
||||
return this.hasVariablesChanged(this.originalTemplating, getVariableClones());
|
||||
}
|
||||
|
||||
return this.hasVariablesChanged(this.originalTemplating, this.templating.list);
|
||||
}
|
||||
|
||||
@@ -1026,7 +1019,7 @@ export class DashboardModel {
|
||||
|
||||
getVariables = () => {
|
||||
if (getConfig().featureToggles.newVariables) {
|
||||
return this.variables.list;
|
||||
return getVariableClones();
|
||||
}
|
||||
return this.templating.list;
|
||||
};
|
||||
|
||||
@@ -24,7 +24,6 @@ import { DashboardModel } from './DashboardModel';
|
||||
import { DataQuery } from '@grafana/data';
|
||||
import { getConfig } from '../../../core/config';
|
||||
import { initDashboardTemplating, processVariables } from '../../variables/state/actions';
|
||||
import { variableAdapters } from '../../variables/adapters';
|
||||
import { emitDashboardViewEvent } from './analyticsProcessor';
|
||||
|
||||
export interface InitDashboardArgs {
|
||||
@@ -186,11 +185,7 @@ export function initDashboard(args: InitDashboardArgs): ThunkResult<void> {
|
||||
await variableSrv.init(dashboard);
|
||||
}
|
||||
if (getConfig().featureToggles.newVariables) {
|
||||
const list =
|
||||
dashboard.variables.list.length > 0
|
||||
? dashboard.variables.list
|
||||
: dashboard.templating.list.filter(v => variableAdapters.getIfExists(v.type));
|
||||
await dispatch(initDashboardTemplating(list));
|
||||
await dispatch(initDashboardTemplating(dashboard.templating.list));
|
||||
await dispatch(processVariables());
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user