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

[backport] PR #6909 to 4.5 #6930

Merged
merged 1 commit into from
Apr 14, 2016
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
6 changes: 3 additions & 3 deletions src/ui/public/StackTraceMapper/SourceMapReader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var _ = require('lodash');
var SourceMapConsumer = require('source-map/lib/source-map/source-map-consumer').SourceMapConsumer;
var parse = require('url').parse;
let _ = require('lodash');
let SourceMapConsumer = require('source-map/lib/source-map/source-map-consumer').SourceMapConsumer;
let parse = require('url').parse;

function SourceMapReader(url, map) {
this.smc = new SourceMapConsumer(map);
Expand Down
22 changes: 11 additions & 11 deletions src/ui/public/StackTraceMapper/StackTraceMapper.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var _ = require('lodash');
var $ = require('jquery');
var resolve = require('bluebird').resolve;
var fetch = require('exports?window.fetch!imports?Promise=bluebird!whatwg-fetch');
let _ = require('lodash');
let $ = require('jquery');
let resolve = require('bluebird').resolve;
let fetch = require('exports?window.fetch!imports?Promise=bluebird!whatwg-fetch');

var setErrorStack = require('./setErrorStack');
var translateStackLine = require('./translateStackLine');
var stackLineFormat = require('./stackLineFormat');
var SourceMapReader = require('./SourceMapReader');
let setErrorStack = require('./setErrorStack');
let translateStackLine = require('./translateStackLine');
let stackLineFormat = require('./stackLineFormat');
let SourceMapReader = require('./SourceMapReader');

function StackTraceMapper() {
this.maps = [];
Expand All @@ -22,7 +22,7 @@ StackTraceMapper.prototype.init = function (mapUrls) {
StackTraceMapper.prototype.mapError = function (err) {
if (!stackLineFormat || !err.stack) return err;

var stack = err.stack.replace(stackLineFormat, this.mapLine);
let stack = err.stack.replace(stackLineFormat, this.mapLine);
return setErrorStack(err, stack);
};

Expand All @@ -39,10 +39,10 @@ StackTraceMapper.prototype.getMapFor = function (url) {
StackTraceMapper.prototype.loadMaps = function (mapUrls) {
mapUrls = _.clone(mapUrls || {});

var maps = this.maps;
let maps = this.maps;

$('script[src][src-map]').each(function () {
var $el = $(this);
let $el = $(this);
mapUrls[$el.attr('src')] = $el.attr('src-map');
});

Expand Down
6 changes: 3 additions & 3 deletions src/ui/public/StackTraceMapper/setErrorStack.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var _ = require('lodash');
let _ = require('lodash');

var err = new Error();
let err = new Error();
try { setByAssignment(err, 'john'); } catch (e) {} // eslint-disable-line

// err.stack is not always writeable, so we
Expand All @@ -13,7 +13,7 @@ if (err.stack === 'john') module.exports = setByAssignment;
else module.exports = setByShadowing;

function setByShadowing(err, stack) {
var props = _.mapValues(err, function (val) {
let props = _.mapValues(err, function (val) {
return {
enumerable: true,
value: val
Expand Down
6 changes: 3 additions & 3 deletions src/ui/public/StackTraceMapper/stackLineFormat.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
var _ = require('lodash');
let _ = require('lodash');

var opts = [
let opts = [
/@((?:[!#$&-;=?-\[\]_a-z~]|%[0-9a-f]{2})+\.js)\:(\d+)(?:\:(\d+)|())/ig,
/(?: \(|at )((?:[!#$&-;=?-\[\]_a-z~]|%[0-9a-f]{2})+\.js)\:(\d+)(?:\:(\d+)|())/ig
];

let sample;
try { throw new Error('msg'); } catch (e) { sample = e.stack; }

var format = _.find(opts, function (format) {
let format = _.find(opts, function (format) {
return format.test(sample);
});

Expand Down
20 changes: 10 additions & 10 deletions src/ui/public/StackTraceMapper/translateStackLine.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
var _ = require('lodash');
let _ = require('lodash');

module.exports = function (map, match, filename, line, col) {
if (!map) return match;

var position = {
let position = {
line: parseFloat(line) || 0,
column: parseFloat(col) || 0
};

var srcPosition = map.smc.originalPositionFor(position);
let srcPosition = map.smc.originalPositionFor(position);
if (!srcPosition || !srcPosition.source) return match;

var srcFilename = srcPosition.source;
var srcLine = srcPosition.line;
var srcCol = srcPosition.column;
let srcFilename = srcPosition.source;
let srcLine = srcPosition.line;
let srcCol = srcPosition.column;

if (srcCol === 0 && position.column) {
// TODO: teach sourcemaps correct column
Expand All @@ -26,10 +26,10 @@ module.exports = function (map, match, filename, line, col) {
// fold the components into the original match, so that supporting
// characters (parens, periods, etc) from the format are kept, and so
// we don't accidentally replace the wrong part we use splitting and consumption
var resp = '';
var remainingResp = match;
var fold = function (replace, replacement) {
var wrappingContent = remainingResp.split(replace);
let resp = '';
let remainingResp = match;
let fold = function (replace, replacement) {
let wrappingContent = remainingResp.split(replace);
resp += wrappingContent.shift() + replacement;
remainingResp = wrappingContent.join(replace);
};
Expand Down
14 changes: 7 additions & 7 deletions src/ui/public/paginated_table/paginated_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ define(function (require) {
require('ui/modules')
.get('kibana')
.directive('paginatedTable', function ($filter) {
var _ = require('lodash');
var orderBy = $filter('orderBy');
let _ = require('lodash');
let orderBy = $filter('orderBy');

return {
restrict: 'E',
Expand All @@ -18,14 +18,14 @@ define(function (require) {
},
controllerAs: 'paginatedTable',
controller: function ($scope) {
var self = this;
let self = this;
self.sort = {
columnIndex: null,
direction: null
};

self.sortColumn = function (colIndex) {
var col = $scope.columns[colIndex];
let col = $scope.columns[colIndex];

if (!col) return;
if (col.sortable === false) return;
Expand All @@ -35,7 +35,7 @@ define(function (require) {
if (self.sort.columnIndex !== colIndex) {
sortDirection = 'asc';
} else {
var directions = {
let directions = {
null: 'asc',
'asc': 'desc',
'desc': null
Expand All @@ -55,7 +55,7 @@ define(function (require) {
} else {
// use generic sort handler
self.sort.getter = function (row) {
var value = row[index];
let value = row[index];
if (value && value.value != null) return value.value;
return value;
};
Expand All @@ -73,7 +73,7 @@ define(function (require) {
return;
}

var sort = self.sort;
let sort = self.sort;
if (sort.direction == null) {
$scope.sortedRows = $scope.rows.slice(0);
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/ui/public/parse_query/lib/from_user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
define(function (require) {
var _ = require('lodash');
let _ = require('lodash');
return function GetQueryFromUser(es, Private) {
var decorateQuery = Private(require('ui/courier/data_source/_decorate_query'));
let decorateQuery = Private(require('ui/courier/data_source/_decorate_query'));

/**
* Take text from the user and make it into a query object
Expand All @@ -13,7 +13,7 @@ define(function (require) {
return decorateQuery({query_string: {query: text}});
}

var matchAll = getQueryStringQuery('*');
let matchAll = getQueryStringQuery('*');

// If we get an empty object, treat it as a *
if (_.isObject(text)) {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/parse_query/lib/to_user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define(function (require) {
var _ = require('lodash');
var angular = require('angular');
let _ = require('lodash');
let angular = require('angular');

/**
* Take text from the model and present it to the user as a string
Expand Down
6 changes: 3 additions & 3 deletions src/ui/public/parse_query/parse_query.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ define(function (require) {
require('ui/modules')
.get('kibana')
.directive('parseQuery', function (Private) {
var fromUser = Private(require('ui/parse_query/lib/from_user'));
var toUser = require('ui/parse_query/lib/to_user');
let fromUser = Private(require('ui/parse_query/lib/from_user'));
let toUser = require('ui/parse_query/lib/to_user');

return {
restrict: 'A',
Expand All @@ -12,7 +12,7 @@ define(function (require) {
'ngModel': '='
},
link: function ($scope, elem, attr, ngModel) {
var init = function () {
let init = function () {
$scope.ngModel = fromUser($scope.ngModel);
};

Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/persisted_log/persisted_log.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define(function (require) {
var modules = require('ui/modules');
var _ = require('lodash');
let modules = require('ui/modules');
let _ = require('lodash');

modules.get('kibana/persisted_log')
.factory('PersistedLog', function ($window, localStorage) {
Expand Down
62 changes: 31 additions & 31 deletions src/ui/public/persisted_state/persisted_state.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
define(function (require) {
var _ = require('lodash');
var toPath = require('lodash/internal/toPath');
var errors = require('ui/errors');
let _ = require('lodash');
let toPath = require('lodash/internal/toPath');
let errors = require('ui/errors');

return function (Private) {
var Events = Private(require('ui/events'));
var SimpleEmitter = require('ui/utils/SimpleEmitter');
let Events = Private(require('ui/events'));
let SimpleEmitter = require('ui/utils/SimpleEmitter');

function validateParent(parent, path) {
if (path.length <= 0) {
Expand All @@ -17,7 +17,7 @@ define(function (require) {
}

function validateValue(value) {
var msg = 'State value must be a plain object';
let msg = 'State value must be a plain object';
if (!value) return;
if (!_.isPlainObject(value)) throw new errors.PersistedStateError(msg);
}
Expand Down Expand Up @@ -73,21 +73,21 @@ define(function (require) {
};

PersistedState.prototype.set = function (key, value) {
var params = prepSetParams(key, value, this._path);
var val = this._set(params.key, params.value);
let params = prepSetParams(key, value, this._path);
let val = this._set(params.key, params.value);
this.emit('set');
return val;
};

PersistedState.prototype.setSilent = function (key, value) {
var params = prepSetParams(key, value, this._path);
let params = prepSetParams(key, value, this._path);
return this._set(params.key, params.value, true);
};

PersistedState.prototype.reset = function (path) {
var keyPath = this._getIndex(path);
var origValue = _.get(this._defaultState, keyPath);
var currentValue = _.get(this._mergedState, keyPath);
let keyPath = this._getIndex(path);
let origValue = _.get(this._defaultState, keyPath);
let currentValue = _.get(this._mergedState, keyPath);

if (_.isUndefined(origValue)) {
this._cleanPath(path, this._mergedState);
Expand All @@ -108,7 +108,7 @@ define(function (require) {
};

PersistedState.prototype.removeChild = function (path) {
var origValue = _.get(this._defaultState, this._getIndex(path));
let origValue = _.get(this._defaultState, this._getIndex(path));

if (_.isUndefined(origValue)) {
this.reset(path);
Expand Down Expand Up @@ -139,19 +139,19 @@ define(function (require) {
};

PersistedState.prototype._getPartialIndex = function (key) {
var keyPath = this._getIndex(key);
let keyPath = this._getIndex(key);
return keyPath.slice(this._path.length);
};

PersistedState.prototype._cleanPath = function (path, stateTree) {
var partialPath = this._getPartialIndex(path);
var remove = true;
let partialPath = this._getPartialIndex(path);
let remove = true;

// recursively delete value tree, when no other keys exist
while (partialPath.length > 0) {
var lastKey = partialPath.splice(partialPath.length - 1, 1)[0];
var statePath = this._path.concat(partialPath);
var stateVal = statePath.length > 0 ? _.get(stateTree, statePath) : stateTree;
let lastKey = partialPath.splice(partialPath.length - 1, 1)[0];
let statePath = this._path.concat(partialPath);
let stateVal = statePath.length > 0 ? _.get(stateTree, statePath) : stateTree;

// if stateVal isn't an object, do nothing
if (!_.isPlainObject(stateVal)) return;
Expand All @@ -162,13 +162,13 @@ define(function (require) {
};

PersistedState.prototype._getDefault = function () {
var def = (this._hasPath()) ? undefined : {};
let def = (this._hasPath()) ? undefined : {};
return (this._parent ? this.get() : def);
};

PersistedState.prototype._setPath = function (path) {
var isString = _.isString(path);
var isArray = _.isArray(path);
let isString = _.isString(path);
let isArray = _.isArray(path);

if (!isString && !isArray) return [];
return (isString) ? [this._getIndex(path)] : path;
Expand Down Expand Up @@ -196,11 +196,11 @@ define(function (require) {
};

PersistedState.prototype._set = function (key, value, silent, initialChildState) {
var self = this;
var stateChanged = false;
var initialState = !this._initialized;
var keyPath = this._getIndex(key);
var hasKeyPath = keyPath.length > 0;
let self = this;
let stateChanged = false;
let initialState = !this._initialized;
let keyPath = this._getIndex(key);
let hasKeyPath = keyPath.length > 0;

// if this is the initial state value, save value as the default
if (initialState) {
Expand All @@ -226,7 +226,7 @@ define(function (require) {
}
} else {
// check for changes at path, emit an event when different
var curVal = hasKeyPath ? this.get(keyPath) : this._mergedState;
let curVal = hasKeyPath ? this.get(keyPath) : this._mergedState;
stateChanged = !_.isEqual(curVal, value);

if (!initialChildState) {
Expand All @@ -243,11 +243,11 @@ define(function (require) {
}

// update the merged state value
var targetObj = this._mergedState || _.cloneDeep(this._defaultState);
var sourceObj = _.merge({}, this._defaultChildState, this._changedState);
let targetObj = this._mergedState || _.cloneDeep(this._defaultState);
let sourceObj = _.merge({}, this._defaultChildState, this._changedState);

// handler arguments are (targetValue, sourceValue, key, target, source)
var mergeMethod = function (targetValue, sourceValue, mergeKey) {
let mergeMethod = function (targetValue, sourceValue, mergeKey) {
// if not initial state, skip default merge method (ie. return value, see note below)
if (!initialState && !initialChildState && _.isEqual(keyPath, self._getIndex(mergeKey))) {
// use the sourceValue or fall back to targetValue
Expand Down
Loading