Skip to content

Commit

Permalink
Problems: fix empty query editor, #988
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderzobnin committed Nov 17, 2020
1 parent 6b1067a commit 0de6403
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/panel-triggers/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export function getDefaultTargetOptions() {
}

export function migratePanelSchema(panel) {
if (isDefaultPanel(panel)) {
return panel;
}

if (isEmptyPanel(panel)) {
delete panel.targets;
return panel;
Expand Down Expand Up @@ -160,6 +164,14 @@ function isEmptyTargets(targets) {
return !targets || (_.isArray(targets) && (targets.length === 0 || targets.length === 1 && _.isEmpty(targets[0])));
}

function isDefaultPanel(panel) {
return panel.targets && panel.targets.length === 1 && isDefaultTarget(panel.targets[0]);
}

function isDefaultTarget(target) {
return !target.group?.filter && !target.host?.filter && !target.application?.filter && !target.trigger?.filter && !target.queryType;
}

function isEmptyTarget(target) {
return !target || !(target.group && target.host && target.application && target.trigger);
}
Expand Down
1 change: 1 addition & 0 deletions src/panel-triggers/triggers_panel_ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const DEFAULT_TIME_FORMAT = "DD MMM YYYY HH:mm:ss";

export const PANEL_DEFAULTS = {
schemaVersion: CURRENT_SCHEMA_VERSION,
targets: [{}],
// Fields
hostField: true,
hostTechNameField: false,
Expand Down

0 comments on commit 0de6403

Please sign in to comment.