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

This commit is contained in:
Torkel Ödegaard 2020-11-11 12:18:45 +01:00 committed by GitHub
parent 28383bcfac
commit cbd28cd28b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -14,7 +14,9 @@ export class EventEditorCtrl {
timeFormated: string;
/** @ngInject */
constructor(private annotationsSrv: AnnotationsSrv) {
constructor(private annotationsSrv: AnnotationsSrv) {}
$onInit() {
this.event.panelId = this.panelCtrl.panel.id;
this.event.dashboardId = this.panelCtrl.dashboard.id;

View File

@ -243,11 +243,17 @@ class GraphElement {
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)
if (pos.x !== pos.x1) {
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(() => {
this.eventManager.updateTime({ from: pos.x, to: null });
}, 100);