mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[data views] IndexPatternField => DataViewField (#133080)
* IndexPatternField => DataViewField
This commit is contained in:
parent
0eef31fe9f
commit
7958fa048c
41 changed files with 146 additions and 170 deletions
|
@ -143,7 +143,6 @@ export {
|
|||
isFilterable,
|
||||
fieldList,
|
||||
DataViewField,
|
||||
IndexPatternField,
|
||||
DataViewType,
|
||||
IndexPatternsService,
|
||||
DataViewsService,
|
||||
|
|
|
@ -15,10 +15,10 @@ import { AggType } from './agg_type';
|
|||
import { AggTypesRegistryStart } from './agg_types_registry';
|
||||
import { mockAggTypesRegistry } from './test_helpers';
|
||||
import { MetricAggType } from './metrics/metric_agg_type';
|
||||
import { IndexPattern, IndexPatternField, IIndexPatternFieldList } from '../..';
|
||||
import { DataView, DataViewField, IIndexPatternFieldList } from '../..';
|
||||
|
||||
describe('AggConfig', () => {
|
||||
let indexPattern: IndexPattern;
|
||||
let indexPattern: DataView;
|
||||
let typesRegistry: AggTypesRegistryStart;
|
||||
const fields = [
|
||||
{
|
||||
|
@ -55,11 +55,11 @@ describe('AggConfig', () => {
|
|||
fields: {
|
||||
getByName: (name: string) => fields.find((f) => f.name === name),
|
||||
filter: () => fields,
|
||||
} as unknown as IndexPattern['fields'],
|
||||
getFormatterForField: (field: IndexPatternField) => ({
|
||||
} as unknown as DataView['fields'],
|
||||
getFormatterForField: (field: DataViewField) => ({
|
||||
toJSON: () => ({}),
|
||||
}),
|
||||
} as IndexPattern;
|
||||
} as DataView;
|
||||
typesRegistry = mockAggTypesRegistry();
|
||||
});
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ import { AggConfigs, CreateAggConfigParams } from '../agg_configs';
|
|||
import { BUCKET_TYPES } from './bucket_agg_types';
|
||||
import { IBucketAggConfig } from './bucket_agg_type';
|
||||
import { mockAggTypesRegistry } from '../test_helpers';
|
||||
import type { IndexPatternField } from '../../..';
|
||||
import { IndexPattern } from '../../..';
|
||||
import type { DataViewField } from '../../..';
|
||||
import { DataView } from '../../..';
|
||||
|
||||
const indexPattern = {
|
||||
id: '1234',
|
||||
|
@ -41,9 +41,9 @@ const indexPattern = {
|
|||
searchable: true,
|
||||
},
|
||||
],
|
||||
} as IndexPattern;
|
||||
} as DataView;
|
||||
|
||||
indexPattern.fields.getByName = (name) => ({ name } as unknown as IndexPatternField);
|
||||
indexPattern.fields.getByName = (name) => ({ name } as unknown as DataViewField);
|
||||
|
||||
const singleTerm = {
|
||||
aggs: [
|
||||
|
|
|
@ -10,8 +10,8 @@ import { AggConfigs } from '../agg_configs';
|
|||
import { METRIC_TYPES } from '../metrics';
|
||||
import { mockAggTypesRegistry } from '../test_helpers';
|
||||
import { BUCKET_TYPES } from './bucket_agg_types';
|
||||
import type { IndexPatternField } from '../../..';
|
||||
import { IndexPattern } from '../../..';
|
||||
import type { DataViewField } from '../../..';
|
||||
import { DataView } from '../../..';
|
||||
|
||||
describe('Multi Terms Agg', () => {
|
||||
const getAggConfigs = (params: Record<string, any> = {}) => {
|
||||
|
@ -52,9 +52,9 @@ describe('Multi Terms Agg', () => {
|
|||
searchable: true,
|
||||
},
|
||||
],
|
||||
} as IndexPattern;
|
||||
} as DataView;
|
||||
|
||||
indexPattern.fields.getByName = (name) => ({ name } as unknown as IndexPatternField);
|
||||
indexPattern.fields.getByName = (name) => ({ name } as unknown as DataViewField);
|
||||
indexPattern.fields.filter = () => indexPattern.fields;
|
||||
|
||||
return new AggConfigs(
|
||||
|
@ -161,9 +161,9 @@ describe('Multi Terms Agg', () => {
|
|||
searchable: true,
|
||||
},
|
||||
],
|
||||
} as IndexPattern;
|
||||
} as DataView;
|
||||
|
||||
indexPattern.fields.getByName = (name) => ({ name } as unknown as IndexPatternField);
|
||||
indexPattern.fields.getByName = (name) => ({ name } as unknown as DataViewField);
|
||||
indexPattern.fields.filter = () => indexPattern.fields;
|
||||
|
||||
const aggConfigs = new AggConfigs(
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
import { AggConfigs } from '../agg_configs';
|
||||
import { mockAggTypesRegistry } from '../test_helpers';
|
||||
import { BUCKET_TYPES } from './bucket_agg_types';
|
||||
import type { IndexPatternField } from '../../..';
|
||||
import { IndexPattern } from '../../..';
|
||||
import type { DataViewField } from '../../..';
|
||||
import { DataView } from '../../..';
|
||||
|
||||
describe('rare terms Agg', () => {
|
||||
const getAggConfigs = (params: Record<string, any> = {}) => {
|
||||
|
@ -51,9 +51,9 @@ describe('rare terms Agg', () => {
|
|||
searchable: true,
|
||||
},
|
||||
],
|
||||
} as IndexPattern;
|
||||
} as DataView;
|
||||
|
||||
indexPattern.fields.getByName = (name) => ({ name } as unknown as IndexPatternField);
|
||||
indexPattern.fields.getByName = (name) => ({ name } as unknown as DataViewField);
|
||||
indexPattern.fields.filter = () => indexPattern.fields;
|
||||
|
||||
return new AggConfigs(
|
||||
|
|
|
@ -10,8 +10,8 @@ import { AggConfigs } from '../agg_configs';
|
|||
import { METRIC_TYPES } from '../metrics';
|
||||
import { mockAggTypesRegistry } from '../test_helpers';
|
||||
import { BUCKET_TYPES } from './bucket_agg_types';
|
||||
import type { IndexPatternField } from '../../..';
|
||||
import { IndexPattern } from '../../..';
|
||||
import type { DataViewField } from '../../..';
|
||||
import { DataView } from '../../..';
|
||||
|
||||
describe('Terms Agg', () => {
|
||||
describe('order agg editor UI', () => {
|
||||
|
@ -53,9 +53,9 @@ describe('Terms Agg', () => {
|
|||
searchable: true,
|
||||
},
|
||||
],
|
||||
} as IndexPattern;
|
||||
} as DataView;
|
||||
|
||||
indexPattern.fields.getByName = (name) => ({ name } as unknown as IndexPatternField);
|
||||
indexPattern.fields.getByName = (name) => ({ name } as unknown as DataViewField);
|
||||
indexPattern.fields.filter = () => indexPattern.fields;
|
||||
|
||||
return new AggConfigs(
|
||||
|
@ -258,9 +258,9 @@ describe('Terms Agg', () => {
|
|||
searchable: true,
|
||||
},
|
||||
],
|
||||
} as IndexPattern;
|
||||
} as DataView;
|
||||
|
||||
indexPattern.fields.getByName = (name) => ({ name } as unknown as IndexPatternField);
|
||||
indexPattern.fields.getByName = (name) => ({ name } as unknown as DataViewField);
|
||||
indexPattern.fields.filter = () => indexPattern.fields;
|
||||
|
||||
const aggConfigs = new AggConfigs(
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { SavedFieldNotFound, SavedFieldTypeInvalidForAgg } from '@kbn/kibana-utils-plugin/common';
|
||||
import { isNestedField, IndexPatternField, DataViewField } from '@kbn/data-views-plugin/common';
|
||||
import { isNestedField, DataViewField } from '@kbn/data-views-plugin/common';
|
||||
import { IAggConfig } from '../agg_config';
|
||||
import { BaseParamType } from './base';
|
||||
import { propFilter } from '../utils';
|
||||
|
@ -105,7 +105,7 @@ export class FieldParamType extends BaseParamType {
|
|||
};
|
||||
}
|
||||
|
||||
this.serialize = (field: IndexPatternField) => {
|
||||
this.serialize = (field: DataViewField) => {
|
||||
return field.name;
|
||||
};
|
||||
|
||||
|
@ -116,7 +116,7 @@ export class FieldParamType extends BaseParamType {
|
|||
const field = aggConfig.getIndexPattern().fields.getByName(fieldName);
|
||||
|
||||
if (!field) {
|
||||
return new IndexPatternField({
|
||||
return new DataViewField({
|
||||
type: KBN_FIELD_TYPES.MISSING,
|
||||
name: fieldName,
|
||||
searchable: false,
|
||||
|
@ -133,7 +133,7 @@ export class FieldParamType extends BaseParamType {
|
|||
*/
|
||||
getAvailableFields = (aggConfig: IAggConfig) => {
|
||||
const fields = aggConfig.getIndexPattern().fields;
|
||||
const filteredFields = fields.filter((field: IndexPatternField) => {
|
||||
const filteredFields = fields.filter((field: DataViewField) => {
|
||||
const { onlyAggregatable, scriptable, filterFieldTypes, filterField } = this;
|
||||
|
||||
if (filterField) {
|
||||
|
|
|
@ -18,7 +18,7 @@ jest.mock('moment', () => {
|
|||
return moment;
|
||||
});
|
||||
|
||||
import { IndexPattern, IndexPatternField } from '../../..';
|
||||
import { DataView, DataViewField } from '../../..';
|
||||
import { AggParamsDateHistogram } from '../buckets';
|
||||
import { inferTimeZone } from './infer_time_zone';
|
||||
|
||||
|
@ -27,7 +27,7 @@ describe('inferTimeZone', () => {
|
|||
const params: AggParamsDateHistogram = {
|
||||
time_zone: 'CEST',
|
||||
};
|
||||
expect(inferTimeZone(params, {} as IndexPattern, () => false, jest.fn())).toEqual('CEST');
|
||||
expect(inferTimeZone(params, {} as DataView, () => false, jest.fn())).toEqual('CEST');
|
||||
});
|
||||
|
||||
it('reads time zone from index pattern type meta if available', () => {
|
||||
|
@ -44,7 +44,7 @@ describe('inferTimeZone', () => {
|
|||
},
|
||||
},
|
||||
},
|
||||
} as unknown as IndexPattern,
|
||||
} as unknown as DataView,
|
||||
() => false,
|
||||
jest.fn()
|
||||
)
|
||||
|
@ -57,7 +57,7 @@ describe('inferTimeZone', () => {
|
|||
{
|
||||
field: {
|
||||
name: 'mydatefield',
|
||||
} as IndexPatternField,
|
||||
} as DataViewField,
|
||||
},
|
||||
{
|
||||
typeMeta: {
|
||||
|
@ -69,7 +69,7 @@ describe('inferTimeZone', () => {
|
|||
},
|
||||
},
|
||||
},
|
||||
} as unknown as IndexPattern,
|
||||
} as unknown as DataView,
|
||||
() => false,
|
||||
jest.fn()
|
||||
)
|
||||
|
@ -77,14 +77,14 @@ describe('inferTimeZone', () => {
|
|||
});
|
||||
|
||||
it('reads time zone from moment if set to default', () => {
|
||||
expect(inferTimeZone({}, {} as IndexPattern, () => true, jest.fn())).toEqual('CET');
|
||||
expect(inferTimeZone({}, {} as DataView, () => true, jest.fn())).toEqual('CET');
|
||||
});
|
||||
|
||||
it('reads time zone from config if not set to default', () => {
|
||||
expect(
|
||||
inferTimeZone(
|
||||
{},
|
||||
{} as IndexPattern,
|
||||
{} as DataView,
|
||||
() => false,
|
||||
() => 'CET' as any
|
||||
)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { Filter } from '@kbn/es-query';
|
||||
import { ExpressionValueBoxed, ExpressionValueFilter } from '@kbn/expressions-plugin/common';
|
||||
import { Query, TimeRange } from '../../query';
|
||||
import { adaptToExpressionValueFilter, IndexPatternField } from '../..';
|
||||
import { adaptToExpressionValueFilter, DataViewField } from '../..';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
||||
export type ExecutionContextSearch = {
|
||||
|
@ -24,7 +24,7 @@ export type ExpressionValueSearchContext = ExpressionValueBoxed<
|
|||
|
||||
export type KibanaQueryOutput = ExpressionValueBoxed<'kibana_query', Query>;
|
||||
export type KibanaFilter = ExpressionValueBoxed<'kibana_filter', Filter>;
|
||||
export type KibanaField = ExpressionValueBoxed<'kibana_field', IndexPatternField>;
|
||||
export type KibanaField = ExpressionValueBoxed<'kibana_field', DataViewField>;
|
||||
|
||||
// TODO: These two are exported for legacy reasons - remove them eventually.
|
||||
export type KIBANA_CONTEXT_NAME = 'kibana_context';
|
||||
|
|
|
@ -79,8 +79,8 @@ import { normalizeSortRequest } from './normalize_sort_request';
|
|||
import {
|
||||
AggConfigSerialized,
|
||||
IIndexPattern,
|
||||
IndexPattern,
|
||||
IndexPatternField,
|
||||
DataView,
|
||||
DataViewField,
|
||||
SerializedSearchSourceFields,
|
||||
} from '../..';
|
||||
import {
|
||||
|
@ -633,7 +633,7 @@ export class SearchSource {
|
|||
typeof fld === 'string' ? fld : fld.field;
|
||||
|
||||
private getFieldsWithoutSourceFilters(
|
||||
index: IndexPattern | undefined,
|
||||
index: DataView | undefined,
|
||||
bodyFields: SearchFieldValue[]
|
||||
) {
|
||||
if (!index) {
|
||||
|
@ -661,14 +661,14 @@ export class SearchSource {
|
|||
}
|
||||
// we need to get the list of fields from an index pattern
|
||||
return fields
|
||||
.filter((fld: IndexPatternField) => filterSourceFields(fld.name))
|
||||
.map((fld: IndexPatternField) => ({ field: fld.name }));
|
||||
.filter((fld: DataViewField) => filterSourceFields(fld.name))
|
||||
.map((fld: DataViewField) => ({ field: fld.name }));
|
||||
}
|
||||
|
||||
private getFieldFromDocValueFieldsOrIndexPattern(
|
||||
docvaluesIndex: Record<string, object>,
|
||||
fld: SearchFieldValue,
|
||||
index?: IndexPattern
|
||||
index?: DataView
|
||||
) {
|
||||
if (typeof fld === 'string') {
|
||||
return fld;
|
||||
|
|
|
@ -75,7 +75,7 @@ export const indexPatterns = {
|
|||
};
|
||||
|
||||
export type { IndexPatternsContract, DataViewsContract, TypeMeta } from './data_views';
|
||||
export { IndexPattern, IndexPatternField } from './data_views';
|
||||
export { IndexPattern } from './data_views';
|
||||
|
||||
export type {
|
||||
IIndexPattern,
|
||||
|
|
|
@ -47,7 +47,6 @@ export {
|
|||
|
||||
export type { IndexPatternAttributes } from '../common';
|
||||
export {
|
||||
IndexPatternField,
|
||||
ES_FIELD_TYPES,
|
||||
KBN_FIELD_TYPES,
|
||||
UI_SETTINGS,
|
||||
|
|
|
@ -7,20 +7,20 @@
|
|||
*/
|
||||
|
||||
import { extractTimeFields } from './extract_time_fields';
|
||||
import type { IndexPatternField } from '@kbn/data-plugin/public';
|
||||
import type { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
|
||||
describe('extractTimeFields', () => {
|
||||
it('should handle no date fields', () => {
|
||||
const fields = [
|
||||
{ type: 'text', name: 'name' },
|
||||
{ type: 'text', name: 'name' },
|
||||
] as IndexPatternField[];
|
||||
] as DataViewField[];
|
||||
|
||||
expect(extractTimeFields(fields)).toEqual([]);
|
||||
});
|
||||
|
||||
it('should add extra options', () => {
|
||||
const fields = [{ type: 'date', name: '@timestamp' }] as IndexPatternField[];
|
||||
const fields = [{ type: 'date', name: '@timestamp' }] as DataViewField[];
|
||||
|
||||
// const extractedFields = extractTimeFields(fields);
|
||||
expect(extractTimeFields(fields)).toEqual([
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { IndexPatternField } from '@kbn/data-plugin/public';
|
||||
import { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
import { TimestampOption } from '../types';
|
||||
|
||||
export function extractTimeFields(
|
||||
fields: IndexPatternField[],
|
||||
fields: DataViewField[],
|
||||
requireTimestampField: boolean = false
|
||||
): TimestampOption[] {
|
||||
const dateFields = fields.filter((field) => field.type === 'date');
|
||||
|
|
|
@ -14,7 +14,7 @@ import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
|
|||
import {
|
||||
createKibanaReactContext,
|
||||
toMountPoint,
|
||||
IndexPattern,
|
||||
DataView,
|
||||
DataPublicPluginStart,
|
||||
} from './shared_imports';
|
||||
|
||||
|
@ -58,7 +58,7 @@ export const getEditorOpener =
|
|||
}
|
||||
};
|
||||
|
||||
const onSaveIndexPattern = (indexPattern: IndexPattern) => {
|
||||
const onSaveIndexPattern = (indexPattern: DataView) => {
|
||||
closeEditor();
|
||||
|
||||
if (onSave) {
|
||||
|
|
|
@ -11,9 +11,8 @@ export type {
|
|||
GetFieldsOptions,
|
||||
IndexPatternAggRestrictions,
|
||||
} from '@kbn/data-plugin/public';
|
||||
export { IndexPattern, IndexPatternField } from '@kbn/data-plugin/public';
|
||||
export type { DataViewSpec } from '@kbn/data-views-plugin/public';
|
||||
export { DataView } from '@kbn/data-views-plugin/public';
|
||||
export { DataView, DataViewField } from '@kbn/data-views-plugin/public';
|
||||
|
||||
export {
|
||||
createKibanaReactContext,
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
import { map, last } from 'lodash';
|
||||
|
||||
import { IndexPattern } from './data_view';
|
||||
import { DataView } from './data_view';
|
||||
|
||||
import { CharacterNotAllowedInField } from '@kbn/kibana-utils-plugin/common';
|
||||
|
||||
import { IndexPatternField } from '../fields';
|
||||
import { DataViewField } from '../fields';
|
||||
|
||||
import { fieldFormatsMock } from '@kbn/field-formats-plugin/common/mocks';
|
||||
import { FieldFormat } from '@kbn/field-formats-plugin/common';
|
||||
|
@ -51,7 +51,7 @@ function create(id: string) {
|
|||
attributes: { timeFieldName, fields, title },
|
||||
} = stubbedSavedObjectIndexPattern(id);
|
||||
|
||||
return new IndexPattern({
|
||||
return new DataView({
|
||||
spec: {
|
||||
id,
|
||||
type,
|
||||
|
@ -68,7 +68,7 @@ function create(id: string) {
|
|||
}
|
||||
|
||||
describe('IndexPattern', () => {
|
||||
let indexPattern: IndexPattern;
|
||||
let indexPattern: DataView;
|
||||
|
||||
// create an indexPattern instance for each test
|
||||
beforeEach(() => {
|
||||
|
@ -101,8 +101,8 @@ describe('IndexPattern', () => {
|
|||
describe('getScriptedFields', () => {
|
||||
test('should return all scripted fields', () => {
|
||||
const scriptedNames = stubLogstashFields
|
||||
.filter((item: IndexPatternField) => item.scripted === true)
|
||||
.map((item: IndexPatternField) => item.name);
|
||||
.filter((item: DataViewField) => item.scripted === true)
|
||||
.map((item: DataViewField) => item.name);
|
||||
const respNames = map(indexPattern.getScriptedFields(), 'name');
|
||||
|
||||
expect(respNames).toEqual(scriptedNames);
|
||||
|
@ -151,8 +151,8 @@ describe('IndexPattern', () => {
|
|||
describe('getNonScriptedFields', () => {
|
||||
test('should return all non-scripted fields', () => {
|
||||
const notScriptedNames = stubLogstashFields
|
||||
.filter((item: IndexPatternField) => item.scripted === false)
|
||||
.map((item: IndexPatternField) => item.name);
|
||||
.filter((item: DataViewField) => item.scripted === false)
|
||||
.map((item: DataViewField) => item.name);
|
||||
notScriptedNames.push('runtime_field');
|
||||
const respNames = map(indexPattern.getNonScriptedFields(), 'name');
|
||||
|
||||
|
@ -186,7 +186,7 @@ describe('IndexPattern', () => {
|
|||
|
||||
const scriptedFields = indexPattern.getScriptedFields();
|
||||
expect(scriptedFields).toHaveLength(oldCount + 1);
|
||||
expect((indexPattern.fields.getByName(scriptedField.name) as IndexPatternField).name).toEqual(
|
||||
expect((indexPattern.fields.getByName(scriptedField.name) as DataViewField).name).toEqual(
|
||||
scriptedField.name
|
||||
);
|
||||
});
|
||||
|
@ -394,7 +394,7 @@ describe('IndexPattern', () => {
|
|||
} as unknown as FieldFormat;
|
||||
indexPattern.getFormatterForField = () => formatter;
|
||||
const spec = indexPattern.toSpec();
|
||||
const restoredPattern = new IndexPattern({
|
||||
const restoredPattern = new DataView({
|
||||
spec,
|
||||
fieldFormats: fieldFormatsMock,
|
||||
shortDotsEnable: false,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPatternField } from './data_view_field';
|
||||
import { DataViewField } from './data_view_field';
|
||||
import { IndexPattern } from '..';
|
||||
import { KBN_FIELD_TYPES } from '@kbn/field-types';
|
||||
import { FieldSpec, RuntimeField } from '../types';
|
||||
|
@ -18,7 +18,7 @@ describe('Field', function () {
|
|||
}
|
||||
|
||||
function getField(values = {}) {
|
||||
return new IndexPatternField({ ...fieldValues, ...values });
|
||||
return new DataViewField({ ...fieldValues, ...values });
|
||||
}
|
||||
|
||||
const fieldValues = {
|
||||
|
@ -146,12 +146,12 @@ describe('Field', function () {
|
|||
});
|
||||
|
||||
it('exports the property to JSON', () => {
|
||||
const field = new IndexPatternField(fieldValues);
|
||||
const field = new DataViewField(fieldValues);
|
||||
expect(flatten(field)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('spec snapshot', () => {
|
||||
const field = new IndexPatternField(fieldValues);
|
||||
const field = new DataViewField(fieldValues);
|
||||
const getFormatterForField = () =>
|
||||
({
|
||||
toJSON: () => ({
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
/* eslint-disable max-classes-per-file */
|
||||
|
||||
import { KbnFieldType, getKbnFieldType } from '@kbn/field-types';
|
||||
import { KBN_FIELD_TYPES } from '@kbn/field-types';
|
||||
import type { RuntimeFieldSpec } from '../types';
|
||||
|
@ -235,8 +233,3 @@ export class DataViewField implements IFieldType {
|
|||
return this.runtimeField?.type === 'composite';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use DataViewField instead. All index pattern interfaces were renamed.
|
||||
*/
|
||||
export class IndexPatternField extends DataViewField {}
|
||||
|
|
|
@ -17,7 +17,6 @@ export {
|
|||
isFilterable,
|
||||
fieldList,
|
||||
DataViewField,
|
||||
IndexPatternField,
|
||||
isNestedField,
|
||||
isMultiField,
|
||||
getFieldSubtypeMulti,
|
||||
|
|
|
@ -18,7 +18,6 @@ export { onRedirectNoIndexPattern } from './data_views';
|
|||
export type { IIndexPatternFieldList, TypeMeta, RuntimeType } from '../common';
|
||||
export type { DataViewSpec, FieldSpec, DataViewAttributes } from '../common';
|
||||
export {
|
||||
IndexPatternField,
|
||||
DataViewField,
|
||||
DataViewType,
|
||||
DataViewSavedObjectConflictError,
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IAggConfig, IndexPatternField } from '@kbn/data-plugin/public';
|
||||
import { IAggConfig } from '@kbn/data-plugin/public';
|
||||
import { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
|
||||
type AggTypeFieldFilter = (field: IndexPatternField, aggConfig: IAggConfig) => boolean;
|
||||
type AggTypeFieldFilter = (field: DataViewField, aggConfig: IAggConfig) => boolean;
|
||||
|
||||
const filters: AggTypeFieldFilter[] = [
|
||||
/**
|
||||
|
@ -29,7 +30,7 @@ const filters: AggTypeFieldFilter[] = [
|
|||
},
|
||||
];
|
||||
|
||||
export function filterAggTypeFields(fields: IndexPatternField[], aggConfig: IAggConfig) {
|
||||
export function filterAggTypeFields(fields: DataViewField[], aggConfig: IAggConfig) {
|
||||
const allowedAggTypeFields = fields.filter((field) => {
|
||||
const isAggTypeFieldAllowed = filters.every((filter) => filter(field, aggConfig));
|
||||
return isAggTypeFieldAllowed;
|
||||
|
|
|
@ -6,12 +6,8 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import {
|
||||
IAggConfig,
|
||||
AggParam,
|
||||
IndexPatternField,
|
||||
OptionedValueProp,
|
||||
} from '@kbn/data-plugin/public';
|
||||
import { IAggConfig, AggParam, OptionedValueProp } from '@kbn/data-plugin/public';
|
||||
import { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
import type { Schema } from '@kbn/visualizations-plugin/public';
|
||||
import { ComboBoxGroupedOptions } from '../utils';
|
||||
import { EditorConfig } from './utils';
|
||||
|
@ -27,7 +23,7 @@ export interface AggParamCommonProps<T, P = AggParam> {
|
|||
disabled?: boolean;
|
||||
editorConfig: EditorConfig;
|
||||
formIsTouched: boolean;
|
||||
indexedFields?: ComboBoxGroupedOptions<IndexPatternField>;
|
||||
indexedFields?: ComboBoxGroupedOptions<DataViewField>;
|
||||
showValidation: boolean;
|
||||
state: EditorVisState;
|
||||
value?: T;
|
||||
|
|
|
@ -8,14 +8,8 @@
|
|||
|
||||
import { get, isEmpty } from 'lodash';
|
||||
|
||||
import {
|
||||
IAggConfig,
|
||||
AggParam,
|
||||
IFieldParamType,
|
||||
IAggType,
|
||||
IndexPattern,
|
||||
IndexPatternField,
|
||||
} from '@kbn/data-plugin/public';
|
||||
import { IAggConfig, AggParam, IFieldParamType, IAggType } from '@kbn/data-plugin/public';
|
||||
import { DataView, DataViewField } from '@kbn/data-views-plugin/public';
|
||||
import type { Schema } from '@kbn/visualizations-plugin/public';
|
||||
|
||||
import { filterAggTypes, filterAggTypeFields } from '../agg_filters';
|
||||
|
@ -38,7 +32,7 @@ interface ParamInstanceBase {
|
|||
|
||||
export interface ParamInstance extends ParamInstanceBase {
|
||||
aggParam: AggParam;
|
||||
indexedFields: ComboBoxGroupedOptions<IndexPatternField>;
|
||||
indexedFields: ComboBoxGroupedOptions<DataViewField>;
|
||||
paramEditor: React.ComponentType<AggParamEditorProps<unknown>>;
|
||||
value: unknown;
|
||||
}
|
||||
|
@ -66,8 +60,8 @@ function getAggParamsToRender({
|
|||
const schema = getSchemaByName(schemas, agg.schema);
|
||||
// build collection of agg params components
|
||||
paramsToRender.forEach((param: AggParam, index: number) => {
|
||||
let indexedFields: ComboBoxGroupedOptions<IndexPatternField> = [];
|
||||
let fields: IndexPatternField[];
|
||||
let indexedFields: ComboBoxGroupedOptions<DataViewField> = [];
|
||||
let fields: DataViewField[];
|
||||
|
||||
if (hideCustomLabel && param.name === 'customLabel') {
|
||||
return;
|
||||
|
@ -77,7 +71,7 @@ function getAggParamsToRender({
|
|||
}
|
||||
// if field param exists, compute allowed fields
|
||||
if (param.type === 'field') {
|
||||
let availableFields: IndexPatternField[] = (param as IFieldParamType).getAvailableFields(agg);
|
||||
let availableFields: DataViewField[] = (param as IFieldParamType).getAvailableFields(agg);
|
||||
// should be refactored in the future to provide a more general way
|
||||
// for visualization to override some agg config settings
|
||||
if (agg.type.name === 'top_hits' && param.name === 'field') {
|
||||
|
@ -135,7 +129,7 @@ function getAggParamsToRender({
|
|||
function getAggTypeOptions(
|
||||
aggTypes: any,
|
||||
agg: IAggConfig,
|
||||
indexPattern: IndexPattern,
|
||||
indexPattern: DataView,
|
||||
groupName: string,
|
||||
allowedAggs: string[]
|
||||
): ComboBoxGroupedOptions<IAggType> {
|
||||
|
|
|
@ -11,7 +11,8 @@ import { act } from 'react-dom/test-utils';
|
|||
import { mount, shallow, ReactWrapper } from 'enzyme';
|
||||
import { EuiComboBoxProps, EuiComboBox } from '@elastic/eui';
|
||||
|
||||
import { IAggConfig, IndexPatternField, AggParam } from '@kbn/data-plugin/public';
|
||||
import { IAggConfig, AggParam } from '@kbn/data-plugin/public';
|
||||
import { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
import { ComboBoxGroupedOptions } from '../../utils';
|
||||
import { FieldParamEditor, FieldParamEditorProps } from './field';
|
||||
import { EditorVisState } from '../sidebar/state/reducers';
|
||||
|
@ -29,11 +30,11 @@ describe('FieldParamEditor component', () => {
|
|||
let setTouched: jest.Mock;
|
||||
let onChange: jest.Mock;
|
||||
let defaultProps: FieldParamEditorProps;
|
||||
let indexedFields: ComboBoxGroupedOptions<IndexPatternField>;
|
||||
let field: IndexPatternField;
|
||||
let indexedFields: ComboBoxGroupedOptions<DataViewField>;
|
||||
let field: DataViewField;
|
||||
let option: {
|
||||
label: string;
|
||||
target: IndexPatternField;
|
||||
target: DataViewField;
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -42,7 +43,7 @@ describe('FieldParamEditor component', () => {
|
|||
setTouched = jest.fn();
|
||||
onChange = jest.fn();
|
||||
|
||||
field = { displayName: 'bytes', type: 'bytes' } as IndexPatternField;
|
||||
field = { displayName: 'bytes', type: 'bytes' } as DataViewField;
|
||||
option = { label: 'bytes', target: field };
|
||||
indexedFields = [
|
||||
{
|
||||
|
|
|
@ -13,13 +13,8 @@ import useMount from 'react-use/lib/useMount';
|
|||
import { EuiComboBox, EuiComboBoxOptionOption, EuiFormRow } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import {
|
||||
AggParam,
|
||||
IAggConfig,
|
||||
IFieldParamType,
|
||||
IndexPatternField,
|
||||
KBN_FIELD_TYPES,
|
||||
} from '@kbn/data-plugin/public';
|
||||
import { AggParam, IAggConfig, IFieldParamType, KBN_FIELD_TYPES } from '@kbn/data-plugin/public';
|
||||
import { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
import { formatListAsProse, parseCommaSeparatedList, useValidation } from './utils';
|
||||
import { AggParamEditorProps } from '../agg_param_props';
|
||||
import { ComboBoxGroupedOptions } from '../../utils';
|
||||
|
@ -28,7 +23,7 @@ const label = i18n.translate('visDefaultEditor.controls.field.fieldLabel', {
|
|||
defaultMessage: 'Field',
|
||||
});
|
||||
|
||||
export interface FieldParamEditorProps extends AggParamEditorProps<IndexPatternField> {
|
||||
export interface FieldParamEditorProps extends AggParamEditorProps<DataViewField> {
|
||||
customError?: string;
|
||||
customLabel?: string;
|
||||
}
|
||||
|
@ -46,12 +41,12 @@ function FieldParamEditor({
|
|||
setValue,
|
||||
}: FieldParamEditorProps) {
|
||||
const [isDirty, setIsDirty] = useState(false);
|
||||
const selectedOptions: ComboBoxGroupedOptions<IndexPatternField> = value
|
||||
const selectedOptions: ComboBoxGroupedOptions<DataViewField> = value
|
||||
? [{ label: value.displayName, target: value, key: value.name }]
|
||||
: [];
|
||||
|
||||
const onChange = (options: EuiComboBoxOptionOption[]) => {
|
||||
const selectedOption: IndexPatternField = get(options, '0.target');
|
||||
const selectedOption: DataViewField = get(options, '0.target');
|
||||
if (!(aggParam.required && !selectedOption)) {
|
||||
setValue(selectedOption);
|
||||
}
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
import React from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { IndexPatternField } from '@kbn/data-plugin/public';
|
||||
import { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
import { FieldParamEditor } from './field';
|
||||
import { getCompatibleAggs } from './top_aggregate';
|
||||
import { AggParamEditorProps } from '../agg_param_props';
|
||||
|
||||
function TopFieldParamEditor(props: AggParamEditorProps<IndexPatternField>) {
|
||||
function TopFieldParamEditor(props: AggParamEditorProps<DataViewField>) {
|
||||
const compatibleAggs = getCompatibleAggs(props.agg);
|
||||
let customError;
|
||||
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
import React from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { IndexPatternField } from '@kbn/data-plugin/public';
|
||||
import { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
import { FieldParamEditor } from './field';
|
||||
import { AggParamEditorProps } from '../agg_param_props';
|
||||
|
||||
function TopSortFieldParamEditor(props: AggParamEditorProps<IndexPatternField>) {
|
||||
function TopSortFieldParamEditor(props: AggParamEditorProps<DataViewField>) {
|
||||
const customLabel = i18n.translate('visDefaultEditor.controls.sortOnLabel', {
|
||||
defaultMessage: 'Sort on',
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import type { IndexPatternField } from '@kbn/data-plugin/public';
|
||||
import type { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
import { indexPatterns } from '@kbn/data-plugin/public';
|
||||
import type {
|
||||
AggregationsExtendedStatsAggregation,
|
||||
|
@ -52,7 +52,7 @@ export class ESDocField extends AbstractField implements IField {
|
|||
return this._source;
|
||||
}
|
||||
|
||||
async _getIndexPatternField(): Promise<IndexPatternField | undefined> {
|
||||
async _getIndexPatternField(): Promise<DataViewField | undefined> {
|
||||
const indexPattern = await this._source.getIndexPattern();
|
||||
const indexPatternField = indexPattern.fields.getByName(this.getName());
|
||||
return indexPatternField && indexPatterns.isNestedField(indexPatternField)
|
||||
|
|
|
@ -10,7 +10,8 @@ import React, { Fragment, Component } from 'react';
|
|||
import uuid from 'uuid/v4';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { EuiPanel, EuiSpacer, EuiComboBoxOptionOption, EuiTitle } from '@elastic/eui';
|
||||
import { IndexPatternField, indexPatterns } from '@kbn/data-plugin/public';
|
||||
import { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
import { indexPatterns } from '@kbn/data-plugin/public';
|
||||
import { getDataViewNotFoundMessage } from '../../../../common/i18n_getters';
|
||||
import {
|
||||
AGG_TYPE,
|
||||
|
@ -42,7 +43,7 @@ interface Props {
|
|||
interface State {
|
||||
geoFieldType?: ES_GEO_FIELD_TYPE;
|
||||
metricsEditorKey: string;
|
||||
fields: IndexPatternField[];
|
||||
fields: DataViewField[];
|
||||
loadError?: string;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import React, { ChangeEvent, Component, Fragment } from 'react';
|
||||
import { EuiFormRow, EuiSelect } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import type { IndexPatternField } from '@kbn/data-plugin/public';
|
||||
import { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
import { SortDirection } from '@kbn/data-plugin/public';
|
||||
import { SingleFieldSelect } from '../../../../components/single_field_select';
|
||||
import { getIndexPatternService } from '../../../../kibana_services';
|
||||
|
@ -23,9 +23,9 @@ interface Props {
|
|||
isColumnCompressed?: boolean;
|
||||
onChange: (args: OnSourceChangeArgs) => void;
|
||||
sortField: string;
|
||||
sortFields: IndexPatternField[];
|
||||
sortFields: DataViewField[];
|
||||
sortOrder: SortDirection;
|
||||
termFields: IndexPatternField[];
|
||||
termFields: DataViewField[];
|
||||
topHitsSplitField: string | null;
|
||||
topHitsSize: number;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import React, { Component, Fragment } from 'react';
|
|||
import { EuiFormRow, EuiTitle, EuiPanel, EuiSpacer, EuiSwitch, EuiSwitchEvent } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import type { IndexPatternField } from '@kbn/data-plugin/public';
|
||||
import { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
import { SortDirection } from '@kbn/data-plugin/public';
|
||||
import { getDataViewNotFoundMessage } from '../../../../../common/i18n_getters';
|
||||
import { FIELD_ORIGIN } from '../../../../../common/constants';
|
||||
|
@ -38,8 +38,8 @@ interface Props {
|
|||
interface State {
|
||||
loadError?: string;
|
||||
sourceFields: IField[];
|
||||
termFields: IndexPatternField[];
|
||||
sortFields: IndexPatternField[];
|
||||
termFields: DataViewField[];
|
||||
sortFields: DataViewField[];
|
||||
}
|
||||
|
||||
export class TopHitsUpdateSourceEditor extends Component<Props, State> {
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
*/
|
||||
|
||||
import { getDocValueAndSourceFields } from './get_docvalue_source_fields';
|
||||
import type { IndexPatternField, IndexPattern } from '@kbn/data-plugin/public';
|
||||
import type { DataViewField, DataView } from '@kbn/data-views-plugin/public';
|
||||
|
||||
function createMockIndexPattern(fields: IndexPatternField[]): IndexPattern {
|
||||
function createMockIndexPattern(fields: DataViewField[]): DataView {
|
||||
const indexPattern = {
|
||||
get fields() {
|
||||
return {
|
||||
|
@ -19,7 +19,7 @@ function createMockIndexPattern(fields: IndexPatternField[]): IndexPattern {
|
|||
},
|
||||
};
|
||||
|
||||
return indexPattern as unknown as IndexPattern;
|
||||
return indexPattern as unknown as DataView;
|
||||
}
|
||||
|
||||
describe('getDocValueAndSourceFields', () => {
|
||||
|
@ -29,7 +29,7 @@ describe('getDocValueAndSourceFields', () => {
|
|||
{
|
||||
name: 'foobar',
|
||||
runtimeField: { type: 'keyword' },
|
||||
} as IndexPatternField,
|
||||
} as DataViewField,
|
||||
]),
|
||||
['foobar'],
|
||||
'epoch_millis'
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import type { IndexPatternField, IndexPattern } from '@kbn/data-plugin/public';
|
||||
import type { DataViewField, DataView } from '@kbn/data-views-plugin/public';
|
||||
import { ESTooltipProperty } from './es_tooltip_property';
|
||||
import { TooltipProperty } from './tooltip_property';
|
||||
import { AbstractField } from '../fields/field';
|
||||
|
@ -25,7 +25,7 @@ const indexPatternField = {
|
|||
searchable: true,
|
||||
aggregatable: true,
|
||||
readFromDocValues: false,
|
||||
} as IndexPatternField;
|
||||
} as DataViewField;
|
||||
|
||||
const featurePropertyField = new MockField({
|
||||
fieldName: 'machine.os',
|
||||
|
@ -41,7 +41,7 @@ const nonFilterableIndexPatternField = {
|
|||
searchable: true,
|
||||
aggregatable: true,
|
||||
readFromDocValues: false,
|
||||
} as IndexPatternField;
|
||||
} as DataViewField;
|
||||
|
||||
const nonFilterableFeaturePropertyField = new MockField({
|
||||
fieldName: 'location',
|
||||
|
@ -51,7 +51,7 @@ const nonFilterableFeaturePropertyField = new MockField({
|
|||
const indexPattern = {
|
||||
id: 'indexPatternId',
|
||||
fields: {
|
||||
getByName: (name: string): IndexPatternField | null => {
|
||||
getByName: (name: string): DataViewField | null => {
|
||||
if (name === 'machine.os') {
|
||||
return indexPatternField;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ const indexPattern = {
|
|||
},
|
||||
},
|
||||
title: 'my index pattern',
|
||||
} as IndexPattern;
|
||||
} as DataView;
|
||||
|
||||
describe('getESFilters', () => {
|
||||
test('Should return empty array when field does not exist in index pattern', async () => {
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
import React from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { EuiFormRow } from '@elastic/eui';
|
||||
import type { IndexPatternField } from '@kbn/data-plugin/public';
|
||||
import { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
import { SingleFieldSelect } from './single_field_select';
|
||||
|
||||
interface Props {
|
||||
value: string;
|
||||
geoFields: IndexPatternField[];
|
||||
geoFields: DataViewField[];
|
||||
onChange: (geoFieldName?: string) => void;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n';
|
|||
import { EuiButtonEmpty, EuiComboBoxOptionOption, EuiFieldText, EuiFormRow } from '@elastic/eui';
|
||||
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import type { IndexPatternField } from '@kbn/data-plugin/public';
|
||||
import { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
import { MetricSelect } from './metric_select';
|
||||
import { SingleFieldSelect } from '../single_field_select';
|
||||
import { AggDescriptor } from '../../../common/descriptor_types';
|
||||
|
@ -19,7 +19,7 @@ import { AGG_TYPE, DEFAULT_PERCENTILE } from '../../../common/constants';
|
|||
import { getTermsFields } from '../../index_pattern_util';
|
||||
import { ValidatedNumberInput } from '../validated_number_input';
|
||||
|
||||
function filterFieldsForAgg(fields: IndexPatternField[], aggType: AGG_TYPE) {
|
||||
function filterFieldsForAgg(fields: DataViewField[], aggType: AGG_TYPE) {
|
||||
if (!fields) {
|
||||
return [];
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ function filterFieldsForAgg(fields: IndexPatternField[], aggType: AGG_TYPE) {
|
|||
|
||||
interface Props {
|
||||
metric: AggDescriptor;
|
||||
fields: IndexPatternField[];
|
||||
fields: DataViewField[];
|
||||
onChange: (metric: AggDescriptor) => void;
|
||||
onRemove: () => void;
|
||||
metricsFilter?: (metricOption: EuiComboBoxOptionOption<AGG_TYPE>) => boolean;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import React, { Component, Fragment } from 'react';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { EuiButtonEmpty, EuiComboBoxOptionOption, EuiSpacer, EuiTextAlign } from '@elastic/eui';
|
||||
import type { IndexPatternField } from '@kbn/data-plugin/public';
|
||||
import { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
import { MetricEditor } from './metric_editor';
|
||||
import { DEFAULT_METRIC } from '../../classes/sources/es_agg_source';
|
||||
import { AggDescriptor, FieldedAggDescriptor } from '../../../common/descriptor_types';
|
||||
|
@ -23,7 +23,7 @@ export function isMetricValid(aggDescriptor: AggDescriptor) {
|
|||
interface Props {
|
||||
allowMultipleMetrics: boolean;
|
||||
metrics: AggDescriptor[];
|
||||
fields: IndexPatternField[];
|
||||
fields: DataViewField[];
|
||||
onChange: (metrics: AggDescriptor[]) => void;
|
||||
metricsFilter?: (metricOption: EuiComboBoxOptionOption<AGG_TYPE>) => boolean;
|
||||
}
|
||||
|
|
|
@ -18,19 +18,19 @@ import {
|
|||
EuiToolTip,
|
||||
} from '@elastic/eui';
|
||||
import { FieldIcon } from '@kbn/react-field';
|
||||
import { IndexPatternField } from '@kbn/data-plugin/public';
|
||||
import { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
|
||||
function fieldsToOptions(
|
||||
fields?: IndexPatternField[],
|
||||
isFieldDisabled?: (field: IndexPatternField) => boolean
|
||||
): Array<EuiComboBoxOptionOption<IndexPatternField>> {
|
||||
fields?: DataViewField[],
|
||||
isFieldDisabled?: (field: DataViewField) => boolean
|
||||
): Array<EuiComboBoxOptionOption<DataViewField>> {
|
||||
if (!fields) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return fields
|
||||
.map((field) => {
|
||||
const option: EuiComboBoxOptionOption<IndexPatternField> = {
|
||||
const option: EuiComboBoxOptionOption<DataViewField> = {
|
||||
value: field,
|
||||
label: field.displayName ? field.displayName : field.name,
|
||||
};
|
||||
|
@ -45,14 +45,14 @@ function fieldsToOptions(
|
|||
}
|
||||
|
||||
type Props = Omit<
|
||||
EuiComboBoxProps<IndexPatternField>,
|
||||
EuiComboBoxProps<DataViewField>,
|
||||
'isDisabled' | 'onChange' | 'options' | 'renderOption' | 'selectedOptions' | 'singleSelection'
|
||||
> & {
|
||||
fields?: IndexPatternField[];
|
||||
fields?: DataViewField[];
|
||||
onChange: (fieldName?: string) => void;
|
||||
value: string | null; // index pattern field name
|
||||
isFieldDisabled?: (field: IndexPatternField) => boolean;
|
||||
getFieldDisabledReason?: (field: IndexPatternField) => string | null;
|
||||
isFieldDisabled?: (field: DataViewField) => boolean;
|
||||
getFieldDisabledReason?: (field: DataViewField) => string | null;
|
||||
};
|
||||
|
||||
export function SingleFieldSelect({
|
||||
|
@ -64,7 +64,7 @@ export function SingleFieldSelect({
|
|||
...rest
|
||||
}: Props) {
|
||||
function renderOption(
|
||||
option: EuiComboBoxOptionOption<IndexPatternField>,
|
||||
option: EuiComboBoxOptionOption<DataViewField>,
|
||||
searchValue: string,
|
||||
contentClassName: string
|
||||
) {
|
||||
|
@ -91,13 +91,13 @@ export function SingleFieldSelect({
|
|||
);
|
||||
}
|
||||
|
||||
const onSelection = (selectedOptions: Array<EuiComboBoxOptionOption<IndexPatternField>>) => {
|
||||
const onSelection = (selectedOptions: Array<EuiComboBoxOptionOption<DataViewField>>) => {
|
||||
onChange(_.get(selectedOptions, '0.value.name'));
|
||||
};
|
||||
|
||||
const selectedOptions: Array<EuiComboBoxOptionOption<IndexPatternField>> = [];
|
||||
const selectedOptions: Array<EuiComboBoxOptionOption<DataViewField>> = [];
|
||||
if (value && fields) {
|
||||
const selectedField = fields.find((field: IndexPatternField) => {
|
||||
const selectedField = fields.find((field: DataViewField) => {
|
||||
return field.name === value;
|
||||
});
|
||||
if (selectedField) {
|
||||
|
|
|
@ -18,7 +18,7 @@ import {
|
|||
} from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { IndexPatternField } from '@kbn/data-plugin/public';
|
||||
import { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { getDataViewSelectPlaceholder } from '../../../../../common/i18n_getters';
|
||||
import { DEFAULT_MAX_BUCKETS_LIMIT } from '../../../../../common/constants';
|
||||
|
@ -55,7 +55,7 @@ interface Props {
|
|||
// Right field props
|
||||
rightValue: string;
|
||||
rightSize?: number;
|
||||
rightFields: IndexPatternField[];
|
||||
rightFields: DataViewField[];
|
||||
onRightFieldChange: (term?: string) => void;
|
||||
onRightSizeChange: (size: number) => void;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
EuiFormHelpText,
|
||||
} from '@elastic/eui';
|
||||
|
||||
import { IndexPatternField } from '@kbn/data-plugin/public';
|
||||
import { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { MetricsEditor } from '../../../../components/metrics_editor';
|
||||
import { AGG_TYPE } from '../../../../../common/constants';
|
||||
|
@ -23,7 +23,7 @@ import { AggDescriptor, FieldedAggDescriptor } from '../../../../../common/descr
|
|||
|
||||
interface Props {
|
||||
metrics: AggDescriptor[];
|
||||
rightFields: IndexPatternField[];
|
||||
rightFields: DataViewField[];
|
||||
onChange: (metrics: AggDescriptor[]) => void;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,18 +14,18 @@ import {
|
|||
supportsGeoTileAgg,
|
||||
} from './index_pattern_util';
|
||||
import { ES_GEO_FIELD_TYPE } from '../common/constants';
|
||||
import { IndexPatternField } from '@kbn/data-plugin/public';
|
||||
import { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
|
||||
describe('getSourceFields', () => {
|
||||
test('Should remove multi fields from field list', () => {
|
||||
const agent = new IndexPatternField({
|
||||
const agent = new DataViewField({
|
||||
name: 'agent',
|
||||
searchable: true,
|
||||
aggregatable: true,
|
||||
type: 'string',
|
||||
});
|
||||
|
||||
const agentKeyword = new IndexPatternField({
|
||||
const agentKeyword = new DataViewField({
|
||||
name: 'agent.keyword',
|
||||
subType: {
|
||||
multi: {
|
||||
|
@ -52,7 +52,7 @@ describe('Gold+ licensing', () => {
|
|||
name: 'location',
|
||||
type: 'geo_point',
|
||||
aggregatable: true,
|
||||
} as IndexPatternField,
|
||||
} as DataViewField,
|
||||
supportedInBasic: true,
|
||||
supportedInGold: true,
|
||||
},
|
||||
|
@ -61,7 +61,7 @@ describe('Gold+ licensing', () => {
|
|||
name: 'location',
|
||||
type: 'geo_shape',
|
||||
aggregatable: false,
|
||||
} as IndexPatternField,
|
||||
} as DataViewField,
|
||||
supportedInBasic: false,
|
||||
supportedInGold: false,
|
||||
},
|
||||
|
@ -70,7 +70,7 @@ describe('Gold+ licensing', () => {
|
|||
name: 'location',
|
||||
type: 'geo_shape',
|
||||
aggregatable: true,
|
||||
} as IndexPatternField,
|
||||
} as DataViewField,
|
||||
supportedInBasic: false,
|
||||
supportedInGold: true,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue