Skip to content

Commit

Permalink
[index pattern managment] remove IFieldType references (#107239)
Browse files Browse the repository at this point in the history
* remove IFieldType references

* typescript fixes

* update snapshot
  • Loading branch information
mattkime authored Jul 30, 2021
1 parent c330fc5 commit b072a5d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@
*/

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.` },
]);
});

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' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const items: IndexedFieldItem[] = [
type: 'name',
kbnType: 'string',
excluded: false,
format: '',
isMapped: true,
hasRuntime: false,
},
Expand All @@ -36,7 +35,6 @@ const items: IndexedFieldItem[] = [
kbnType: 'date',
info: [],
excluded: false,
format: 'YYYY-MM-DD',
isMapped: true,
hasRuntime: false,
},
Expand All @@ -47,7 +45,6 @@ const items: IndexedFieldItem[] = [
kbnType: 'conflict',
info: [],
excluded: false,
format: '',
isMapped: true,
hasRuntime: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ import {
getSupportedScriptingLanguages,
} from '../../scripting_languages';
import {
IndexPatternField,
FieldFormatInstanceType,
IndexPattern,
IFieldType,
IndexPatternField,
KBN_FIELD_TYPES,
ES_FIELD_TYPES,
DataPublicPluginStart,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b072a5d

Please sign in to comment.