Skip to content

Commit

Permalink
chore(NA): migrate to lodash4 on dev_tools, discover, embeddable, es_…
Browse files Browse the repository at this point in the history
…ui)shared, expressions, home plugins
  • Loading branch information
mistic committed Jun 23, 2020
1 parent 199ed88 commit f115f61
Show file tree
Hide file tree
Showing 45 changed files with 55 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/plugins/dev_tools/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { BehaviorSubject } from 'rxjs';
import { AppUpdater, CoreSetup, Plugin } from 'kibana/public';
import { i18n } from '@kbn/i18n';
import { sortBy } from 'lodash';
import { sortBy } from 'lodash4';
import { KibanaLegacySetup } from '../../kibana_legacy/public';
import { CreateDevToolArgs, DevToolApp, createDevToolApp } from './dev_tool';
import { AppNavLinkStatus, DEFAULT_APP_CATEGORIES } from '../../../core/public';
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/discover/public/application/angular/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
import { i18n } from '@kbn/i18n';
import { CONTEXT_DEFAULT_SIZE_SETTING } from '../../../common';
import { getAngularModule, getServices } from '../../kibana_services';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
import { i18n } from '@kbn/i18n';

export function fetchAnchorProvider(indexPatterns, searchSource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import moment from 'moment';
import * as _ from 'lodash';
import * as _ from 'lodash4';
import { createIndexPatternsStub, createContextSearchSourceStub } from './_stubs';
import { fetchContextProvider } from './context';
import { setServices } from '../../../../kibana_services';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import moment from 'moment';
import * as _ from 'lodash';
import * as _ from 'lodash4';

import { createIndexPatternsStub, createContextSearchSourceStub } from './_stubs';
import { setServices } from '../../../../kibana_services';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { getServices } from '../../../../kibana_services';
Expand Down Expand Up @@ -70,7 +70,7 @@ export function QueryActionsProvider(Promise) {
setLoadingStatus(state)('anchor');

return Promise.try(() =>
fetchAnchor(indexPatternId, anchorId, [_.zipObject([sort]), { [tieBreakerField]: sort[1] }])
fetchAnchor(indexPatternId, anchorId, [_.fromPairs([sort]), { [tieBreakerField]: sort[1] }])
).then(
(anchorDocument) => {
setLoadedStatus(state)('anchor');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
import { esFilters } from '../../../../../../data/public';

import { MAX_CONTEXT_SIZE, MIN_CONTEXT_SIZE, QUERY_PARAMETER_KEYS } from './constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
import { CONTEXT_STEP_SETTING, CONTEXT_TIE_BREAKER_FIELDS_SETTING } from '../../../common';
import { getAngularModule, getServices } from '../../kibana_services';
import contextAppTemplate from './context_app.html';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import _ from 'lodash';
import _ from 'lodash4';
import { History } from 'history';
import {
createStateContainer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
import $ from 'jquery';
import { IScope } from 'angular';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
// Debounce service, angularized version of lodash debounce
// borrowed heavily from https://github.com/shahata/angular-debounce

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import $ from 'jquery';
import _ from 'lodash';
import _ from 'lodash4';
import { DebounceProvider } from './debounce';

const SCROLLER_HEIGHT = 20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
import React from 'react';
import { Subscription, Subject, merge } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { isEqual } from 'lodash';
import { isEqual } from 'lodash4';
import { History } from 'history';
import {
createStateContainer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
import $ from 'jquery';
// @ts-ignore
import rison from 'rison-node';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
import { IndexPattern } from '../../../../../../data/public';

export type SortPairObj = Record<string, string>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { i18n } from '@kbn/i18n';
import { get } from 'lodash';
import { get } from 'lodash4';

export function getPainlessError(error: Error) {
const rootCause: Array<{ lang: string; script: string }> | undefined = get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { uniq } from 'lodash';
import { uniq } from 'lodash4';
import { Duration, Moment } from 'moment';
import { Unit } from '@elastic/datemath';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
import { ReactWrapper } from 'enzyme';
// @ts-ignore
import { findTestSubject } from '@elastic/eui/lib/test';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import './discover_sidebar.scss';
import React, { useCallback, useEffect, useState, useMemo } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiButtonIcon, EuiTitle } from '@elastic/eui';
import { sortBy } from 'lodash';
import { sortBy } from 'lodash4';
import { FormattedMessage, I18nProvider } from '@kbn/i18n/react';
import { DiscoverField } from './discover_field';
import { DiscoverIndexPattern } from './discover_index_pattern';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
import { i18n } from '@kbn/i18n';

function getFieldValues(hits, field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash';
import _ from 'lodash4';
// @ts-ignore
import realHits from 'fixtures/real_hits.js';
// @ts-ignore
Expand Down Expand Up @@ -186,7 +186,7 @@ describe('fieldCalculator', function () {
expect(extensions).toBeInstanceOf(Object);
expect(extensions.buckets).toBeInstanceOf(Array);
expect(extensions.buckets.length).toBe(3);
expect(_.pluck(extensions.buckets, 'value')).toEqual(['html', 'php', 'gif']);
expect(_.map(extensions.buckets, 'value')).toEqual(['html', 'php', 'gif']);
expect(extensions.error).toBe(undefined);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { difference, map } from 'lodash';
import { difference, map } from 'lodash4';
import { IndexPattern, IndexPatternField } from 'src/plugins/data/public';
import { DiscoverServices } from '../../../../build_services';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import React, { useState } from 'react';
import { escapeRegExp } from 'lodash';
import { escapeRegExp } from 'lodash4';
import { DocViewTableRow } from './table_row';
import { arrayContainsObjects, trimAngularSpan } from './table_helper';
import { DocViewRenderProps } from '../../doc_views/doc_views_types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import './search_embeddable.scss';
import angular from 'angular';
import _ from 'lodash';
import _ from 'lodash4';
import * as Rx from 'rxjs';
import { Subscription } from 'rxjs';
import { i18n } from '@kbn/i18n';
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/discover/public/kibana_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/

import _ from 'lodash4';
import { createHashHistory } from 'history';
import { ScopedHistory } from 'kibana/public';
import { DiscoverServices } from './build_services';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { cloneDeep, isEqual } from 'lodash';
import { cloneDeep, isEqual } from 'lodash4';
import * as Rx from 'rxjs';
import { Adapters, ViewMode } from '../types';
import { IContainer } from '../containers';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import { padLeft } from 'lodash';
import { padStart } from 'lodash4';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';

Expand Down Expand Up @@ -55,12 +55,12 @@ function makeSequence(min, max) {

const MINUTE_OPTIONS = makeSequence(0, 59).map((value) => ({
value: value.toString(),
text: padLeft(value, 2, '0'),
text: padStart(value, 2, '0'),
}));

const HOUR_OPTIONS = makeSequence(0, 23).map((value) => ({
value: value.toString(),
text: padLeft(value, 2, '0'),
text: padStart(value, 2, '0'),
}));

const DAY_OPTIONS = makeSequence(1, 7).map((value) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import React, { useCallback } from 'react';
import { EuiFormRow, EuiCodeEditor } from '@elastic/eui';
import { debounce } from 'lodash';
import { debounce } from 'lodash4';

import { isJSON } from '../../../static/validators/string';
import { useJson, OnJsonEditorUpdateHandler } from './use_json';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import * as _ from 'lodash';
import * as _ from 'lodash4';
import ace from 'brace';
import 'brace/mode/json';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import _ from 'lodash';
import _ from 'lodash4';
// @ts-ignore
import collapsingTests from './utils_string_collapsing.txt';
// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { useState, useRef, useEffect, useMemo } from 'react';
import { get } from 'lodash';
import { get } from 'lodash4';

import { FormHook, FieldHook, FormData, FieldConfig, FieldsMap, FormConfig } from '../types';
import { mapFormFields, unflattenObject, Subject, Subscription } from '../lib';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { set } from 'lodash';
import { set } from 'lodash4';
import { FieldHook } from '../types';

export const unflattenObject = (object: any) =>
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/expressions/common/execution/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { keys, last, mapValues, reduce, zipObject } from 'lodash';
import { keys, last, mapValues, reduce, zipObject } from 'lodash4';
import { Executor } from '../executor';
import { createExecutionContainer, ExecutionContainer } from './container';
import { createError } from '../util';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { uniq } from 'lodash';
import { uniqBy } from 'lodash4';
import { i18n } from '@kbn/i18n';
import { ExpressionFunctionDefinition } from '../../expression_functions';
import { KibanaContext } from '../../expression_types';
Expand All @@ -40,9 +40,9 @@ const getParsedValue = (data: any, defaultValue: any) =>
typeof data === 'string' && data.length ? JSON.parse(data) || defaultValue : defaultValue;

const mergeQueries = (first: Query | Query[] = [], second: Query | Query[]) =>
uniq<Query>(
uniqBy<Query>(
[...(Array.isArray(first) ? first : [first]), ...(Array.isArray(second) ? second : [second])],
(n: any) => JSON.stringify(n.query)
(n: any) => JSON.stringify(n.query) as any
);

export const kibanaContextFunction: ExpressionFunctionKibanaContext = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { mapValues } from 'lodash';
import { mapValues } from 'lodash4';
import { AnyExpressionFunctionDefinition } from '../../types';
import { ExecutionContext } from '../../../execution/types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { map, pick, zipObject } from 'lodash';
import { map, pick, zipObject } from 'lodash4';

import { ExpressionTypeDefinition } from '../types';
import { PointSeries } from './pointseries';
Expand Down Expand Up @@ -109,7 +109,7 @@ export const datatable: ExpressionTypeDefinition<typeof name, Datatable, Seriali
pointseries: (value: PointSeries) => ({
type: name,
rows: value.rows,
columns: map(value.columns, (val, colName) => {
columns: map(value.columns, (val: any, colName) => {
return { name: colName!, type: val.type };
}),
}),
Expand Down
Loading

0 comments on commit f115f61

Please sign in to comment.