Skip to content

Commit b74c79a

Browse files
[Lens] Remove deprecated IFieldType (#109825)
* [Lens] Remove deprecated `IFieldType` * Fix types for terms.test * Replace IndexPatternField with FieldSpec, revert terms.test and update other tests Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent 9f5a936 commit b74c79a

File tree

6 files changed

+45
-20
lines changed

6 files changed

+45
-20
lines changed

x-pack/plugins/lens/public/app_plugin/app.test.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import { createMemoryHistory } from 'history';
2323
import {
2424
esFilters,
2525
FilterManager,
26-
IFieldType,
2726
IndexPattern,
2827
Query,
2928
} from '../../../../../src/plugins/data/public';
29+
import type { FieldSpec } from '../../../../../src/plugins/data/common';
3030
import { TopNavMenuData } from '../../../../../src/plugins/navigation/public';
3131
import { LensByValueInput } from '../embeddable/embeddable';
3232
import { SavedObjectReference } from '../../../../../src/core/types';
@@ -146,7 +146,7 @@ describe('Lens App', () => {
146146
it('updates global filters with store state', async () => {
147147
const services = makeDefaultServices(sessionIdSubject);
148148
const indexPattern = ({ id: 'index1' } as unknown) as IndexPattern;
149-
const pinnedField = ({ name: 'pinnedField' } as unknown) as IFieldType;
149+
const pinnedField = ({ name: 'pinnedField' } as unknown) as FieldSpec;
150150
const pinnedFilter = esFilters.buildExistsFilter(pinnedField, indexPattern);
151151
services.data.query.filterManager.getFilters = jest.fn().mockImplementation(() => {
152152
return [];
@@ -644,8 +644,8 @@ describe('Lens App', () => {
644644

645645
it('saves app filters and does not save pinned filters', async () => {
646646
const indexPattern = ({ id: 'index1' } as unknown) as IndexPattern;
647-
const field = ({ name: 'myfield' } as unknown) as IFieldType;
648-
const pinnedField = ({ name: 'pinnedField' } as unknown) as IFieldType;
647+
const field = ({ name: 'myfield' } as unknown) as FieldSpec;
648+
const pinnedField = ({ name: 'pinnedField' } as unknown) as FieldSpec;
649649
const unpinned = esFilters.buildExistsFilter(field, indexPattern);
650650
const pinned = esFilters.buildExistsFilter(pinnedField, indexPattern);
651651
await act(async () => {
@@ -857,7 +857,7 @@ describe('Lens App', () => {
857857
it('updates the filters when the user changes them', async () => {
858858
const { instance, services, lensStore } = await mountWith({});
859859
const indexPattern = ({ id: 'index1' } as unknown) as IndexPattern;
860-
const field = ({ name: 'myfield' } as unknown) as IFieldType;
860+
const field = ({ name: 'myfield' } as unknown) as FieldSpec;
861861
expect(lensStore.getState()).toEqual({
862862
lens: expect.objectContaining({
863863
filters: [],
@@ -912,7 +912,7 @@ describe('Lens App', () => {
912912
}),
913913
});
914914
const indexPattern = ({ id: 'index1' } as unknown) as IndexPattern;
915-
const field = ({ name: 'myfield' } as unknown) as IFieldType;
915+
const field = ({ name: 'myfield' } as unknown) as FieldSpec;
916916
act(() =>
917917
services.data.query.filterManager.setFilters([
918918
esFilters.buildExistsFilter(field, indexPattern),
@@ -1047,8 +1047,8 @@ describe('Lens App', () => {
10471047
})
10481048
);
10491049
const indexPattern = ({ id: 'index1' } as unknown) as IndexPattern;
1050-
const field = ({ name: 'myfield' } as unknown) as IFieldType;
1051-
const pinnedField = ({ name: 'pinnedField' } as unknown) as IFieldType;
1050+
const field = ({ name: 'myfield' } as unknown) as FieldSpec;
1051+
const pinnedField = ({ name: 'pinnedField' } as unknown) as FieldSpec;
10521052
const unpinned = esFilters.buildExistsFilter(field, indexPattern);
10531053
const pinned = esFilters.buildExistsFilter(pinnedField, indexPattern);
10541054
FilterManager.setFiltersStore([pinned], esFilters.FilterStateStore.GLOBAL_STATE);
@@ -1104,8 +1104,8 @@ describe('Lens App', () => {
11041104
})
11051105
);
11061106
const indexPattern = ({ id: 'index1' } as unknown) as IndexPattern;
1107-
const field = ({ name: 'myfield' } as unknown) as IFieldType;
1108-
const pinnedField = ({ name: 'pinnedField' } as unknown) as IFieldType;
1107+
const field = ({ name: 'myfield' } as unknown) as FieldSpec;
1108+
const pinnedField = ({ name: 'pinnedField' } as unknown) as FieldSpec;
11091109
const unpinned = esFilters.buildExistsFilter(field, indexPattern);
11101110
const pinned = esFilters.buildExistsFilter(pinnedField, indexPattern);
11111111
FilterManager.setFiltersStore([pinned], esFilters.FilterStateStore.GLOBAL_STATE);

x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import { ReactWrapper } from 'enzyme';
2828
import { DragDrop, ChildDragDropProvider } from '../../../drag_drop';
2929
import { fromExpression } from '@kbn/interpreter/common';
3030
import { coreMock } from 'src/core/public/mocks';
31-
import { esFilters, IFieldType, IndexPattern } from '../../../../../../../src/plugins/data/public';
31+
import { esFilters, IndexPattern } from '../../../../../../../src/plugins/data/public';
32+
import type { FieldSpec } from '../../../../../../../src/plugins/data/common';
3233
import { UiActionsStart } from '../../../../../../../src/plugins/ui_actions/public';
3334
import { uiActionsPluginMock } from '../../../../../../../src/plugins/ui_actions/public/mocks';
3435
import { TriggerContract } from '../../../../../../../src/plugins/ui_actions/public/triggers';
@@ -419,7 +420,7 @@ describe('workspace_panel', () => {
419420
expect(expressionRendererMock).toHaveBeenCalledTimes(1);
420421

421422
const indexPattern = ({ id: 'index1' } as unknown) as IndexPattern;
422-
const field = ({ name: 'myfield' } as unknown) as IFieldType;
423+
const field = ({ name: 'myfield' } as unknown) as FieldSpec;
423424

424425
await act(async () => {
425426
instance.setProps({

x-pack/plugins/lens/public/indexpattern_datasource/datapanel.test.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,14 @@ describe('IndexPattern Data Panel', () => {
664664
...props.indexPatterns['1'],
665665
fields: [
666666
...props.indexPatterns['1'].fields,
667-
{ name: '_id', displayName: '_id', meta: true, type: 'string' },
667+
{
668+
name: '_id',
669+
displayName: '_id',
670+
meta: true,
671+
type: 'string',
672+
searchable: true,
673+
aggregatable: true,
674+
},
668675
],
669676
},
670677
}}

x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile.test.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ describe('percentile', () => {
8181
displayName: 'bytes',
8282
type: 'number',
8383
esTypes: ['long'],
84+
searchable: true,
8485
aggregatable: true,
8586
})
8687
).toEqual({
@@ -97,6 +98,7 @@ describe('percentile', () => {
9798
displayName: 'response_time',
9899
type: 'histogram',
99100
esTypes: ['histogram'],
101+
searchable: true,
100102
aggregatable: true,
101103
})
102104
).toEqual({
@@ -113,6 +115,7 @@ describe('percentile', () => {
113115
displayName: 'origin',
114116
type: 'string',
115117
esTypes: ['keyword'],
118+
searchable: true,
116119
aggregatable: true,
117120
})
118121
).toBeUndefined();

x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,23 @@ const defaultOptions = {
9696
id: '1',
9797
title: 'my_index_pattern',
9898
hasRestrictions: false,
99-
fields: [{ name: sourceField, type: 'number', displayName: sourceField }],
99+
fields: [
100+
{
101+
name: sourceField,
102+
type: 'number',
103+
displayName: sourceField,
104+
searchable: true,
105+
aggregatable: true,
106+
},
107+
],
100108
getFieldByName: getFieldByNameFactory([
101-
{ name: sourceField, type: 'number', displayName: sourceField },
109+
{
110+
name: sourceField,
111+
type: 'number',
112+
displayName: sourceField,
113+
searchable: true,
114+
aggregatable: true,
115+
},
102116
]),
103117
},
104118
operationDefinitionMap: {},

x-pack/plugins/lens/public/indexpattern_datasource/types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
* 2.0.
66
*/
77

8-
import { IFieldType } from 'src/plugins/data/common';
9-
import { IndexPatternColumn, IncompleteColumn } from './operations';
10-
import { IndexPatternAggRestrictions } from '../../../../../src/plugins/data/public';
11-
import { DragDropIdentifier } from '../drag_drop/providers';
8+
import type { IndexPatternColumn, IncompleteColumn } from './operations';
9+
import type { IndexPatternAggRestrictions } from '../../../../../src/plugins/data/public';
10+
import type { FieldSpec } from '../../../../../src/plugins/data/common';
11+
import type { DragDropIdentifier } from '../drag_drop/providers';
1212

1313
export {
1414
FieldBasedIndexPatternColumn,
@@ -57,7 +57,7 @@ export interface IndexPattern {
5757
hasRestrictions: boolean;
5858
}
5959

60-
export type IndexPatternField = IFieldType & {
60+
export type IndexPatternField = FieldSpec & {
6161
displayName: string;
6262
aggregationRestrictions?: Partial<IndexPatternAggRestrictions>;
6363
meta?: boolean;

0 commit comments

Comments
 (0)