grafana-dash-gen 3.3.1 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -70,12 +70,6 @@ Dashboard.prototype._initRows = function _initRows(opts) {
70
70
  Dashboard.prototype._initLinks = function _initLinks(opts) {
71
71
  this.links = opts.links || [];
72
72
  this.state.links = [];
73
-
74
- this.links.forEach(link => {
75
- if (!(link instanceof ExternalLink)) {
76
- throw new TypeError('links must be defined using ExternalLink')
77
- }
78
- })
79
73
  };
80
74
 
81
75
  Dashboard.prototype._initTemplating = function _initRows(opts) {
@@ -125,7 +119,12 @@ Dashboard.prototype.addAnnotation = function addAnnotation(annotation) {
125
119
  Dashboard.prototype.generate = function generate() {
126
120
  // Generate jsons.
127
121
  this.state.rows = this.rows.map(row => row.generate());
128
- this.state.links = this.links.map(link => link.generate());
122
+ this.state.links = this.links.map(link => {
123
+ if (link instanceof ExternalLink) {
124
+ return link.generate()
125
+ }
126
+ return link
127
+ });
129
128
 
130
129
  return this.state;
131
130
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grafana-dash-gen",
3
- "version": "3.3.1",
3
+ "version": "3.3.2",
4
4
  "description": "A grafana dashboard generator",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/test/dashboard.js CHANGED
@@ -109,7 +109,17 @@ test('Dashboard can generate correct body', function t(assert) {
109
109
  new ExternalLink({
110
110
  title: "Uber Homepage",
111
111
  url: "www.uber.com",
112
- })
112
+ }),
113
+ {
114
+ title: "Google Homepage",
115
+ tooltip: "",
116
+ url: "www.google.com",
117
+ icon: "external link",
118
+ targetBlank: true,
119
+ type: "link",
120
+ includeVars: false,
121
+ keepTime: false,
122
+ }
113
123
  ]
114
124
  });
115
125
  var row = {
@@ -134,16 +144,19 @@ test('Dashboard can generate correct body', function t(assert) {
134
144
  type: "link",
135
145
  includeVars: false,
136
146
  keepTime: false,
147
+ },
148
+ {
149
+ title: "Google Homepage",
150
+ tooltip: "",
151
+ url: "www.google.com",
152
+ icon: "external link",
153
+ targetBlank: true,
154
+ type: "link",
155
+ includeVars: false,
156
+ keepTime: false,
137
157
  }
138
158
  ]
139
159
  }
140
160
  assert.deepEqual(json, expectedJson);
141
161
  assert.end();
142
162
  });
143
-
144
- test('Dashboard throws error if links are defined with wrong type', function t(assert) {
145
- assert.throws(() => new Dashboard({
146
- links: [{ title: "custom link", url: "www.wrong.com"}]
147
- }), new TypeError('links must be defined using ExternalLink'))
148
- assert.end();
149
- });