Commit cbd28cd2 by Torkel Ödegaard Committed by GitHub

Annotations: Fixes error when trying to create annotation when dashboard is unsaved (#29013)

parent 28383bcf
...@@ -14,7 +14,9 @@ export class EventEditorCtrl { ...@@ -14,7 +14,9 @@ export class EventEditorCtrl {
timeFormated: string; timeFormated: string;
/** @ngInject */ /** @ngInject */
constructor(private annotationsSrv: AnnotationsSrv) { constructor(private annotationsSrv: AnnotationsSrv) {}
$onInit() {
this.event.panelId = this.panelCtrl.panel.id; this.event.panelId = this.panelCtrl.panel.id;
this.event.dashboardId = this.panelCtrl.dashboard.id; this.event.dashboardId = this.panelCtrl.dashboard.id;
......
...@@ -243,11 +243,17 @@ class GraphElement { ...@@ -243,11 +243,17 @@ class GraphElement {
return; return;
} }
if ((pos.ctrlKey || pos.metaKey) && (this.dashboard.meta.canEdit || this.dashboard.meta.canMakeEditable)) { if (pos.ctrlKey || pos.metaKey) {
// Skip if range selected (added in "plotselected" event handler) // Skip if range selected (added in "plotselected" event handler)
if (pos.x !== pos.x1) { if (pos.x !== pos.x1) {
return; return;
} }
// skip if dashboard is not saved yet (exists in db) or user cannot edit
if (!this.dashboard.id || (!this.dashboard.meta.canEdit && !this.dashboard.meta.canMakeEditable)) {
return;
}
setTimeout(() => { setTimeout(() => {
this.eventManager.updateTime({ from: pos.x, to: null }); this.eventManager.updateTime({ from: pos.x, to: null });
}, 100); }, 100);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment