mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Backport PR #6881
--------- **Commit 1:** [internal] Replace var with let in root of ui/public This change was applied only to files in the root of the src/ui/public directory. This was an automatic replacement from var to let for any variable declaration that doubles as the initial assignment. Ultimately we want most of these to be converted to const, but this commit is so large that it warrants breaking each step of automation up into its own commit. For example: `var foo = 'bar';` becomes `let foo = 'var';` This was accomplished by replacing: find: `var ([a-zA-Z_$][0-9a-zA-Z_$]*)(\s+)=` replace: `let $1$2=` * Original sha:469c0bde04
* Authored by Court Ewing <court@epixa.com> on 2016-04-12T21:38:58Z **Commit 2:** [internal] Replace let with const in root of ui/public This change was applied only to files in the root of the src/ui/public directory. All instances of `let` were replaced with `const`, and then any instance that flagged the `no-const-assign` rule in the linter was put back. * Original sha:3ae090908d
* Authored by Court Ewing <court@epixa.com> on 2016-04-12T21:45:32Z
This commit is contained in:
parent
6369da866a
commit
f00851176d
10 changed files with 48 additions and 48 deletions
|
@ -1,16 +1,16 @@
|
|||
define(function (require) {
|
||||
var _ = require('lodash');
|
||||
const _ = require('lodash');
|
||||
|
||||
function ConfigTemplate(templates) {
|
||||
var template = this;
|
||||
const template = this;
|
||||
template.current = null;
|
||||
template.toggle = _.partial(update, null);
|
||||
template.open = _.partial(update, true);
|
||||
template.close = _.partial(update, false);
|
||||
|
||||
function update(newState, name) {
|
||||
var toUpdate = templates[name];
|
||||
var curState = template.is(name);
|
||||
const toUpdate = templates[name];
|
||||
const curState = template.is(name);
|
||||
if (newState == null) newState = !curState;
|
||||
|
||||
if (newState) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
define(function (require) {
|
||||
return function BoundToConfigObjProvider($rootScope, config) {
|
||||
var _ = require('lodash');
|
||||
const _ = require('lodash');
|
||||
|
||||
/**
|
||||
* Create an object with properties that may be bound to config values.
|
||||
|
@ -17,7 +17,7 @@ define(function (require) {
|
|||
* @return {Object}
|
||||
*/
|
||||
function BoundToConfigObj(input) {
|
||||
var self = this;
|
||||
const self = this;
|
||||
|
||||
_.forOwn(input, function (val, prop) {
|
||||
if (!_.isString(val) || val.charAt(0) !== '=') {
|
||||
|
@ -25,7 +25,7 @@ define(function (require) {
|
|||
return;
|
||||
}
|
||||
|
||||
var configKey = val.substr(1);
|
||||
const configKey = val.substr(1);
|
||||
|
||||
update();
|
||||
$rootScope.$on('init:config', update);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
define(function (require) {
|
||||
var _ = require('lodash');
|
||||
const _ = require('lodash');
|
||||
|
||||
/**
|
||||
* Angular can't render directives that render themselves recursively:
|
||||
|
@ -25,7 +25,7 @@ define(function (require) {
|
|||
}
|
||||
|
||||
// Break the recursion loop by removing the contents
|
||||
var contents = element.contents().remove();
|
||||
const contents = element.contents().remove();
|
||||
let compiledContents;
|
||||
return {
|
||||
pre: (link && link.pre) ? link.pre : null,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
define(function (require) {
|
||||
var _ = require('lodash');
|
||||
var NL_RE = /\n/g;
|
||||
var events = 'keydown keypress keyup change';
|
||||
const _ = require('lodash');
|
||||
const NL_RE = /\n/g;
|
||||
const events = 'keydown keypress keyup change';
|
||||
|
||||
require('ui/modules').get('kibana')
|
||||
.directive('elasticTextarea', function () {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
define(function (require) {
|
||||
var _ = require('lodash');
|
||||
var angular = require('angular');
|
||||
const _ = require('lodash');
|
||||
const angular = require('angular');
|
||||
|
||||
var canStack = (function () {
|
||||
var err = new Error();
|
||||
const canStack = (function () {
|
||||
const err = new Error();
|
||||
return !!err.stack;
|
||||
}());
|
||||
|
||||
var errors = {};
|
||||
const errors = {};
|
||||
|
||||
// abstract error class
|
||||
function KbnError(msg, constructor) {
|
||||
|
@ -120,7 +120,7 @@ define(function (require) {
|
|||
* @param {String} field - the fields which contains the conflict
|
||||
*/
|
||||
errors.RestrictedMapping = function RestrictedMapping(field, index) {
|
||||
var msg = field + ' is a restricted field name';
|
||||
let msg = field + ' is a restricted field name';
|
||||
if (index) msg += ', found it while attempting to fetch mapping for index pattern: ' + index;
|
||||
|
||||
KbnError.call(this, msg, errors.RestrictedMapping);
|
||||
|
@ -166,7 +166,7 @@ define(function (require) {
|
|||
errors.SavedObjectNotFound = function SavedObjectNotFound(type, id) {
|
||||
this.savedObjectType = type;
|
||||
this.savedObjectId = id;
|
||||
var idMsg = id ? ' (id: ' + id + ')' : '';
|
||||
const idMsg = id ? ' (id: ' + id + ')' : '';
|
||||
KbnError.call(this,
|
||||
'Could not locate that ' + type + idMsg,
|
||||
errors.SavedObjectNotFound);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
define(function (require) {
|
||||
require('elasticsearch-browser/elasticsearch.angular.js');
|
||||
var _ = require('lodash');
|
||||
const _ = require('lodash');
|
||||
|
||||
let es; // share the client amoungst all apps
|
||||
require('ui/modules')
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
define(function (require) {
|
||||
var _ = require('lodash');
|
||||
var Notifier = require('ui/notify/notifier');
|
||||
const _ = require('lodash');
|
||||
const Notifier = require('ui/notify/notifier');
|
||||
|
||||
return function EventsProvider(Private, Promise) {
|
||||
var SimpleEmitter = require('ui/utils/SimpleEmitter');
|
||||
var notify = new Notifier({ location: 'EventEmitter' });
|
||||
const SimpleEmitter = require('ui/utils/SimpleEmitter');
|
||||
const notify = new Notifier({ location: 'EventEmitter' });
|
||||
|
||||
_.class(Events).inherits(SimpleEmitter);
|
||||
function Events() {
|
||||
|
@ -24,7 +24,7 @@ define(function (require) {
|
|||
this._listeners[name] = [];
|
||||
}
|
||||
|
||||
var listener = {
|
||||
const listener = {
|
||||
handler: handler
|
||||
};
|
||||
this._listeners[name].push(listener);
|
||||
|
@ -76,8 +76,8 @@ define(function (require) {
|
|||
* @returns {Promise}
|
||||
*/
|
||||
Events.prototype.emit = function (name) {
|
||||
var self = this;
|
||||
var args = _.rest(arguments);
|
||||
const self = this;
|
||||
const args = _.rest(arguments);
|
||||
|
||||
if (!self._listeners[name]) {
|
||||
return self._emitChain;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
define(function (require) {
|
||||
var $ = require('jquery');
|
||||
var _ = require('lodash');
|
||||
const $ = require('jquery');
|
||||
const _ = require('lodash');
|
||||
|
||||
var SCROLLER_HEIGHT = 20;
|
||||
const SCROLLER_HEIGHT = 20;
|
||||
|
||||
require('ui/modules')
|
||||
.get('kibana')
|
||||
|
@ -10,15 +10,15 @@ define(function (require) {
|
|||
return {
|
||||
restrict: 'A',
|
||||
link: function ($scope, $el) {
|
||||
var $window = $(window);
|
||||
var $scroller = $('<div class="fixed-scroll-scroller">').height(SCROLLER_HEIGHT);
|
||||
let $window = $(window);
|
||||
let $scroller = $('<div class="fixed-scroll-scroller">').height(SCROLLER_HEIGHT);
|
||||
|
||||
|
||||
/**
|
||||
* Remove the listeners bound in listen()
|
||||
* @type {function}
|
||||
*/
|
||||
var unlisten = _.noop;
|
||||
let unlisten = _.noop;
|
||||
|
||||
/**
|
||||
* Listen for scroll events on the $scroller and the $el, sets unlisten()
|
||||
|
@ -74,15 +74,15 @@ define(function (require) {
|
|||
function setup() {
|
||||
cleanUp();
|
||||
|
||||
var containerWidth = $el.width();
|
||||
var contentWidth = $el.prop('scrollWidth');
|
||||
var containerHorizOverflow = contentWidth - containerWidth;
|
||||
const containerWidth = $el.width();
|
||||
const contentWidth = $el.prop('scrollWidth');
|
||||
const containerHorizOverflow = contentWidth - containerWidth;
|
||||
|
||||
var elTop = $el.offset().top - $window.scrollTop();
|
||||
var elBottom = elTop + $el.height();
|
||||
var windowVertOverflow = elBottom - $window.height();
|
||||
const elTop = $el.offset().top - $window.scrollTop();
|
||||
const elBottom = elTop + $el.height();
|
||||
const windowVertOverflow = elBottom - $window.height();
|
||||
|
||||
var requireScroller = containerHorizOverflow > 0 && windowVertOverflow > 0;
|
||||
const requireScroller = containerHorizOverflow > 0 && windowVertOverflow > 0;
|
||||
if (!requireScroller) return;
|
||||
|
||||
// push the content away from the scroller
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
define(function (require) {
|
||||
var angular = require('angular');
|
||||
var existingModules = {};
|
||||
var _ = require('lodash');
|
||||
var links = [];
|
||||
const angular = require('angular');
|
||||
const existingModules = {};
|
||||
const _ = require('lodash');
|
||||
const links = [];
|
||||
|
||||
function link(module) {
|
||||
// as modules are defined they will be set as requirements for this app
|
||||
|
@ -13,7 +13,7 @@ define(function (require) {
|
|||
}
|
||||
|
||||
function get(moduleName, requires) {
|
||||
var module = existingModules[moduleName];
|
||||
let module = existingModules[moduleName];
|
||||
|
||||
if (module === void 0) {
|
||||
// create the module
|
||||
|
@ -36,13 +36,13 @@ define(function (require) {
|
|||
}
|
||||
|
||||
function close(moduleName) {
|
||||
var module = existingModules[moduleName];
|
||||
const module = existingModules[moduleName];
|
||||
|
||||
// already closed
|
||||
if (!module) return;
|
||||
|
||||
// if the module is currently linked, unlink it
|
||||
var i = links.indexOf(module);
|
||||
const i = links.indexOf(module);
|
||||
if (i > -1) links.splice(i, 1);
|
||||
|
||||
// remove from linked modules list of required modules
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
define(function (require) {
|
||||
var parseInterval = require('ui/utils/parse_interval');
|
||||
const parseInterval = require('ui/utils/parse_interval');
|
||||
|
||||
require('ui/modules')
|
||||
.get('kibana')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue