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/public';

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/public';

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/public';
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/public';
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/public';
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/public';
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/public';
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/public';
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/public';
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/public';

export enum SortDirection {
asc = 'asc',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
} from '../__mocks__/use_context_app_fetch';
import { indexPatternWithTimefieldMock } from '../../../__mocks__/index_pattern_with_timefield';
import { createContextSearchSourceStub } from '../services/_stubs';
import { DataView } from '../../../../../data_views/common';
import { DataView } from '../../../../../data_views/public';
import { themeServiceMock } from '../../../../../../core/public/mocks';
import { KibanaContextProvider } from '../../../../../kibana_react/public';

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/public';
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/public';
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/public';
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/public';
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/public';
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/public';
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,8 @@ 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 { DataViewAttributes } from '../../../../../../data_views/common';
import type { DataView } from '../../../../../../data_views/public';
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 +58,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/public';
import { DiscoverSidebarResponsive } from '../sidebar';
import { DiscoverLayoutProps } from './types';
import { SEARCH_FIELDS_FROM_SOURCE, SHOW_FIELD_STATISTICS } from '../../../../../common';
Expand All @@ -48,7 +48,7 @@ import {
import { FieldStatisticsTable } from '../field_stats_table';
import { VIEW_MODE } from '../../../../components/view_mode_toggle';
import { DOCUMENTS_VIEW_CLICK, FIELD_STATISTICS_VIEW_CLICK } from '../field_stats_table/constants';
import { DataViewType, DataView } from '../../../../../../data_views/common';
import { DataViewType, DataView } from '../../../../../../data_views/public';

/**
* Local storage key for sidebar persistence state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
* 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 { DataViewAttributes } from '../../../../../../data_views/common';
import type { DataView } from '../../../../../../data_views/public';
import { ISearchSource } from '../../../../../../data/public';
import { AppState, GetStateReturn } from '../../services/discover_state';
import { DataRefetch$, SavedSearchData } from '../../utils/use_saved_search';
Expand All @@ -22,7 +18,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 @@ -10,7 +10,7 @@ import { storiesOf } from '@storybook/react';
import React from 'react';
import { KBN_FIELD_TYPES } from '@kbn/field-types';
import { DiscoverFieldDetails } from '../discover_field_details';
import { DataView, IndexPatternField } from '../../../../../../../data_views/common';
import { DataView, IndexPatternField } from '../../../../../../../data_views/public';
import { fieldSpecMap } from './fields';
import { numericField as field } from './fields';
import { Bucket } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* Side Public License, v 1.
*/

import { FieldSpec, IndexPatternField } from '../../../../../../../data_views/common';
import { FieldSpec } from '../../../../../../../data_views/common';
kertal marked this conversation as resolved.
Show resolved Hide resolved
import { DataViewField } from '../../../../../../../data_views/public';

export const fieldSpecMap: Record<string, FieldSpec> = {
'machine.os': {
Expand Down Expand Up @@ -39,7 +40,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/public';
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/public';
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/public';
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/public';
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/public';

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/public';

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/public';
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,8 @@ 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 { DataViewAttributes } from 'src/plugins/data_views/common';
kertal marked this conversation as resolved.
Show resolved Hide resolved
import type { DataView } from 'src/plugins/data_views/public';
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,8 @@

import React, { useState, useEffect } from 'react';
import { SavedObject } from 'kibana/public';
import { DataView, DataViewAttributes } from 'src/plugins/data/common';
import type { DataViewAttributes } from 'src/plugins/data_views/common';
import type { DataView } from 'src/plugins/data_views/public';
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/public';

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 @@ -39,7 +39,7 @@ import { DiscoverSidebarResponsiveProps } from './discover_sidebar_responsive';
import { DiscoverIndexPatternManagement } from './discover_index_pattern_management';
import { VIEW_MODE } from '../../../../components/view_mode_toggle';
import { ElasticSearchHit } from '../../../../types';
import { DataViewField } from '../../../../../../data_views/common';
import { DataViewField } from '../../../../../../data_views/public';

/**
* Default number of available fields displayed and added on scroll
Expand Down
Loading