[index pattern managment] remove IFieldType references (#107239)

* remove IFieldType references

* typescript fixes

* update snapshot
This commit is contained in:
Matthew Kime 2021-07-30 08:58:23 -05:00 committed by GitHub
parent c330fc5a9a
commit b072a5d32b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 17 deletions

View file

@ -8,7 +8,7 @@
import React from 'react';
import { IndexPatternCreationConfig } from '../../../../../../../plugins/index_pattern_management/public';
import { IFieldType } from '../../../../../../../plugins/data/public';
import { IndexPatternField } from '../../../../../../../plugins/data/public';
import { mockManagementPlugin } from '../../../../mocks';
import { createComponentWithContext } from '../../../test_utils';
@ -20,7 +20,7 @@ jest.mock('./components/advanced_options', () => ({ AdvancedOptions: 'AdvancedOp
jest.mock('./components/action_buttons', () => ({ ActionButtons: 'ActionButtons' }));
jest.mock('./../../lib', () => ({
extractTimeFields: jest.requireActual('./../../lib').extractTimeFields,
ensureMinimumTime: async (fields: IFieldType) => Promise.resolve(fields),
ensureMinimumTime: async (fields: IndexPatternField) => Promise.resolve(fields),
}));
const mockIndexPatternCreationType = new IndexPatternCreationConfig({

View file

@ -7,13 +7,14 @@
*/
import { extractTimeFields } from './extract_time_fields';
import type { IndexPatternField } from 'src/plugins/data/public';
describe('extractTimeFields', () => {
it('should handle no date fields', () => {
const fields = [
{ type: 'text', name: 'name' },
{ type: 'text', name: 'name' },
];
] as IndexPatternField[];
expect(extractTimeFields(fields)).toEqual([
{ display: `The indices which match this index pattern don't contain any time fields.` },
@ -21,7 +22,7 @@ describe('extractTimeFields', () => {
});
it('should add extra options', () => {
const fields = [{ type: 'date', name: '@timestamp' }];
const fields = [{ type: 'date', name: '@timestamp' }] as IndexPatternField[];
expect(extractTimeFields(fields)).toEqual([
{ display: '@timestamp', fieldName: '@timestamp' },

View file

@ -7,9 +7,9 @@
*/
import { i18n } from '@kbn/i18n';
import { IFieldType } from '../../../../../../plugins/data/public';
import { IndexPatternField } from '../../../../../../plugins/data/public';
export function extractTimeFields(fields: IFieldType[]) {
export function extractTimeFields(fields: IndexPatternField[]) {
const dateFields = fields.filter((field) => field.type === 'date');
const label = i18n.translate(
'indexPatternManagement.createIndexPattern.stepTime.noTimeFieldsLabel',

View file

@ -138,7 +138,6 @@ exports[`Table should render normally 1`] = `
Object {
"displayName": "Elastic",
"excluded": false,
"format": "",
"hasRuntime": false,
"info": Array [],
"isMapped": true,
@ -150,7 +149,6 @@ exports[`Table should render normally 1`] = `
Object {
"displayName": "timestamp",
"excluded": false,
"format": "YYYY-MM-DD",
"hasRuntime": false,
"info": Array [],
"isMapped": true,
@ -161,7 +159,6 @@ exports[`Table should render normally 1`] = `
Object {
"displayName": "conflictingField",
"excluded": false,
"format": "",
"hasRuntime": false,
"info": Array [],
"isMapped": true,

View file

@ -25,7 +25,6 @@ const items: IndexedFieldItem[] = [
type: 'name',
kbnType: 'string',
excluded: false,
format: '',
isMapped: true,
hasRuntime: false,
},
@ -36,7 +35,6 @@ const items: IndexedFieldItem[] = [
kbnType: 'date',
info: [],
excluded: false,
format: 'YYYY-MM-DD',
isMapped: true,
hasRuntime: false,
},
@ -47,7 +45,6 @@ const items: IndexedFieldItem[] = [
kbnType: 'conflict',
info: [],
excluded: false,
format: '',
isMapped: true,
hasRuntime: false,
},

View file

@ -6,9 +6,12 @@
* Side Public License, v 1.
*/
import { IFieldType } from '../../../../../../plugins/data/public';
import { IndexPatternFieldBase } from '@kbn/es-query';
import { IndexPatternField } from '../../../../../../plugins/data/public';
export interface IndexedFieldItem extends IFieldType {
type IndexedFieldItemBase = Partial<IndexPatternField> & IndexPatternFieldBase;
export interface IndexedFieldItem extends IndexedFieldItemBase {
info: string[];
excluded: boolean;
kbnType: string;

View file

@ -39,10 +39,9 @@ import {
getSupportedScriptingLanguages,
} from '../../scripting_languages';
import {
IndexPatternField,
FieldFormatInstanceType,
IndexPattern,
IFieldType,
IndexPatternField,
KBN_FIELD_TYPES,
ES_FIELD_TYPES,
DataPublicPluginStart,
@ -145,7 +144,7 @@ export class FieldEditor extends PureComponent<FieldEdiorProps, FieldEditorState
scriptingLangs: [],
fieldTypes: [],
fieldTypeFormats: [],
existingFieldNames: indexPattern.fields.getAll().map((f: IFieldType) => f.name),
existingFieldNames: indexPattern.fields.getAll().map((f: IndexPatternField) => f.name),
fieldFormatId: undefined,
fieldFormatParams: {},
showScriptingHelp: false,