fix: compatibility with Grafana 7.4

This commit is contained in:
Ivan Mikheykin
2021-02-16 17:43:48 +03:00
parent e987dee850
commit cf28c74069
5 changed files with 13 additions and 7 deletions
+6
View File
@@ -8,6 +8,12 @@ import { Emitter } from 'grafana/app/core/utils/emitter';
// This method detects this behaviour and return true
// only for new Grafana versions.
export function hasAppEventCompatibleEmitter(emitter: Emitter): boolean {
// Grafana 7.4 has new event bus for Angular plugins. It is has a 'subscribe' method.
let emitterProto = Object.getPrototypeOf(emitter);
if (Object.prototype.hasOwnProperty.call(emitterProto, 'subscribe')) {
return true;
}
let receiveEvents = 0;
let eventId: any = { name: 'non-existed-event-id' };
let eventId2: any = { name: 'non-existed-event-id-2' };
-1
View File
@@ -72,7 +72,6 @@ class StatusHeatmapCtrl extends MetricsPanelCtrl {
bucketMatrixPager: BucketMatrixPager;
graph: any;
discreteHelper: ColorModeDiscrete;
opacityScales: any = [];
colorModes: any = [];
colorSchemes: any = [];
+5 -4
View File
@@ -1,9 +1,9 @@
import _ from 'lodash';
import $ from 'jquery';
// TODO moment is used instead of @grafana/data to run in 6.2 and earlier.
/* eslint-disable id-blacklist, no-restricted-imports, @typescript-eslint/ban-types */
// import moment from 'moment';
import { toUtc } from '@grafana/data';
import moment from 'moment';
import kbn from 'grafana/app/core/utils/kbn';
import { appEvents, contextSrv } from 'grafana/app/core/core';
@@ -643,9 +643,10 @@ export class StatusmapRenderer {
Math.max(this.selection.x1, this.selection.x2) - this.yAxisWidth - this.xGridSize / 2
);
// TODO use toUtc method from moment wrapper in @grafana/data
this.ctrl.timeSrv.setTime({
from: toUtc(timeFrom),
to: toUtc(timeTo),
from: moment.utc(timeFrom),
to: moment.utc(timeTo),
});
}