Skip to content

Commit

Permalink
Merge branch 'master' into np-decouple-configSchema
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Dec 2, 2019
2 parents 318f827 + 0132236 commit 1b3088a
Show file tree
Hide file tree
Showing 53 changed files with 458 additions and 164 deletions.
1 change: 1 addition & 0 deletions src/cli/cluster/cluster_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export default class ClusterManager {
fromRoot('x-pack/legacy/plugins/reporting/.chromium'),
fromRoot('x-pack/legacy/plugins/siem/cypress'),
fromRoot('x-pack/legacy/plugins/apm/cypress'),
fromRoot('x-pack/legacy/plugins/apm/scripts'),
fromRoot('x-pack/legacy/plugins/canvas/canvas_plugin_src') // prevents server from restarting twice for Canvas plugin changes
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ import {
applyFiltersPopover,
changeTimeFilter,
extractTimeFilter,
IndexPatternsStart,
} from '../../../../../../plugins/data/public';
import { IndexPatternsStart } from '../../index_patterns';

export const GLOBAL_APPLY_FILTER_ACTION = 'GLOBAL_APPLY_FILTER_ACTION';

interface ActionContext {
Expand Down Expand Up @@ -74,7 +75,7 @@ export function createFilterAction(
if (selectedFilters.length > 1) {
const indexPatterns = await Promise.all(
filters.map(filter => {
return indexPatternsService.indexPatterns.get(filter.meta.index);
return indexPatternsService.indexPatterns.get(filter.meta.index!);
})
);

Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ export {
/** @public static code */
export * from '../common';
export { FilterStateManager } from './filter/filter_manager';
export { getFromSavedObject, getRoutes } from './index_patterns';
export { getFromSavedObject, getRoutes, flattenHitWrapper } from './index_patterns';
19 changes: 18 additions & 1 deletion src/legacy/core_plugins/data/public/index_patterns/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,21 @@
* under the License.
*/

export * from './index_patterns_service';
import { IFieldType, IIndexPattern, indexPatterns } from '../../../../../plugins/data/public';

const getFromSavedObject = indexPatterns.getFromSavedObject;
const getRoutes = indexPatterns.getRoutes;
const flattenHitWrapper = indexPatterns.flattenHitWrapper;

export { getFromSavedObject, getRoutes, flattenHitWrapper };
export { IFieldType as FieldType };
export { IIndexPattern as StaticIndexPattern };
export {
Field,
FieldListInterface,
IndexPattern,
IndexPatterns,
IndexPatternsStart,
IndexPatternsSetup,
IndexPatternsService,
} from '../../../../../plugins/data/public';
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import { isEmpty } from 'lodash';
import { IUiSettingsClient, SavedObjectsClientContract } from 'src/core/public';
import { getFromSavedObject } from '../../../index_patterns';
import { getFromSavedObject } from '../../../';

export async function fetchIndexPatterns(
savedObjectsClient: SavedObjectsClientContract,
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/data/public/shim/legacy_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { once } from 'lodash';

// @ts-ignore
import { uiModules } from 'ui/modules';
import { IndexPatterns } from '../index_patterns/index_patterns';
import { IndexPatterns } from '../';

/** @internal */
export const initLegacyModule = once((indexPatterns: IndexPatterns): void => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { mount } from 'enzyme';
import { IndexPattern } from 'ui/index_patterns';
// @ts-ignore
import { findTestSubject } from '@elastic/eui/lib/test';
import { flattenHitWrapper } from '../../../../data/public/index_patterns/index_patterns/flatten_hit';
import { flattenHitWrapper } from '../../../../data/public/';
import { DocViewTable } from './table';

// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ import {

// @ts-ignore
import { initDashboardApp } from './legacy_app';
import { DataStart } from '../../../data/public';
import { DataStart, IndexPatterns } from '../../../data/public';
import { IEmbeddableStart } from '../../../../../plugins/embeddable/public';
import { NavigationStart } from '../../../navigation/public';
import { DataPublicPluginStart as NpDataStart } from '../../../../../plugins/data/public';
import { SharePluginStart } from '../../../../../plugins/share/public';

export interface RenderDeps {
core: LegacyCoreStart;
indexPatterns: DataStart['indexPatterns']['indexPatterns'];
indexPatterns: IndexPatterns;
dataStart: DataStart;
npDataStart: NpDataStart;
navigation: NavigationStart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
unhashUrl,
} from './legacy_imports';
import { FilterStateManager, IndexPattern } from '../../../data/public';
import { Query, SavedQuery } from '../../../../../plugins/data/public';
import { Query, SavedQuery, IndexPatterns } from '../../../../../plugins/data/public';

import './dashboard_empty_screen_directive';

Expand Down Expand Up @@ -78,9 +78,7 @@ export interface DashboardAppControllerDependencies extends RenderDeps {
$routeParams: any;
getAppState: any;
globalState: State;
indexPatterns: {
getDefault: () => Promise<IndexPattern>;
};
indexPatterns: IndexPatterns;
dashboardConfig: any;
kbnUrl: KbnUrl;
AppStateClass: TAppStateClass<DashboardAppState>;
Expand Down Expand Up @@ -171,7 +169,7 @@ export class DashboardAppController {
} else {
indexPatterns.getDefault().then(defaultIndexPattern => {
$scope.$evalAsync(() => {
$scope.indexPatterns = [defaultIndexPattern];
$scope.indexPatterns = [defaultIndexPattern as IndexPattern];
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import { KbnUrlProvider, RedirectWhenMissingProvider } from 'ui/url';
// @ts-ignore
import { createTopNavDirective, createTopNavHelper } from 'ui/kbn_top_nav/kbn_top_nav';
import { configureAppAngularModule } from 'ui/legacy_compat';
import { IndexPatterns } from '../../../data/public/index_patterns/index_patterns';
import { IndexPatterns } from '../../../../../plugins/data/public';
import { Storage } from '../../../../../plugins/kibana_utils/public';
import { NavigationStart } from '../../../navigation/public';
import { createDocTableDirective } from './angular/doc_table/doc_table';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
* under the License.
*/

import { setup as data } from '../../../../../../../data/public/legacy';
const { FieldImpl: Field } = data.indexPatterns.__LEGACY;

import { Field } from '../../../../../../../../../plugins/data/public';
import { RegistryFieldFormatEditorsProvider } from 'ui/registry/field_format_editors';
import { docTitle } from 'ui/doc_title';
import { KbnUrlProvider } from 'ui/url';
Expand Down
18 changes: 9 additions & 9 deletions src/legacy/ui/public/index_patterns/__mocks__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
* under the License.
*/

import { dataPluginMock } from '../../../../core_plugins/data/public/mocks';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { dataPluginMock } from '../../../../../plugins/data/public/mocks';
import { indexPatterns as npIndexPatterns } from '../../../../../plugins/data/public';

const dataSetup = dataPluginMock.createSetup();
const dataSetup = dataPluginMock.createSetupContract();

// mocks for stateful code
export const { FieldImpl } = dataSetup.indexPatterns!.__LEGACY;
export const {
FieldList,
flattenHitWrapper,
formatHitProvider,
indexPatterns,
} = dataSetup.indexPatterns!;
export const { indexPatterns } = dataSetup.indexPatterns!;

export const flattenHitWrapper = npIndexPatterns.flattenHitWrapper;
export const formatHitProvider = npIndexPatterns.formatHitProvider;

// static code
export { getFromSavedObject, getRoutes } from '../../../../core_plugins/data/public';
export { FieldList } from '../../../../../plugins/data/public';
12 changes: 4 additions & 8 deletions src/legacy/ui/public/index_patterns/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@
* from ui/index_patterns for backwards compatibility.
*/

import { start as data } from '../../../core_plugins/data/public/legacy';

export const {
FieldList, // only used in Discover and StubIndexPattern
flattenHitWrapper,
formatHitProvider,
} = data.indexPatterns;

import { indexPatterns } from '../../../../plugins/data/public';

// static code
Expand All @@ -42,6 +34,8 @@ export const INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE = indexPatterns.ILLEGAL_CH
export const ILLEGAL_CHARACTERS = indexPatterns.ILLEGAL_CHARACTERS_KEY;
export const CONTAINS_SPACES = indexPatterns.CONTAINS_SPACES_KEY;
export const validateIndexPattern = indexPatterns.validate;
export const flattenHitWrapper = indexPatterns.flattenHitWrapper;
export const formatHitProvider = indexPatterns.formatHitProvider;

// types
export {
Expand All @@ -52,3 +46,5 @@ export {
IndexPatterns,
StaticIndexPattern,
} from '../../../core_plugins/data/public';

export { FieldList } from '../../../../plugins/data/public';
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import React from 'react';
import { mount, ReactWrapper } from 'enzyme';
import { act } from '@testing-library/react-hooks';

import { I18nProvider } from '@kbn/i18n/react';
import { EuiButtonGroup } from '@elastic/eui';
Expand Down Expand Up @@ -173,10 +172,8 @@ describe('VisLegend Component', () => {
it('should call unHighlight handler when legend item is unhovered', () => {
const first = getLegendItems(wrapper).first();

act(() => {
first.simulate('mouseEnter');
first.simulate('mouseLeave');
});
first.simulate('mouseEnter');
first.simulate('mouseLeave');

expect(vislibVis.handler.unHighlight).toHaveBeenCalledTimes(1);
});
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/data/common/field_formats/converters/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import { template, escape, keys } from 'lodash';
// @ts-ignore
import { noWhiteSpace } from '../../../../../legacy/core_plugins/kibana/common/utils/no_white_space';
// @ts-ignore
import { shortenDottedString } from '../../../../../legacy/core_plugins/kibana/common/utils/shorten_dotted_string';
import { shortenDottedString } from '../../utils';
import { KBN_FIELD_TYPES } from '../../kbn_field_types/types';
import { FieldFormat } from '../field_format';
import { TextContextTypeConvert, HtmlContextTypeConvert, FIELD_FORMAT_IDS } from '../types';
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/data/common/field_formats/converters/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import { asPrettyString } from '../index';
import { KBN_FIELD_TYPES } from '../../kbn_field_types/types';
import { FieldFormat } from '../field_format';
import { TextContextTypeConvert, FIELD_FORMAT_IDS } from '../types';
// @ts-ignore
import { shortenDottedString } from '../../../../../legacy/core_plugins/kibana/common/utils/shorten_dotted_string';
import { shortenDottedString } from '../../utils';

const TRANSFORM_OPTIONS = [
{
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ export * from './field_formats';
export * from './kbn_field_types';
export * from './index_patterns';
export * from './es_query';

export * from './utils';
export * from './types';
20 changes: 20 additions & 0 deletions src/plugins/data/common/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export { shortenDottedString } from './shorten_dotted_string';
34 changes: 34 additions & 0 deletions src/plugins/data/common/utils/shorten_dotted_string.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { shortenDottedString } from './shorten_dotted_string';

describe('shortenDottedString', () => {
test('should convert a dot.notated.string into a short string', () => {
expect(shortenDottedString('dot.notated.string')).toBe('d.n.string');
});

test('should ignore non-string values', () => {
const obj = { key: 'val' };

expect(shortenDottedString(true)).toBe(true);
expect(shortenDottedString(123)).toBe(123);
expect(shortenDottedString(obj)).toBe(obj);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,14 @@
* under the License.
*/

import { indexPatternsServiceMock } from './index_patterns/index_patterns_service.mock';
const DOT_PREFIX_RE = /(.).+?\./g;

function createDataSetupMock() {
return {
indexPatterns: indexPatternsServiceMock.createSetupContract(),
};
}

function createDataStartMock() {
return {};
/**
* Convert a dot.notated.string into a short
* version (d.n.string)
*
* @return {any}
*/
export function shortenDottedString(input: any) {
return typeof input !== 'string' ? input : input.replace(DOT_PREFIX_RE, '$1.');
}

export const dataPluginMock = {
createSetup: createDataSetupMock,
createStart: createDataStartMock,
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,19 @@
import { i18n } from '@kbn/i18n';
// @ts-ignore
import { ObjDefine } from './obj_define';
// @ts-ignore
import { shortenDottedString } from '../../../../../core_plugins/kibana/common/utils/shorten_dotted_string';
import { IndexPattern } from '../index_patterns';
import { getNotifications, getFieldFormats } from '../services';

import {
FieldFormat,
getKbnFieldType,
IFieldType,
getKbnFieldType,
IFieldSubType,
} from '../../../../../../plugins/data/public';
FieldFormat,
shortenDottedString,
} from '../../../common';

export type FieldSpec = Record<string, any>;

/** @deprecated
* Please use IFieldType instead
* */
export type FieldType = IFieldType;

export class Field implements FieldType {
export class Field implements IFieldType {
name: string;
type: string;
script?: string;
Expand Down
Loading

0 comments on commit 1b3088a

Please sign in to comment.