Skip to content

Commit

Permalink
Fix issue with upgrading panels from version 2.3.0 and older (#63)
Browse files Browse the repository at this point in the history
* Fix issue with upgrading panels from version 2.3.0 and older

* linting
  • Loading branch information
yanscalyr authored Jan 4, 2021
1 parent dfbb312 commit 7073038
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.3.2

Fix issue with migrating panels from versions 2.3.0 and older to version 2.3.1 (TBD) (Yan Shnayder)

## 2.3.1

Align terminology with Scalyr API (#59) (Rein Achten)
Expand Down
4 changes: 2 additions & 2 deletions dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ can find documentation on API Keys [here](https://www.scalyr.com/help/api#scalyr

```bash
grafana-cli --pluginUrl \
https://github.com/scalyr/scalyr-grafana-datasource-plugin/releases/download/2.3.1/scalyr_grafana_plugin_d8e1e08.zip \
https://github.com/scalyr/scalyr-grafana-datasource-plugin/releases/download/2.3.1/scalyr_grafana_plugin_31da5c7.zip \
plugins install scalyr-datasource
```

Expand Down Expand Up @@ -78,7 +78,7 @@ from GitHub.
Stable version:

```bash
tar -xvf scalyr_grafana_plugin_d8e1e08.tar.gz
tar -xvf scalyr_grafana_plugin_31da5c7.tar.gz
cp -rf dist/ /var/lib/grafana/plugins/scalyr/
```

Expand Down
4 changes: 2 additions & 2 deletions dist/module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "Scalyr",
"id": "scalyr-datasource",
"info": {
"version": "2.3.1",
"version": "2.3.2",
"description": "Scalyr Observability Platform",
"author": {
"name": "Scalyr",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scalyr-grafana-datasource-plugin",
"version": "2.3.1",
"version": "2.3.2",
"description": "This grafana plugin allows Scalyr as a datasource for metrics and graphs",
"main": "webpack.config.js",
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions src/datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export class GenericDatasource {
* @param {*} options - query settings/options https://grafana.com/docs/plugins/developing/datasources/#query
*/
query(options) {
// Migrate filters from versions 2.3.0 and older
for (let i = 0; i < options.targets.length; i += 1) {
if (options.targets[i].queryText) {
options.targets[i].filter = options.targets[i].queryText;
options.targets[i].queryText = null;
}
}

const queryType = options.targets[0].queryType;
if (!options.targets.every(x => x.queryType === queryType)) {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "Scalyr",
"id": "scalyr-datasource",
"info": {
"version": "2.3.1",
"version": "2.3.2",
"description": "Scalyr Observability Platform",
"author": {
"name": "Scalyr",
Expand Down
6 changes: 6 additions & 0 deletions src/query_ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export class GenericDatasourceQueryCtrl extends QueryCtrl {
this.target.dataLink = createDataLinkURL(this.target.queryText, this.getScalyrDatasourceUrl());

this.target.copyText = "Copy";

// Migrate filters from versions 2.3.0 and older
if (this.target.queryText) {
this.target.filter = this.target.queryText;
this.target.queryText = null;
}
}

/**
Expand Down

0 comments on commit 7073038

Please sign in to comment.