Skip to content

Commit

Permalink
Move index patterns: src/legacy/core_plugins/data πŸ‘‰ src/plugins/data (#…
Browse files Browse the repository at this point in the history
…53794)

* Move index patterns: src/legacy/core_plugins/data πŸ‘‰ src/plugins/data

Closes: #43444

Make sure that all index pattern related imports use NP (and delete index_pattern folder from shim)

* fix JEST tests

* fix CI

* fix PR comments

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
alexwizp and elasticmachine authored Jan 3, 2020
1 parent b09653a commit 6942d0b
Show file tree
Hide file tree
Showing 86 changed files with 145 additions and 277 deletions.
3 changes: 0 additions & 3 deletions src/legacy/core_plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ export function plugin() {

/** @public types */
export { DataStart };

export { Field, FieldType, IFieldList, IndexPattern } from './index_patterns';
export { EsQuerySortValue, FetchOptions, ISearchSource, SortDirection } from './search/types';
export { SearchSourceFields } from './search/types';
export {
Expand All @@ -41,5 +39,4 @@ export {
/** @public static code */
export * from '../common';
export { FilterStateManager } from './filter/filter_manager';
export { getFromSavedObject, getRoutes, flattenHitWrapper } from './index_patterns';
export { getRequestInspectorStats, getResponseInspectorStats } from './search';
33 changes: 0 additions & 33 deletions src/legacy/core_plugins/data/public/index_patterns/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import React from 'react';
import { shallow } from 'enzyme';
import { JsonCodeBlock } from './json_code_block';
import { IndexPattern } from 'ui/index_patterns';
import { IndexPattern } from '../../../../../plugins/data/public';

it('returns the `JsonCodeEditor` component', () => {
const props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/
import React from 'react';
import { mount } from 'enzyme';
import { IndexPattern } from 'ui/index_patterns';
// @ts-ignore
import { findTestSubject } from '@elastic/eui/lib/test';
import { flattenHitWrapper } from '../../../../data/public/';
import { DocViewTable } from './table';

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

jest.mock('ui/new_platform');

// @ts-ignore
Expand Down Expand Up @@ -70,7 +70,7 @@ const indexPattern = {
formatHit: jest.fn(hit => hit._source),
} as IndexPattern;

indexPattern.flattenHit = flattenHitWrapper(indexPattern, indexPattern.metaFields);
indexPattern.flattenHit = indexPatterns.flattenHitWrapper(indexPattern, indexPattern.metaFields);

describe('DocViewTable at Discover', () => {
// At Discover's main view, all buttons are rendered
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ import {
unhashUrl,
VISUALIZE_EMBEDDABLE_TYPE,
} from '../legacy_imports';
import { FilterStateManager, IndexPattern } from '../../../../data/public';
import { Query, SavedQuery, IndexPatternsContract } from '../../../../../../plugins/data/public';
import { FilterStateManager } from '../../../../data/public';
import {
IndexPattern,
Query,
SavedQuery,
IndexPatternsContract,
} from '../../../../../../plugins/data/public';

import {
DashboardContainer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ const unmountComponentAtNode = jest.fn();

jest.doMock('react-dom', () => ({ render, unmountComponentAtNode }));

// If we don't mock this, Jest fails with the error `TypeError: Cannot redefine property: prototype
// at Function.defineProperties`.
jest.mock('ui/index_patterns', () => ({
INDEX_PATTERN_ILLEGAL_CHARACTERS: ['\\', '/', '?', '"', '<', '>', '|', ' '],
}));

jest.mock('ui/chrome', () => ({
getUiSettingsClient: () => ({
get: () => '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ const mockIndexPatternCreationType = {
checkIndicesForErrors: () => false,
getShowSystemIndices: () => false,
};
// If we don't mock this, Jest fails with the error `TypeError: Cannot redefine property: prototype
// at Function.defineProperties`.
jest.mock('ui/index_patterns', () => ({
INDEX_PATTERN_ILLEGAL_CHARACTERS: ['\\', '/', '?', '"', '<', '>', '|', ' '],
}));

jest.mock('ui/chrome', () => ({
getUiSettingsClient: () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { INDEX_PATTERN_ILLEGAL_CHARACTERS as ILLEGAL_CHARACTERS } from 'ui/index_patterns';
import { indexPatterns } from '../../../../../../../../../../plugins/data/public';
import { MAX_SEARCH_SIZE } from '../../constants';
import {
getIndices,
Expand Down Expand Up @@ -71,7 +71,7 @@ export class StepIndexPattern extends Component {
indexPatternName: indexPatternCreationType.getIndexPatternName(),
};

this.ILLEGAL_CHARACTERS = [...ILLEGAL_CHARACTERS];
this.ILLEGAL_CHARACTERS = [...indexPatterns.ILLEGAL_CHARACTERS];
this.lastQuery = null;
}

Expand Down Expand Up @@ -243,7 +243,7 @@ export class StepIndexPattern extends Component {
if (!query || !query.length || query === '.' || query === '..') {
// This is an error scenario but do not report an error
containsErrors = true;
} else if (containsIllegalCharacters(query, ILLEGAL_CHARACTERS)) {
} else if (containsIllegalCharacters(query, indexPatterns.ILLEGAL_CHARACTERS)) {
const errorMessage = i18n.translate(
'kbn.management.createIndexPattern.step.invalidCharactersErrorMessage',
{
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/agg_types/agg_configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { TimeRange } from 'src/plugins/data/public';
import { Schema } from '../vis/editors/default/schemas';
import { AggConfig, AggConfigOptions } from './agg_config';
import { AggGroupNames } from '../vis/editors/default/agg_groups';
import { IndexPattern } from '../../../core_plugins/data/public';
import { IndexPattern } from '../../../../plugins/data/public';
import { ISearchSource, FetchOptions } from '../courier/types';

type Schemas = Record<string, any>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { IndexPattern } from 'ui/index_patterns';
import { IndexPattern } from '../../../../../plugins/data/public';
import { AggTypeFilters } from './agg_type_filters';
import { AggType } from '..';
import { AggConfig } from '../../vis';
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/agg_types/filter/agg_type_filters.ts
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 { IndexPattern } from '../../index_patterns';
import { IndexPattern } from '../../../../../plugins/data/public';
import { AggConfig } from '../../vis';
import { AggType } from '..';

Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/agg_types/param_types/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { FieldParamEditor } from '../../vis/editors/default/controls/field';
import { BaseParamType } from './base';
import { toastNotifications } from '../../notify';
import { propFilter } from '../filter';
import { Field, IFieldList } from '../../index_patterns';
import { Field, IFieldList } from '../../../../../plugins/data/public';

const filterByType = propFilter('type');

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

import { Field } from 'ui/index_patterns';
import { IndexedArray } from 'ui/indexed_array';
import { AggTypeFieldFilters } from './field_filters';
import { AggConfig } from 'ui/vis';
import { Field } from '../../../../../../plugins/data/public';

describe('AggTypeFieldFilters', () => {
let registry: AggTypeFieldFilters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
import { Field } from 'ui/index_patterns';
import { AggConfig } from '../../../vis';
import { Field } from '../../../../../../plugins/data/public';

type AggTypeFieldFilter = (field: Field, aggConfig: AggConfig) => boolean;

Expand Down
25 changes: 0 additions & 25 deletions src/legacy/ui/public/index_patterns/__mocks__/index.ts

This file was deleted.

40 changes: 0 additions & 40 deletions src/legacy/ui/public/index_patterns/index.ts

This file was deleted.

6 changes: 3 additions & 3 deletions src/legacy/ui/public/indices/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
* under the License.
*/

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

export const INDEX_ILLEGAL_CHARACTERS_VISIBLE = [...INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE, '*'];
export const INDEX_ILLEGAL_CHARACTERS_VISIBLE = [...indexPatterns.ILLEGAL_CHARACTERS_VISIBLE, '*'];

// Insert the comma into the middle, so it doesn't look as if it has grammatical meaning when
// these characters are rendered in the UI.
const insertionIndex = Math.floor(INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE.length / 2);
const insertionIndex = Math.floor(indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.length / 2);
INDEX_ILLEGAL_CHARACTERS_VISIBLE.splice(insertionIndex, 0, ',');
2 changes: 1 addition & 1 deletion src/legacy/ui/public/registry/doc_views_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
import { IndexPattern } from 'src/legacy/core_plugins/data/public';
import { ComponentType } from 'react';
import { IScope } from 'angular';
import { IndexPattern } from '../../../../plugins/data/public';

export interface AngularDirective {
controller: (scope: AngularScope) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import _ from 'lodash';
import { EsResponse, SavedObject, SavedObjectConfig } from 'ui/saved_objects/types';
import { parseSearchSource } from 'ui/saved_objects/helpers/parse_search_source';
import { expandShorthand, SavedObjectNotFound } from '../../../../../plugins/kibana_utils/public';
import { IndexPattern } from '../../../../core_plugins/data/public';
import { IndexPattern } from '../../../../../plugins/data/public';

/**
* A given response of and ElasticSearch containing a plain saved object is applied to the given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { TimeIntervalParam } from 'ui/vis/editors/config/types';
import { AggConfig } from '../..';
import { AggType } from '../../../agg_types';
import { IndexPattern } from '../../../index_patterns';
import { IndexPattern } from '../../../../../../plugins/data/public';
import { leastCommonMultiple } from '../../../utils/math';
import { parseEsInterval } from '../../../../../core_plugins/data/public';
import { leastCommonInterval } from '../../lib/least_common_interval';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { AggGroupNames } from '../agg_groups';
import { DefaultEditorAgg, DefaultEditorAggProps } from './agg';
import { act } from 'react-dom/test-utils';
import { DefaultEditorAggParams } from './agg_params';
import { IndexPattern } from 'ui/index_patterns';
import { AggType } from 'ui/agg_types';
import { IndexPattern } from '../../../../../../../plugins/data/public';

jest.mock('./agg_params', () => ({
DefaultEditorAggParams: () => null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
* under the License.
*/

import { Field } from 'ui/index_patterns';
import { AggParam } from 'ui/agg_types';
import { AggConfig } from '../../../../agg_types/agg_config';
import { ComboBoxGroupedOptions } from '../utils';
import { EditorConfig } from '../../config/types';
import { VisState } from '../../..';
import { SubAggParamsProp } from './agg_params';
import { Field } from '../../../../../../../plugins/data/public';

// NOTE: we cannot export the interface with export { InterfaceName }
// as there is currently a bug on babel typescript transform plugin for it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

import React from 'react';
import { mount, shallow } from 'enzyme';
import { IndexPattern } from 'ui/index_patterns';
import { AggConfig, VisState } from '../../..';
import { DefaultEditorAggParams, DefaultEditorAggParamsProps } from './agg_params';
import { IndexPattern } from '../../../../../../../plugins/data/public';

const mockEditorConfig = {
useNormalizedEsInterval: { hidden: false, fixedValue: false },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { i18n } from '@kbn/i18n';
import useUnmount from 'react-use/lib/useUnmount';

import { VisState } from 'ui/vis';
import { IndexPattern } from 'ui/index_patterns';
import { aggTypes, AggType, AggParam, AggConfig } from 'ui/agg_types/';
import { IndexPattern } from '../../../../../../../plugins/data/public';

import { DefaultEditorAggSelect } from './agg_select';
import { DefaultEditorAggParam } from './agg_param';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import { AggConfig, VisState } from '../../..';
import { AggType } from 'ui/agg_types';
import { IndexPattern, Field } from 'ui/index_patterns';
import { IndexedArray } from 'ui/indexed_array';
import {
getAggParamsToRender,
Expand All @@ -28,6 +27,7 @@ import {
isInvalidParamsTouched,
} from './agg_params_helper';
import { EditorConfig } from '../../config/types';
import { IndexPattern, Field } from '../../../../../../../plugins/data/public';

jest.mock('ui/agg_types', () => ({
aggTypes: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
import { get, isEmpty } from 'lodash';
import { i18n } from '@kbn/i18n';
import { aggTypeFilters } from 'ui/agg_types/filter';
import { IndexPattern, Field } from 'ui/index_patterns';
import { aggTypes, AggParam, FieldParamType, AggType } from 'ui/agg_types';
import { aggTypeFieldFilters } from 'ui/agg_types/param_types/filter';
import { AggConfig, VisState } from '../../..';
import { groupAndSortBy, ComboBoxGroupedOptions } from '../utils';
import { EditorConfig } from '../../config/types';
import { AggTypeState, AggParamsState } from './agg_params_state';
import { AggParamEditorProps } from './agg_param_props';
import { IndexPattern, Field } from '../../../../../../../plugins/data/public';

interface ParamInstanceBase {
agg: AggConfig;
Expand Down
Loading

0 comments on commit 6942d0b

Please sign in to comment.