triggers panel: tests for schema migration

This commit is contained in:
Alexander Zobnin
2017-12-03 12:31:56 +03:00
parent b214705052
commit 5359176f2a
17 changed files with 1345 additions and 976 deletions

View File

@@ -4,11 +4,20 @@ System.register([], function (_export, _context) {
"use strict";
function migratePanelSchema(panel) {
if (isEmptyPanel(panel)) {
return panel;
}
var schemaVersion = getSchemaVersion(panel);
switch (schemaVersion) {
case 1:
panel.datasources = [panel.datasource];
panel.targets = {};
panel.targets[panel.datasources[0]] = panel.triggers;
// delete old props
delete panel.triggers;
delete panel.datasource;
break;
}
@@ -20,6 +29,10 @@ System.register([], function (_export, _context) {
function getSchemaVersion(panel) {
return panel.schemaVersion || 1;
}
function isEmptyPanel(panel) {
return !panel.datasource && !panel.datasources && !panel.triggers && !panel.targets;
}
return {
setters: [],
execute: function () {}