Skip to content

Commit 649d9f9

Browse files
committed
tech(lodash): upraded lodash to 4.15.0, closes grafana#6021
1 parent 0fa0066 commit 649d9f9

File tree

158 files changed

+6038
-129136
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+6038
-129136
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
### Breaking changes
1717
* **SystemD**: Change systemd description, closes [#5971](https://github.com/grafana/grafana/pull/5971)
18+
* **lodash upgrade**: Upgraded lodash from 2.4.2 to 4.15.0, this contains a number of breaking changes that could effect plugins. closes [#6021](https://github.com/grafana/grafana/pull/6021)
1819

1920
### Bugfixes
2021
* **Table Panel**: Fixed problem when switching to Mixed datasource in metrics tab, fixes [#5999](https://github.com/grafana/grafana/pull/5999)

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
],
1515
"dependencies": {
1616
"jquery": "3.1.0",
17-
"lodash": "~4.15.0",
17+
"lodash": "3.10.1",
1818
"angular": "1.5.3",
1919
"angular-route": "1.5.3",
2020
"angular-mocks": "1.5.3",

public/app/core/components/query_part/query_part.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ export class QueryPart {
5454
// handle optional parameters
5555
// if string contains ',' and next param is optional, split and update both
5656
if (this.hasMultipleParamsInString(strValue, index)) {
57-
_.each(strValue.split(','), function(partVal: string, idx) {
57+
_.each(strValue.split(','), (partVal, idx) => {
5858
this.updateParam(partVal.trim(), idx);
59-
}, this);
59+
});
6060
return;
6161
}
6262

public/app/core/lodash_extended.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function () {
1919
return variable === value ? alt : value;
2020
},
2121
toggleInOut: function(array,value) {
22-
if(_.contains(array,value)) {
22+
if(_.includes(array,value)) {
2323
array = _.without(array,value);
2424
} else {
2525
array.push(value);

public/app/features/dashboard/timeSrv.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ define([
1313
module.service('timeSrv', function($rootScope, $timeout, $routeParams, timer) {
1414
var self = this;
1515

16+
// default time
17+
this.time = {from: '6h', to: 'now'};
18+
1619
$rootScope.$on('zoom-out', function(e, factor) { self.zoomOut(factor); });
1720

1821
this.init = function(dashboard) {

public/app/plugins/datasource/cloudwatch/annotation_query.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function (_) {
4747
var start = self.datasource.convertToCloudWatchTime(from, false);
4848
var end = self.datasource.convertToCloudWatchTime(to, true);
4949
_.chain(alarms)
50-
.pluck('MetricAlarms')
50+
.map('MetricAlarms')
5151
.flatten()
5252
.each(function(alarm) {
5353
if (!alarm) {
@@ -70,7 +70,8 @@ function (_) {
7070

7171
d.resolve(eventList);
7272
});
73-
});
73+
})
74+
.value();
7475
});
7576

7677
return d.promise;
@@ -91,7 +92,7 @@ function (_) {
9192
if (!_.isEmpty(dimensions) && !isSameDimensions) {
9293
return false;
9394
}
94-
if (!_.isEmpty(statistics) && !_.contains(statistics, alarm.Statistic)) {
95+
if (!_.isEmpty(statistics) && !_.includes(statistics, alarm.Statistic)) {
9596
return false;
9697
}
9798
if (!_.isNaN(period) && alarm.Period !== period) {

public/app/plugins/datasource/cloudwatch/datasource.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) {
2323

2424
var queries = [];
2525
options = angular.copy(options);
26-
_.each(options.targets, _.bind(function(target) {
26+
_.each(options.targets, function(target) {
2727
if (target.hide || !target.namespace || !target.metricName || _.isEmpty(target.statistics)) {
2828
return;
2929
}
@@ -43,7 +43,7 @@ function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) {
4343
target.period = query.period;
4444

4545
queries.push(query);
46-
}, this));
46+
}.bind(this));
4747

4848
// No valid targets, return the empty result to save a round trip.
4949
if (_.isEmpty(queries)) {
@@ -54,7 +54,7 @@ function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) {
5454

5555
var allQueryPromise = _.map(queries, function(query) {
5656
return this.performTimeSeriesQuery(query, start, end);
57-
}, this);
57+
}.bind(this));
5858

5959
return $q.all(allQueryPromise).then(function(allResponse) {
6060
var result = [];
@@ -64,7 +64,7 @@ function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) {
6464
result = result.concat(metrics);
6565
});
6666

67-
return { data: result };
67+
return {data: result};
6868
});
6969
};
7070

@@ -125,12 +125,12 @@ function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) {
125125

126126
return this.awsRequest(request).then(function(result) {
127127
return _.chain(result.Metrics)
128-
.pluck('Dimensions')
128+
.map('Dimensions')
129129
.flatten()
130130
.filter(function(dimension) {
131131
return dimension !== null && dimension.Name === dimensionKey;
132132
})
133-
.pluck('Value')
133+
.map('Value')
134134
.uniq()
135135
.sortBy()
136136
.map(function(value) {
@@ -295,15 +295,19 @@ function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) {
295295
namespace: templateSrv.replace(options.namespace, scopedVars),
296296
metric: templateSrv.replace(options.metricName, scopedVars),
297297
};
298+
298299
var aliasDimensions = {};
300+
299301
_.each(_.keys(options.dimensions), function(origKey) {
300302
var key = templateSrv.replace(origKey, scopedVars);
301303
var value = templateSrv.replace(options.dimensions[origKey], scopedVars);
302304
aliasDimensions[key] = value;
303305
});
306+
304307
_.extend(aliasData, aliasDimensions);
305308

306309
var periodMs = options.period * 1000;
310+
307311
return _.map(options.statistics, function(stat) {
308312
var dps = [];
309313
var lastTimestamp = null;
@@ -318,7 +322,8 @@ function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) {
318322
}
319323
lastTimestamp = timestamp;
320324
dps.push([dp[stat], timestamp]);
321-
});
325+
})
326+
.value();
322327

323328
aliasData.stat = stat;
324329
var seriesName = aliasPattern.replace(aliasRegex, function(match, g1) {

public/app/plugins/datasource/graphite/gfunc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ function (_, $) {
688688

689689
return "'" + value + "'";
690690

691-
}, this);
691+
}.bind(this));
692692

693693
if (metricExp) {
694694
parameters.unshift(metricExp);
@@ -711,7 +711,7 @@ function (_, $) {
711711
if (this._hasMultipleParamsInString(strValue, index)) {
712712
_.each(strValue.split(','), function(partVal, idx) {
713713
this.updateParam(partVal.trim(), idx);
714-
}, this);
714+
}.bind(this));
715715
return;
716716
}
717717

public/app/plugins/datasource/mixed/datasource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class MixedDatasource {
2525
});
2626

2727
return this.$q.all(promises).then(function(results) {
28-
return { data: _.flatten(_.pluck(results, 'data')) };
28+
return { data: _.flatten(_.map(results, 'data')) };
2929
});
3030
}
3131
}

public/app/plugins/datasource/prometheus/datasource.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
5858
return escapedValues.join('|');
5959
};
6060

61-
var HTTP_REQUEST_ABORTED = -1;
6261
// Called once per panel (graph)
6362
this.query = function(options) {
6463
var self = this;
@@ -69,10 +68,12 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
6968
var activeTargets = [];
7069

7170
options = _.clone(options);
72-
_.each(options.targets, _.bind(function(target) {
71+
72+
_.each(options.targets, target => {
7373
if (!target.expr || target.hide) {
7474
return;
7575
}
76+
7677
activeTargets.push(target);
7778

7879
var query: any = {};
@@ -90,7 +91,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
9091
}
9192

9293
queries.push(query);
93-
}, this));
94+
});
9495

9596
// No valid targets, return the empty result to save a round trip.
9697
if (_.isEmpty(queries)) {
@@ -99,9 +100,9 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
99100
return d.promise;
100101
}
101102

102-
var allQueryPromise = _.map(queries, _.bind(function(query) {
103+
var allQueryPromise = _.map(queries, query => {
103104
return this.performTimeSeriesQuery(query, start, end);
104-
}, this));
105+
});
105106

106107
return $q.all(allQueryPromise).then(function(allResponse) {
107108
var result = [];
@@ -183,7 +184,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
183184
_.each(results.data.data.result, function(series) {
184185
var tags = _.chain(series.metric)
185186
.filter(function(v, k) {
186-
return _.contains(tagKeys, k);
187+
return _.includes(tagKeys, k);
187188
}).value();
188189

189190
_.each(series.values, function(value) {
@@ -273,7 +274,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
273274
this.getOriginalMetricName = function(labelData) {
274275
var metricName = labelData.__name__ || '';
275276
delete labelData.__name__;
276-
var labelPart = _.map(_.pairs(labelData), function(label) {
277+
var labelPart = _.map(_.toPairs(labelData), function(label) {
277278
return label[0] + '="' + label[1] + '"';
278279
}).join(',');
279280
return metricName + '{' + labelPart + '}';

public/vendor/lodash/.bower.json

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
{
22
"name": "lodash",
3+
"main": "lodash.js",
4+
"ignore": [
5+
".*",
6+
"*.custom.*",
7+
"*.log",
8+
"*.map",
9+
"*.md",
10+
"lodash.src.js",
11+
"component.json",
12+
"package.json",
13+
"doc",
14+
"node_modules",
15+
"perf",
16+
"test",
17+
"vendor"
18+
],
319
"homepage": "https://github.com/lodash/lodash",
4-
"version": "4.15.0",
5-
"_release": "4.15.0",
20+
"version": "3.10.1",
21+
"_release": "3.10.1",
622
"_resolution": {
723
"type": "version",
8-
"tag": "4.15.0",
9-
"commit": "e538563f2cf208980f24cda75ba21fabf939a604"
24+
"tag": "3.10.1",
25+
"commit": "ef20b4290cc4fe7551c82a552ea7ffa76548eec8"
1026
},
1127
"_source": "https://github.com/lodash/lodash.git",
12-
"_target": "~4.15.0",
28+
"_target": "3.10.1",
1329
"_originalSource": "lodash"
1430
}

public/vendor/lodash/.editorconfig

Lines changed: 0 additions & 12 deletions
This file was deleted.

public/vendor/lodash/.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/vendor/lodash/.github/CONTRIBUTING.md

Lines changed: 0 additions & 78 deletions
This file was deleted.

public/vendor/lodash/.gitignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)