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

[Discover] Migrate DataView related imports to data_views plugin #126315

Merged
merged 11 commits into from
Mar 15, 2022
3 changes: 1 addition & 2 deletions src/plugins/discover/public/__mocks__/index_pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* Side Public License, v 1.
*/

import { IIndexPatternFieldList } from '../../../data/common';
import { DataView } from '../../../data/common';
import { IIndexPatternFieldList, DataView } from '../../../data_views/common';
kertal marked this conversation as resolved.
Show resolved Hide resolved

const fields = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* Side Public License, v 1.
*/

import { IIndexPatternFieldList } from '../../../data/common';
import { DataView } from '../../../data/common';
import { IIndexPatternFieldList, DataView } from '../../../data_views/common';

const fields = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { EuiText, EuiPageContent, EuiPage, EuiSpacer } from '@elastic/eui';
import { cloneDeep } from 'lodash';
import { DOC_TABLE_LEGACY, SEARCH_FIELDS_FROM_SOURCE } from '../../../common';
import { ContextErrorMessage } from './components/context_error_message';
import { DataView, DataViewField } from '../../../../data/common';
import { DataView, DataViewField } from '../../../../data_views/common';
import { LoadingStatus } from './services/context_query_state';
import { AppState, isEqualFilters } from './services/context_state';
import { useColumns } from '../../utils/use_data_grid_columns';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import React, { useState, Fragment, useMemo, useCallback } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { EuiHorizontalRule, EuiText } from '@elastic/eui';
import { CONTEXT_STEP_SETTING, DOC_HIDE_TIME_COLUMN_SETTING } from '../../../common';
import { DataView, SortDirection } from '../../../../data/common';
import type { DataView } from '../../../../data_views/common';
import { SortDirection } from '../../../../data/common';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data plugin imports should also be from public instead of common

import { LoadingStatus } from './services/context_query_state';
import { ActionBar } from './components/action_bar/action_bar';
import { DiscoverGrid } from '../../components/discover_grid/discover_grid';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { DataView, SortDirection } from '../../../../../data/common';
import { DataView } from '../../../../../data_views/common';
import { SortDirection } from '../../../../../data/common';
import { createSearchSourceStub } from './_stubs';
import { fetchAnchor, updateSearchSource } from './anchor';
import { indexPatternMock } from '../../../__mocks__/index_pattern';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

import { i18n } from '@kbn/i18n';

import { ISearchSource, EsQuerySortValue, DataView } from '../../../../../data/common';
import { ISearchSource, EsQuerySortValue } from '../../../../../data/common';
import { DataView } from '../../../../../data_views/common';
import { EsHitRecord } from '../../types';

export async function fetchAnchor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import moment from 'moment';
import { get, last } from 'lodash';
import { DataView, SortDirection } from 'src/plugins/data/common';
import type { DataView } from 'src/plugins/data_views/common';
import { SortDirection } from 'src/plugins/data/common';
import { createContextSearchSourceStub } from './_stubs';
import { fetchSurroundingDocs, SurrDocType } from './context';
import { DataPublicPluginStart, Query } from '../../../../../data/public';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import moment from 'moment';
import { get, last } from 'lodash';
import { DataView, SortDirection } from 'src/plugins/data/common';
import { SortDirection } from 'src/plugins/data/common';
import type { DataView } from 'src/plugins/data_views/common';
import { createContextSearchSourceStub } from './_stubs';
import { DataPublicPluginStart, Query } from '../../../../../data/public';
import { fetchSurroundingDocs, SurrDocType } from './context';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* Side Public License, v 1.
*/
import type { Filter } from '@kbn/es-query';
import { DataView, ISearchSource } from 'src/plugins/data/common';
import { DataView } from 'src/plugins/data_views/common';
import { ISearchSource } from 'src/plugins/data/common';
import { DataPublicPluginStart } from 'src/plugins/data/public';
import { reverseSortDir, SortDirection } from '../utils/sorting';
import { convertIsoToMillis, extractNanos } from '../utils/date_conversion';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import type { DataView } from 'src/plugins/data/common';
import type { DataView } from 'src/plugins/data_views/common';

export enum SortDirection {
asc = 'asc',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { CONTEXT_TIE_BREAKER_FIELDS_SETTING } from '../../../../common';
import { fetchAnchor } from '../services/anchor';
import { fetchSurroundingDocs, SurrDocType } from '../services/context';
import { MarkdownSimple, toMountPoint, wrapWithTheme } from '../../../../../kibana_react/public';
import { DataView, SortDirection } from '../../../../../data/common';
import type { DataView } from '../../../../../data_views/common';
import { SortDirection } from '../../../../../data/common';
import {
ContextFetchState,
FailureReason,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import React from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { EuiCallOut, EuiLink, EuiLoadingSpinner, EuiPageContent, EuiPage } from '@elastic/eui';
import { DataView } from 'src/plugins/data/common';
import type { DataView } from 'src/plugins/data_views/common';
import { DocViewer } from '../../../services/doc_views/components/doc_viewer';
import { ElasticRequestState } from '../types';
import { useEsDocSearch } from '../../../utils/use_es_doc_search';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React from 'react';
import { act } from 'react-dom/test-utils';
import { Subject, BehaviorSubject } from 'rxjs';
import { mountWithIntl } from '@kbn/test-jest-helpers';
import type { DataView } from '../../../../../../data/common';
import type { DataView } from '../../../../../../data_views/common';
import { setHeaderActionMenuMounter, setUiActions } from '../../../../kibana_services';
import { esHits } from '../../../../__mocks__/es_hits';
import { savedSearchMock } from '../../../../__mocks__/saved_search';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
EuiSpacer,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import type { DataView } from '../../../../../../data/common';
import type { DataView } from '../../../../../../data_views/common';
import { HitsCounter } from '../hits_counter';
import { SavedSearch } from '../../../../services/saved_searches';
import { GetStateReturn } from '../../services/discover_state';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
import type { Filter } from '@kbn/es-query';
import { METRIC_TYPE, UiCounterMetricType } from '@kbn/analytics';
import { useDiscoverServices } from '../../../../utils/use_discover_services';
import { DataViewField, DataView, Query } from '../../../../../../data/common';
import type { Query } from '../../../../../../data/common';
import type { DataViewField, DataView } from '../../../../../../data_views/common';
import {
EmbeddableInput,
EmbeddableOutput,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
SEARCH_FIELDS_FROM_SOURCE,
} from '../../../../../common';
import { useColumns } from '../../../../utils/use_data_grid_columns';
import { DataView } from '../../../../../../data/common';
import { DataView } from '../../../../../../data_views/common';
import { SavedSearch } from '../../../../services/saved_searches';
import { DataDocumentsMsg, DataDocuments$ } from '../../utils/use_saved_search';
import { AppState, GetStateReturn } from '../../services/discover_state';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { esHits } from '../../../../__mocks__/es_hits';
import { indexPatternMock } from '../../../../__mocks__/index_pattern';
import { savedSearchMock } from '../../../../__mocks__/saved_search';
import { createSearchSourceMock } from '../../../../../../data/common/search/search_source/mocks';
import { DataView, IndexPatternAttributes } from '../../../../../../data/common';
import type { DataView, DataViewAttributes } from '../../../../../../data_views/common';
import { SavedObject } from '../../../../../../../core/types';
import { indexPatternWithTimefieldMock } from '../../../../__mocks__/index_pattern_with_timefield';
import { GetStateReturn } from '../../services/discover_state';
Expand Down Expand Up @@ -57,7 +57,7 @@ function mountComponent(indexPattern: DataView, prevSidebarClosed?: boolean) {

const indexPatternList = [indexPattern].map((ip) => {
return { ...ip, ...{ attributes: { title: ip.title } } };
}) as unknown as Array<SavedObject<IndexPatternAttributes>>;
}) as unknown as Array<SavedObject<DataViewAttributes>>;

const main$ = new BehaviorSubject({
fetchStatus: FetchStatus.COMPLETE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { useDiscoverServices } from '../../../../utils/use_discover_services';
import { DiscoverNoResults } from '../no_results';
import { LoadingSpinner } from '../loading_spinner/loading_spinner';
import { generateFilters } from '../../../../../../data/public';
import { DataViewField } from '../../../../../../data/common';
import { DataViewField } from '../../../../../../data_views/common';
import { DiscoverSidebarResponsive } from '../sidebar';
import { DiscoverLayoutProps } from './types';
import { SEARCH_FIELDS_FROM_SOURCE, SHOW_FIELD_STATISTICS } from '../../../../../common';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
* Side Public License, v 1.
*/

import {
DataView,
IndexPatternAttributes,
Query,
SavedObject,
TimeRange,
} from '../../../../../../data/common';
import type { Query, SavedObject, TimeRange } from '../../../../../../data/common';
kertal marked this conversation as resolved.
Show resolved Hide resolved
import type { DataView, DataViewAttributes } from '../../../../../../data_views/common';
import { ISearchSource } from '../../../../../../data/public';
import { AppState, GetStateReturn } from '../../services/discover_state';
import { DataRefetch$, SavedSearchData } from '../../utils/use_saved_search';
Expand All @@ -22,7 +17,7 @@ import { ElasticSearchHit } from '../../../../types';

export interface DiscoverLayoutProps {
indexPattern: DataView;
indexPatternList: Array<SavedObject<IndexPatternAttributes>>;
indexPatternList: Array<SavedObject<DataViewAttributes>>;
inspectorAdapters: { requests: RequestAdapter };
navigateTo: (url: string) => void;
onChangeIndexPattern: (id: string) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { FieldSpec, IndexPatternField } from '../../../../../../../data_views/common';
import { FieldSpec, DataViewField } from '../../../../../../../data_views/common';

export const fieldSpecMap: Record<string, FieldSpec> = {
'machine.os': {
Expand Down Expand Up @@ -39,7 +39,7 @@ export const fieldSpecMap: Record<string, FieldSpec> = {
},
};

export const numericField = new IndexPatternField({
export const numericField = new DataViewField({
name: 'bytes',
type: 'number',
esTypes: ['long'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { findTestSubject } from '@elastic/eui/lib/test';
import { mountWithIntl } from '@kbn/test-jest-helpers';

import { DiscoverField } from './discover_field';
import { DataViewField } from '../../../../../../data/common';
import { DataViewField } from '../../../../../../data_views/common';
import { stubIndexPattern } from '../../../../../../data/common/stubs';
import { KibanaContextProvider } from '../../../../../../kibana_react/public';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import classNames from 'classnames';
import { FieldButton, FieldIcon } from '@kbn/react-field';
import { DiscoverFieldDetails } from './discover_field_details';
import { FieldDetails } from './types';
import { DataViewField, DataView } from '../../../../../../data/common';
import type { DataViewField, DataView } from '../../../../../../data_views/common';
import { getFieldTypeName } from './lib/get_field_type_name';
import { DiscoverFieldVisualize } from './discover_field_visualize';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { EuiText, EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@e
import { i18n } from '@kbn/i18n';
import { StringFieldProgressBar } from './string_progress_bar';
import { Bucket } from './types';
import { DataViewField } from '../../../../../../data/common';
import { DataViewField } from '../../../../../../data_views/common';
import './discover_field_bucket.scss';

interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { findTestSubject } from '@elastic/eui/lib/test';
import { mountWithIntl } from '@kbn/test-jest-helpers';

import { DiscoverFieldDetails } from './discover_field_details';
import { DataViewField } from '../../../../../../data/common';
import { DataViewField } from '../../../../../../data_views/common';
import { stubIndexPattern } from '../../../../../../data/common/stubs';

describe('discover sidebar field details', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { EuiText, EuiSpacer, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { DiscoverFieldBucket } from './discover_field_bucket';
import { Bucket, FieldDetails } from './types';
import { DataViewField, DataView } from '../../../../../../data/common';
import { DataViewField, DataView } from '../../../../../../data_views/common';

interface DiscoverFieldDetailsProps {
field: DataViewField;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React, { useEffect, useState } from 'react';
import { METRIC_TYPE, UiCounterMetricType } from '@kbn/analytics';
import type { DataView, DataViewField } from 'src/plugins/data/common';
import type { DataView, DataViewField } from 'src/plugins/data_views/common';

import { triggerVisualizeActions, VisualizeInformation } from './lib/visualize_trigger_utils';
import type { FieldDetails } from './types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import React from 'react';
import { EuiButton } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { IndexPatternField } from '../../../../../../data_views/common';
import type { DataViewField } from '../../../../../../data_views/common';
import { VisualizeInformation } from './lib/visualize_trigger_utils';

interface DiscoverFieldVisualizeInnerProps {
field: IndexPatternField;
field: DataViewField;
visualizeInfo: VisualizeInformation;
handleVisualizeLinkClick: (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => void;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ChangeIndexPattern } from './change_indexpattern';
import { SavedObject } from 'kibana/server';
import { DiscoverIndexPattern, DiscoverIndexPatternProps } from './discover_index_pattern';
import { EuiSelectable } from '@elastic/eui';
import { DataView, DataViewAttributes } from 'src/plugins/data/common';
import type { DataView, DataViewAttributes } from 'src/plugins/data_views/common';
import { indexPatternsMock } from '../../../../__mocks__/index_patterns';

const indexPattern = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React, { useState, useEffect } from 'react';
import { SavedObject } from 'kibana/public';
import { DataView, DataViewAttributes } from 'src/plugins/data/common';
import type { DataView, DataViewAttributes } from 'src/plugins/data_views/common';
import { IndexPatternRef } from './types';
import { ChangeIndexPattern } from './change_indexpattern';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { useDiscoverServices } from '../../../../utils/use_discover_services';
import { DataView } from '../../../../../../data/common';
import type { DataView } from '../../../../../../data_views/common';

export interface DiscoverIndexPatternManagementProps {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import realHits from '../../../../__fixtures__/real_hits.js';
import { mountWithIntl } from '@kbn/test-jest-helpers';
import React from 'react';
import { DiscoverSidebarProps } from './discover_sidebar';
import { flattenHit, IndexPatternAttributes } from '../../../../../../data/common';
import { flattenHit } from '../../../../../../data/common';
import { DataViewAttributes } from '../../../../../../data_views/common';
import { SavedObject } from '../../../../../../../core/types';
import { getDefaultFieldFilter } from './lib/field_filter';
import { DiscoverSidebarComponent as DiscoverSidebar } from './discover_sidebar';
Expand All @@ -37,9 +38,9 @@ function getCompProps(): DiscoverSidebarProps {
> as ElasticSearchHit[];

const indexPatternList = [
{ id: '0', attributes: { title: 'b' } } as SavedObject<IndexPatternAttributes>,
{ id: '1', attributes: { title: 'a' } } as SavedObject<IndexPatternAttributes>,
{ id: '2', attributes: { title: 'c' } } as SavedObject<IndexPatternAttributes>,
{ id: '0', attributes: { title: 'b' } } as SavedObject<DataViewAttributes>,
{ id: '1', attributes: { title: 'a' } } as SavedObject<DataViewAttributes>,
{ id: '2', attributes: { title: 'c' } } as SavedObject<DataViewAttributes>,
];

const fieldCounts: Record<string, number> = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import realHits from '../../../../__fixtures__/real_hits.js';
import { act } from 'react-dom/test-utils';
import { mountWithIntl } from '@kbn/test-jest-helpers';
import React from 'react';
import { flattenHit, IndexPatternAttributes } from '../../../../../../data/common';
import { DataViewAttributes } from '../../../../../../data_views/common';
import { flattenHit } from '../../../../../../data/common';
import { SavedObject } from '../../../../../../../core/types';
import {
DiscoverSidebarResponsive,
Expand Down Expand Up @@ -78,9 +79,9 @@ function getCompProps(): DiscoverSidebarResponsiveProps {
> as ElasticSearchHit[];

const indexPatternList = [
{ id: '0', attributes: { title: 'b' } } as SavedObject<IndexPatternAttributes>,
{ id: '1', attributes: { title: 'a' } } as SavedObject<IndexPatternAttributes>,
{ id: '2', attributes: { title: 'c' } } as SavedObject<IndexPatternAttributes>,
{ id: '0', attributes: { title: 'b' } } as SavedObject<DataViewAttributes>,
{ id: '1', attributes: { title: 'a' } } as SavedObject<DataViewAttributes>,
{ id: '2', attributes: { title: 'c' } } as SavedObject<DataViewAttributes>,
];

for (const hit of hits) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ import {
} from '@elastic/eui';
import { useDiscoverServices } from '../../../../utils/use_discover_services';
import { DiscoverIndexPattern } from './discover_index_pattern';
import { DataViewField, DataView, DataViewAttributes } from '../../../../../../data/common';
import type {
DataViewField,
DataView,
DataViewAttributes,
} from '../../../../../../data_views/common';
import { SavedObject } from '../../../../../../../core/types';
import { getDefaultFieldFilter } from './lib/field_filter';
import { DiscoverSidebar } from './discover_sidebar';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
import { keys, each, cloneDeep, clone, uniq, filter, map } from 'lodash';
// @ts-expect-error
import realHits from '../../../../../__fixtures__/real_hits.js';
import { flattenHit, DataView } from '../../../../../../../data/common';
import { flattenHit } from '../../../../../../../data/common';
import { DataView } from '../../../../../../../data_views/common';

// @ts-expect-error
import { fieldCalculator } from './field_calculator';
import { stubLogstashIndexPattern as indexPattern } from '../../../../../../../data/common/stubs';
import { stubLogstashDataView as indexPattern } from '../../../../../../../data_views/common/data_view.stub';

describe('fieldCalculator', function () {
it('should have a _countMissing that counts nulls & undefineds in an array', function () {
Expand Down
Loading