Skip to content

Commit

Permalink
feat: cleanup deprecated service and type
Browse files Browse the repository at this point in the history
  • Loading branch information
nlatipov committed May 17, 2022
1 parent ca5398a commit a7aab00
Show file tree
Hide file tree
Showing 30 changed files with 118 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { i18n } from '@kbn/i18n';
import { ThemeServiceSetup } from '@kbn/core/public';
import { toMountPoint } from '@kbn/kibana-react-plugin/public';
import { Action, createAction, IncompatibleActionError } from '@kbn/ui-actions-plugin/public';
import { Filter, FilterManager, TimefilterContract, esFilters } from '@kbn/data-plugin/public';
import { FilterManager, TimefilterContract, esFilters } from '@kbn/data-plugin/public';
import type { Filter } from '@kbn/es-query';
import { getOverlays, getIndexPatterns } from '../services';
import { applyFiltersPopover } from '../apply_filters';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
mapAndFlattenFilters,
getFieldDisplayValueFromFilter,
} from '@kbn/data-plugin/public';
import { Filter } from '@kbn/data-plugin/common';
import type { Filter } from '@kbn/es-query';
import { DataView } from '@kbn/data-views-plugin/public';
import { FilterLabel } from '../filter_bar';

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

import React from 'react';
import { Filter } from '@kbn/data-plugin/common';
import type { Filter } from '@kbn/es-query';
import { DataView } from '@kbn/data-views-plugin/common';

type CancelFnType = () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { coreMock } from '@kbn/core/public/mocks';
import { KueryNode } from '@kbn/data-plugin/public';
import type { KueryNode } from '@kbn/es-query';
import { setupGetConjunctionSuggestions } from './conjunction';
import { QuerySuggestionGetFnArgs } from '../query_suggestion_provider';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import indexPatternResponse from './__fixtures__/index_pattern_response.json';

import { indexPatterns as indexPatternsUtils, KueryNode } from '@kbn/data-plugin/public';
import { indexPatterns as indexPatternsUtils } from '@kbn/data-plugin/public';
import type { KueryNode } from '@kbn/es-query';
import { setupGetFieldSuggestions } from './field';
import { QuerySuggestionGetFnArgs } from '../query_suggestion_provider';
import { coreMock } from '@kbn/core/public/mocks';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import indexPatternResponse from './__fixtures__/index_pattern_response.json';

import { setupGetOperatorSuggestions } from './operator';
import { KueryNode } from '@kbn/data-plugin/public';
import type { KueryNode } from '@kbn/es-query';
import { QuerySuggestionGetFnArgs } from '../query_suggestion_provider';
import { coreMock } from '@kbn/core/public/mocks';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { setupGetValueSuggestions } from './value';
import indexPatternResponse from './__fixtures__/index_pattern_response.json';

import { coreMock } from '@kbn/core/public/mocks';
import { KueryNode } from '@kbn/data-plugin/public';
import type { KueryNode } from '@kbn/es-query';
import { QuerySuggestionGetFnArgs } from '../query_suggestion_provider';

const mockKueryNode = (kueryNode: Partial<KueryNode>) => kueryNode as unknown as KueryNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { flatten } from 'lodash';
import { CoreSetup } from '@kbn/core/public';
import { IFieldType, IIndexPattern } from '@kbn/data-plugin/public';
import type { IIndexPattern, IFieldType } from '@kbn/data-views-plugin/common';
import { escapeQuotes } from './lib/escape_kuery';
import { KqlQuerySuggestionProvider } from './types';
import type { UnifiedSearchPublicPluginStart } from '../../../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { ValueSuggestionsMethod } from '@kbn/data-plugin/common';
import { IFieldType, IIndexPattern } from '@kbn/data-plugin/common';
import type { DataViewField, IIndexPattern } from '@kbn/data-views-plugin/common';

export enum QuerySuggestionTypes {
Field = 'field',
Expand Down Expand Up @@ -47,7 +47,7 @@ export interface QuerySuggestionBasic {
/** @public **/
export interface QuerySuggestionField extends QuerySuggestionBasic {
type: QuerySuggestionTypes.Field;
field: IFieldType;
field: DataViewField;
}

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

import { IUiSettingsClient, CoreSetup } from '@kbn/core/public';
import { stubIndexPattern, stubFields } from '@kbn/data-plugin/public/stubs';
import { stubFields } from '@kbn/data-views-plugin/common/stubs';
import { stubDataView } from '@kbn/data-views-plugin/common/data_view.stub';
import type { TimefilterSetup } from '@kbn/data-plugin/public';
import { UI_SETTINGS } from '@kbn/data-plugin/common';
import { setupValueSuggestionProvider } from './value_suggestion_provider';
Expand Down Expand Up @@ -48,7 +49,7 @@ describe('FieldSuggestions', () => {

it('should return an empty array', async () => {
const suggestions = await getValueSuggestions({
indexPattern: stubIndexPattern,
indexPattern: stubDataView,
field: stubFields[0],
query: '',
});
Expand All @@ -64,7 +65,7 @@ describe('FieldSuggestions', () => {
it('should return true/false for boolean fields', async () => {
const [field] = stubFields.filter(({ type }) => type === 'boolean');
const suggestions = await getValueSuggestions({
indexPattern: stubIndexPattern,
indexPattern: stubDataView,
field,
query: '',
});
Expand All @@ -76,7 +77,7 @@ describe('FieldSuggestions', () => {
it('should return an empty array if the field type is not a string or boolean', async () => {
const [field] = stubFields.filter(({ type }) => type !== 'string' && type !== 'boolean');
const suggestions = await getValueSuggestions({
indexPattern: stubIndexPattern,
indexPattern: stubDataView,
field,
query: '',
});
Expand All @@ -88,7 +89,7 @@ describe('FieldSuggestions', () => {
it('should return an empty array if the field is not aggregatable', async () => {
const [field] = stubFields.filter(({ aggregatable }) => !aggregatable);
const suggestions = await getValueSuggestions({
indexPattern: stubIndexPattern,
indexPattern: stubDataView,
field,
query: '',
});
Expand All @@ -103,7 +104,7 @@ describe('FieldSuggestions', () => {
);

await getValueSuggestions({
indexPattern: stubIndexPattern,
indexPattern: stubDataView,
field,
query: '',
useTimeRange: false,
Expand All @@ -117,7 +118,7 @@ describe('FieldSuggestions', () => {
({ type, aggregatable }) => type === 'string' && aggregatable
);
const args = {
indexPattern: stubIndexPattern,
indexPattern: stubDataView,
field,
query: '',
useTimeRange: false,
Expand All @@ -134,7 +135,7 @@ describe('FieldSuggestions', () => {
({ type, aggregatable }) => type === 'string' && aggregatable
);
const args = {
indexPattern: stubIndexPattern,
indexPattern: stubDataView,
field,
query: '',
useTimeRange: false,
Expand All @@ -158,35 +159,34 @@ describe('FieldSuggestions', () => {
);

await getValueSuggestions({
indexPattern: stubIndexPattern,
indexPattern: stubDataView,
field: fields[0],
query: '',
useTimeRange: false,
});
await getValueSuggestions({
indexPattern: stubIndexPattern,
indexPattern: stubDataView,
field: fields[0],
query: 'query',
useTimeRange: false,
});
await getValueSuggestions({
indexPattern: stubIndexPattern,
indexPattern: stubDataView,
field: fields[1],
query: '',
useTimeRange: false,
});
await getValueSuggestions({
indexPattern: stubIndexPattern,
indexPattern: stubDataView,
field: fields[1],
query: 'query',
useTimeRange: false,
});

const customIndexPattern = {
...stubIndexPattern,
const customIndexPattern = Object.assign({}, stubDataView, {
title: 'customIndexPattern',
useTimeRange: false,
};
});

await getValueSuggestions({
indexPattern: customIndexPattern,
Expand Down Expand Up @@ -222,7 +222,7 @@ describe('FieldSuggestions', () => {
);

await getValueSuggestions({
indexPattern: stubIndexPattern,
indexPattern: stubDataView,
field,
query: '',
useTimeRange: true,
Expand All @@ -243,7 +243,7 @@ describe('FieldSuggestions', () => {
);

await getValueSuggestions({
indexPattern: stubIndexPattern,
indexPattern: stubDataView,
field,
query: '',
useTimeRange: true,
Expand All @@ -263,7 +263,7 @@ describe('FieldSuggestions', () => {
);

await getValueSuggestions({
indexPattern: stubIndexPattern,
indexPattern: stubDataView,
field,
query: '',
useTimeRange: true,
Expand All @@ -283,7 +283,7 @@ describe('FieldSuggestions', () => {
);

await getValueSuggestions({
indexPattern: stubIndexPattern,
indexPattern: stubDataView,
field,
query: '',
useTimeRange: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@
import { CoreSetup } from '@kbn/core/public';
import dateMath from '@kbn/datemath';
import { memoize } from 'lodash';
import {
IIndexPattern,
IFieldType,
UI_SETTINGS,
ValueSuggestionsMethod,
} from '@kbn/data-plugin/common';
import { UI_SETTINGS, ValueSuggestionsMethod } from '@kbn/data-plugin/common';
import type { IIndexPattern, IFieldType } from '@kbn/data-views-plugin/common';
import type { TimefilterSetup } from '@kbn/data-plugin/public';
import { AutocompleteUsageCollector } from '../collectors';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
import { get } from 'lodash';
import React, { Component } from 'react';
import { XJsonLang } from '@kbn/monaco';
import { DataView, IFieldType } from '@kbn/data-views-plugin/common';
import { DataView, DataViewField } from '@kbn/data-views-plugin/common';
import { getIndexPatternFromFilter } from '@kbn/data-plugin/public';
import { CodeEditor } from '@kbn/kibana-react-plugin/public';
import { GenericComboBox, GenericComboBoxProps } from './generic_combo_box';
Expand Down Expand Up @@ -61,7 +61,7 @@ export interface Props {

interface State {
selectedIndexPattern?: DataView;
selectedField?: IFieldType;
selectedField?: DataViewField;
selectedOperator?: Operator;
params: any;
useCustomLabel: boolean;
Expand Down Expand Up @@ -447,7 +447,7 @@ class FilterEditorUI extends Component<Props, State> {
this.setState({ selectedIndexPattern, selectedField, selectedOperator, params });
};

private onFieldChange = ([selectedField]: IFieldType[]) => {
private onFieldChange = ([selectedField]: DataViewField[]) => {
const selectedOperator = undefined;
const params = undefined;
this.setState({ selectedField, selectedOperator, params });
Expand Down Expand Up @@ -529,7 +529,7 @@ function IndexPatternComboBox(props: GenericComboBoxProps<DataView>) {
return GenericComboBox(props);
}

function FieldComboBox(props: GenericComboBoxProps<IFieldType>) {
function FieldComboBox(props: GenericComboBoxProps<DataViewField>) {
return GenericComboBox(props);
}

Expand Down
Loading

0 comments on commit a7aab00

Please sign in to comment.