Skip to content

Commit

Permalink
remove unused deprecated code and use field format plugin directly fo…
Browse files Browse the repository at this point in the history
…r data view field editor (elastic#126029)
  • Loading branch information
mattkime authored and lucasfcosta committed Mar 2, 2022
1 parent 397ef0d commit d9dcc42
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 49 deletions.
8 changes: 0 additions & 8 deletions src/plugins/data/common/es_query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import {
KueryNode as oldKueryNode,
FilterMeta as oldFilterMeta,
FILTERS as oldFILTERS,
IFieldSubType as oldIFieldSubType,
EsQueryConfig as oldEsQueryConfig,
compareFilters as oldCompareFilters,
COMPARE_ALL_OPTIONS as OLD_COMPARE_ALL_OPTIONS,
Expand Down Expand Up @@ -356,12 +355,6 @@ type KueryNode = oldKueryNode;
*/
type FilterMeta = oldFilterMeta;

/**
* @deprecated Import from the "@kbn/es-query" package directly instead.
* @removeBy 8.1
*/
type IFieldSubType = oldIFieldSubType;

/**
* @deprecated Import from the "@kbn/es-query" package directly instead.
* @removeBy 8.1
Expand All @@ -385,7 +378,6 @@ export type {
RangeFilter,
KueryNode,
FilterMeta,
IFieldSubType,
EsQueryConfig,
};
export {
Expand Down
27 changes: 2 additions & 25 deletions src/plugins/data/common/kbn_field_types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,6 @@
*/

// NOTE: trick to mark exports as deprecated (only for constants and types, but not for interfaces, classes or enums)
import {
getFilterableKbnTypeNames as oldGetFilterableKbnTypeNames,
getKbnFieldType as oldGetKbnFieldType,
getKbnTypeNames as oldGetKbnTypeNames,
KbnFieldType,
} from '@kbn/field-types';
import { KbnFieldType } from '@kbn/field-types';

/**
* @deprecated Import from the "@kbn/field-types" package directly instead.
* @removeBy 8.1
*/
const getFilterableKbnTypeNames = oldGetFilterableKbnTypeNames;

/**
* @deprecated Import from the "@kbn/field-types" package directly instead.
* @removeBy 8.1
*/
const getKbnFieldType = oldGetKbnFieldType;

/**
* @deprecated Import from the "@kbn/field-types" package directly instead.
* @removeBy 8.1
*/
const getKbnTypeNames = oldGetKbnTypeNames;

export { getKbnFieldType, getKbnTypeNames, getFilterableKbnTypeNames, KbnFieldType };
export { KbnFieldType };
2 changes: 0 additions & 2 deletions src/plugins/data/public/deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import {
PhraseFilter,
CustomFilter,
MatchAllFilter,
IFieldSubType,
EsQueryConfig,
FilterStateStore,
compareFilters,
Expand Down Expand Up @@ -147,7 +146,6 @@ export type {
PhraseFilter,
CustomFilter,
MatchAllFilter,
IFieldSubType,
EsQueryConfig,
};
export { isFilter, isFilters };
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export type {

export type { AggsStart } from './search/aggs';

export { getTime, getKbnTypeNames } from '../common';
export { getTime } from '../common';

export { isTimeRange, isQuery } from '../common';

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/server/deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ export const esQuery = {
buildEsQuery,
};

export type { Filter, Query, EsQueryConfig, KueryNode, IFieldSubType } from '../common';
export type { Filter, Query, EsQueryConfig, KueryNode } from '../common';
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import React, { createContext, useContext, FunctionComponent, useMemo } from 'react';
import { NotificationsStart, CoreStart } from 'src/core/public';
import { FieldFormatsStart } from '../shared_imports';
import type { DataView, DataPublicPluginStart } from '../shared_imports';
import { ApiService } from '../lib/api';
import type { InternalFieldType, PluginStart } from '../types';
Expand All @@ -25,7 +26,7 @@ export interface Context {
notifications: NotificationsStart;
};
fieldFormatEditors: PluginStart['fieldFormatEditors'];
fieldFormats: DataPublicPluginStart['fieldFormats'];
fieldFormats: FieldFormatsStart;
/**
* An array of field names not allowed.
* e.g we probably don't want a user to give a name of an existing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { DocLinksStart, NotificationsStart, CoreStart } from 'src/core/public';
import { i18n } from '@kbn/i18n';
import { METRIC_TYPE } from '@kbn/analytics';

import { FieldFormatsStart } from 'src/plugins/field_formats/public';
import {
DataViewField,
DataView,
Expand Down Expand Up @@ -51,7 +52,7 @@ export interface Props {
apiService: ApiService;
/** Field format */
fieldFormatEditors: PluginStart['fieldFormatEditors'];
fieldFormats: DataPublicPluginStart['fieldFormats'];
fieldFormats: FieldFormatsStart;
uiSettings: CoreStart['uiSettings'];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,21 @@ import { EuiCode, EuiFormRow, EuiSelect } from '@elastic/eui';

import { FormattedMessage } from '@kbn/i18n-react';
import { i18n } from '@kbn/i18n';
import {
IndexPattern,
KBN_FIELD_TYPES,
ES_FIELD_TYPES,
DataPublicPluginStart,
} from 'src/plugins/data/public';
import { KBN_FIELD_TYPES, ES_FIELD_TYPES } from 'src/plugins/data/public';
import type { FieldFormatInstanceType } from 'src/plugins/field_formats/common';
import { CoreStart } from 'src/core/public';
import { castEsToKbnFieldTypeName } from '@kbn/field-types';
import { FieldFormatsStart } from 'src/plugins/field_formats/public';
import { DataView } from 'src/plugins/data_views/public';
import { FormatEditor } from './format_editor';
import { FormatEditorServiceStart } from '../../service';
import { FieldFormatConfig } from '../../types';

export interface FormatSelectEditorProps {
esTypes: ES_FIELD_TYPES[];
indexPattern: IndexPattern;
indexPattern: DataView;
fieldFormatEditors: FormatEditorServiceStart['fieldFormatEditors'];
fieldFormats: DataPublicPluginStart['fieldFormats'];
fieldFormats: FieldFormatsStart;
uiSettings: CoreStart['uiSettings'];
onChange: (change?: FieldFormatConfig) => void;
onError: (error?: string) => void;
Expand All @@ -54,7 +51,7 @@ interface InitialFieldTypeFormat extends FieldTypeFormat {
const getFieldTypeFormatsList = (
fieldType: KBN_FIELD_TYPES,
defaultFieldFormat: FieldFormatInstanceType,
fieldFormats: DataPublicPluginStart['fieldFormats']
fieldFormats: FieldFormatsStart
) => {
const formatsByType = fieldFormats.getByFieldType(fieldType).map(({ id, title }) => ({
id,
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/data_view_field_editor/public/plugin.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jest.mock('../../kibana_react/public', () => {
import { CoreStart } from 'src/core/public';
import { coreMock } from 'src/core/public/mocks';
import { dataPluginMock } from '../../data/public/mocks';
import { fieldFormatsServiceMock } from '../../field_formats/public/mocks';
import { usageCollectionPluginMock } from '../../usage_collection/public/mocks';

import { FieldEditorLoader } from './components/field_editor_loader';
Expand All @@ -35,7 +36,7 @@ describe('DataViewFieldEditorPlugin', () => {
data: dataPluginMock.createStartContract(),
usageCollection: usageCollectionPluginMock.createSetupContract(),
dataViews: dataPluginMock.createStartContract().dataViews,
fieldFormats: dataPluginMock.createStartContract().fieldFormats,
fieldFormats: fieldFormatsServiceMock.createStartContract(),
};

let plugin: IndexPatternFieldEditorPlugin;
Expand Down

0 comments on commit d9dcc42

Please sign in to comment.