Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grafana 8: Don't croak when unable to load/access KeybindingSrv #104

Merged
merged 1 commit into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## development
- Add compatibility with Grafana 8

## v0.15.0
- Support multiple metrics in popup content for Elasticsearch. Thanks, @matschaffer!
Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ The easiest way to invoke a development sandbox is by using Docker.
```shell
# Run with Grafana 7
docker run --publish=3000:3000 --volume=$PWD/dist:/var/lib/grafana/plugins/grafana-map-panel grafana/grafana:7.5.7

# Run with Grafana 8
docker run --publish=3000:3000 --volume=$PWD/dist:/var/lib/grafana/plugins/grafana-map-panel --env=GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=grafana-map-panel grafana/grafana:8.0.0
```

Because the version of `node-sass` used as transitive dependency is apparently
Expand Down
12 changes: 10 additions & 2 deletions src/chrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,19 @@ export class WorldmapChrome {
* - https://github.com/daq-tools/grafanimate/blob/0.5.5/grafanimate/grafana-studio.js
*
*/
this.getKeybindingSrv().unbind('esc', 'keydown');
try {
this.getKeybindingSrv().unbind('esc', 'keydown');
} catch (err) {
console.error(`Accessing KeybindingSrv not implemented for Grafana 8 yet.\n${err}`);
}
}

restoreEscapeKeyBinding() {
this.getKeybindingSrv().setupGlobal();
try {
this.getKeybindingSrv().setupGlobal();
} catch (err) {
console.error(`Accessing KeybindingSrv not implemented for Grafana 8 yet.\n${err}`);
}
}

getKeybindingSrv() {
Expand Down
4 changes: 4 additions & 0 deletions src/worldmap_ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,10 @@ export default class WorldmapCtrl extends MetricsPanelCtrl {
this.panel.snapshotLocationData = this.locations;
}

console.info('Processing data');
this.processData(dataList);

console.info('Updating color mode');
this.updateColorMode();

const autoCenterMap =
Expand Down Expand Up @@ -504,6 +506,8 @@ export default class WorldmapCtrl extends MetricsPanelCtrl {

resetData() {
this.data = [];
this.data.categories = [];
this.data.thresholds = [];
//this.mapCenterMoved = true;
}

Expand Down