From d65743cc3c1b1ba1b08120ecc9310deb64878509 Mon Sep 17 00:00:00 2001 From: Matthew Kime <matt@mattki.me> Date: Tue, 13 Jul 2021 12:57:14 -0500 Subject: [PATCH] Revert "Rollup index pattern list fixes (#105328)" (#105456) This reverts commit 6933d630078b2310ebfa73365543f6fb7c347229. --- ...in-plugins-data-public.indexpatterntype.md | 19 --- ...lugins-data-public.indexpatterntypemeta.md | 1 - ...data-public.indexpatterntypemeta.params.md | 13 -- .../kibana-plugin-plugins-data-public.md | 1 - .../data/common/index_patterns/types.ts | 10 +- src/plugins/data/public/index.ts | 1 - src/plugins/data/public/public.api.md | 44 ++--- .../indexed_fields_table.test.tsx.snap | 155 ------------------ .../components/table/table.test.tsx | 4 +- .../indexed_fields_table.test.tsx | 55 +------ .../indexed_fields_table.tsx | 4 +- .../public/service/list/config.ts | 14 +- .../public/service/list/manager.ts | 13 +- ...p_list_config.ts => rollup_list_config.js} | 22 +-- 14 files changed, 53 insertions(+), 303 deletions(-) delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatterntype.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatterntypemeta.params.md rename src/plugins/index_pattern_management/public/service/list/{rollup_list_config.ts => rollup_list_config.js} (69%) diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatterntype.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatterntype.md deleted file mode 100644 index 46fd3a0725e40..0000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatterntype.md +++ /dev/null @@ -1,19 +0,0 @@ -<!-- Do not edit this file. It is automatically generated by API Documenter. --> - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternType](./kibana-plugin-plugins-data-public.indexpatterntype.md) - -## IndexPatternType enum - -<b>Signature:</b> - -```typescript -export declare enum IndexPatternType -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| DEFAULT | <code>"default"</code> | | -| ROLLUP | <code>"rollup"</code> | | - diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatterntypemeta.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatterntypemeta.md index 19a884862d460..e6690b244c9ea 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatterntypemeta.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatterntypemeta.md @@ -15,5 +15,4 @@ export interface TypeMeta | Property | Type | Description | | --- | --- | --- | | [aggs](./kibana-plugin-plugins-data-public.indexpatterntypemeta.aggs.md) | <code>Record<string, AggregationRestrictions></code> | | -| [params](./kibana-plugin-plugins-data-public.indexpatterntypemeta.params.md) | <code>{</code><br/><code> rollup_index: string;</code><br/><code> }</code> | | diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatterntypemeta.params.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatterntypemeta.params.md deleted file mode 100644 index 12646a39188a0..0000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatterntypemeta.params.md +++ /dev/null @@ -1,13 +0,0 @@ -<!-- Do not edit this file. It is automatically generated by API Documenter. --> - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternTypeMeta](./kibana-plugin-plugins-data-public.indexpatterntypemeta.md) > [params](./kibana-plugin-plugins-data-public.indexpatterntypemeta.params.md) - -## IndexPatternTypeMeta.params property - -<b>Signature:</b> - -```typescript -params?: { - rollup_index: string; - }; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md index 7c2911875ee05..65c4601d5faec 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md @@ -31,7 +31,6 @@ | --- | --- | | [BUCKET\_TYPES](./kibana-plugin-plugins-data-public.bucket_types.md) | | | [ES\_FIELD\_TYPES](./kibana-plugin-plugins-data-public.es_field_types.md) | \* | -| [IndexPatternType](./kibana-plugin-plugins-data-public.indexpatterntype.md) | | | [KBN\_FIELD\_TYPES](./kibana-plugin-plugins-data-public.kbn_field_types.md) | \* | | [METRIC\_TYPES](./kibana-plugin-plugins-data-public.metric_types.md) | | | [QuerySuggestionTypes](./kibana-plugin-plugins-data-public.querysuggestiontypes.md) | | diff --git a/src/plugins/data/common/index_patterns/types.ts b/src/plugins/data/common/index_patterns/types.ts index 58cc6d0478d5e..b03e745df74a6 100644 --- a/src/plugins/data/common/index_patterns/types.ts +++ b/src/plugins/data/common/index_patterns/types.ts @@ -150,17 +150,9 @@ export type AggregationRestrictions = Record< time_zone?: string; } >; - export interface TypeMeta { aggs?: Record<string, AggregationRestrictions>; - params?: { - rollup_index: string; - }; -} - -export enum IndexPatternType { - DEFAULT = 'default', - ROLLUP = 'rollup', + [key: string]: any; } export type FieldSpecConflictDescriptions = Record<string, string[]>; diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts index 9af1cbf95d94d..e9e50ebfaf138 100644 --- a/src/plugins/data/public/index.ts +++ b/src/plugins/data/public/index.ts @@ -269,7 +269,6 @@ export { IndexPatternLoadExpressionFunctionDefinition, fieldList, INDEX_PATTERN_SAVED_OBJECT_TYPE, - IndexPatternType, } from '../common'; export { DuplicateIndexPatternError } from '../common/index_patterns/errors'; diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index 6c0ddd000f30a..b8af7c12d57fc 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -1688,26 +1688,14 @@ export class IndexPatternsService { updateSavedObject(indexPattern: IndexPattern, saveAttempts?: number, ignoreErrors?: boolean): Promise<void | Error>; } -// Warning: (ae-missing-release-tag) "IndexPatternType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export enum IndexPatternType { - // (undocumented) - DEFAULT = "default", - // (undocumented) - ROLLUP = "rollup" -} - // Warning: (ae-missing-release-tag) "TypeMeta" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) export interface IndexPatternTypeMeta { // (undocumented) - aggs?: Record<string, IndexPatternAggRestrictions>; + [key: string]: any; // (undocumented) - params?: { - rollup_index: string; - }; + aggs?: Record<string, IndexPatternAggRestrictions>; } // Warning: (ae-missing-release-tag) "injectReferences" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -2778,20 +2766,20 @@ export interface WaitUntilNextSessionCompletesOptions { // src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "validateIndexPattern" needs to be exported by the entry point index.d.ts // src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts // src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:410:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:410:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:410:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:412:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:413:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:422:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:423:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:424:1 - (ae-forgotten-export) The symbol "IpAddress" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:425:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:429:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:430:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:433:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:434:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:437:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:409:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:409:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:409:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:411:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:412:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:421:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:422:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:423:1 - (ae-forgotten-export) The symbol "IpAddress" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:424:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:428:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:429:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:432:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:433:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:436:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts // src/plugins/data/public/query/state_sync/connect_to_query_state.ts:34:5 - (ae-forgotten-export) The symbol "FilterStateStore" needs to be exported by the entry point index.d.ts // src/plugins/data/public/search/session/session_service.ts:62:5 - (ae-forgotten-export) The symbol "UrlGeneratorStateMapping" needs to be exported by the entry point index.d.ts diff --git a/src/plugins/index_pattern_management/public/components/edit_index_pattern/indexed_fields_table/__snapshots__/indexed_fields_table.test.tsx.snap b/src/plugins/index_pattern_management/public/components/edit_index_pattern/indexed_fields_table/__snapshots__/indexed_fields_table.test.tsx.snap index 776294a93df18..32a2b936edd00 100644 --- a/src/plugins/index_pattern_management/public/components/edit_index_pattern/indexed_fields_table/__snapshots__/indexed_fields_table.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/edit_index_pattern/indexed_fields_table/__snapshots__/indexed_fields_table.test.tsx.snap @@ -1,146 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`IndexedFieldsTable IndexedFieldsTable with rollup index pattern should render normally 1`] = ` -<div> - <Table - deleteField={[Function]} - editField={[Function]} - indexPattern={ - Object { - "getFormatterForFieldNoDefault": [Function], - "getNonScriptedFields": [Function], - "type": "rollup", - "typeMeta": Object { - "aggs": Object { - "avg": Object { - "amount": Object { - "agg": "avg", - }, - }, - "date_histogram": Object { - "timestamp": Object { - "agg": "date_histogram", - "delay": "30s", - "fixed_interval": "30s", - "time_zone": "UTC", - }, - }, - "histogram": Object { - "amount": Object { - "agg": "histogram", - "interval": 5, - }, - }, - "max": Object { - "amount": Object { - "agg": "max", - }, - }, - "min": Object { - "amount": Object { - "agg": "min", - }, - }, - "sum": Object { - "amount": Object { - "agg": "sum", - }, - }, - "terms": Object { - "Elastic": Object { - "agg": "terms", - }, - }, - "value_count": Object { - "amount": Object { - "agg": "value_count", - }, - }, - }, - "rollup-index": "rollup", - }, - } - } - items={ - Array [ - Object { - "displayName": "Elastic", - "esTypes": Array [ - "keyword", - ], - "excluded": false, - "format": "", - "hasRuntime": false, - "info": Array [ - "Rollup aggregations:", - "terms", - ], - "isMapped": false, - "kbnType": undefined, - "name": "Elastic", - "searchable": true, - "type": "keyword", - }, - Object { - "displayName": "timestamp", - "esTypes": Array [ - "date", - ], - "excluded": false, - "format": "", - "hasRuntime": false, - "info": Array [ - "Rollup aggregations:", - "date_histogram (interval: 30s, delay: 30s, UTC)", - ], - "isMapped": false, - "kbnType": undefined, - "name": "timestamp", - "type": "date", - }, - Object { - "displayName": "conflictingField", - "esTypes": Array [ - "keyword", - "long", - ], - "excluded": false, - "format": "", - "hasRuntime": false, - "info": Array [], - "isMapped": false, - "kbnType": undefined, - "name": "conflictingField", - "type": "keyword, long", - }, - Object { - "displayName": "amount", - "esTypes": Array [ - "long", - ], - "excluded": false, - "format": "", - "hasRuntime": false, - "info": Array [ - "Rollup aggregations:", - "histogram (interval: 5)", - "avg", - "max", - "min", - "sum", - "value_count", - ], - "isMapped": false, - "kbnType": undefined, - "name": "amount", - "type": "long", - }, - ] - } - /> -</div> -`; - exports[`IndexedFieldsTable should filter based on the query bar 1`] = ` <div> <Table @@ -265,20 +124,6 @@ exports[`IndexedFieldsTable should render normally 1`] = ` "name": "conflictingField", "type": "keyword, long", }, - Object { - "displayName": "amount", - "esTypes": Array [ - "long", - ], - "excluded": false, - "format": "", - "hasRuntime": false, - "info": Array [], - "isMapped": false, - "kbnType": undefined, - "name": "amount", - "type": "long", - }, ] } /> diff --git a/src/plugins/index_pattern_management/public/components/edit_index_pattern/indexed_fields_table/components/table/table.test.tsx b/src/plugins/index_pattern_management/public/components/edit_index_pattern/indexed_fields_table/components/table/table.test.tsx index 163152b52e80b..b9957534d8c69 100644 --- a/src/plugins/index_pattern_management/public/components/edit_index_pattern/indexed_fields_table/components/table/table.test.tsx +++ b/src/plugins/index_pattern_management/public/components/edit_index_pattern/indexed_fields_table/components/table/table.test.tsx @@ -8,13 +8,13 @@ import React from 'react'; import { shallow } from 'enzyme'; -import { IndexPattern } from 'src/plugins/data/public'; +import { IIndexPattern } from 'src/plugins/data/public'; import { IndexedFieldItem } from '../../types'; import { Table, renderFieldName } from './table'; const indexPattern = { timeFieldName: 'timestamp', -} as IndexPattern; +} as IIndexPattern; const items: IndexedFieldItem[] = [ { diff --git a/src/plugins/index_pattern_management/public/components/edit_index_pattern/indexed_fields_table/indexed_fields_table.test.tsx b/src/plugins/index_pattern_management/public/components/edit_index_pattern/indexed_fields_table/indexed_fields_table.test.tsx index c819b1d3a33fd..e587ada6695cb 100644 --- a/src/plugins/index_pattern_management/public/components/edit_index_pattern/indexed_fields_table/indexed_fields_table.test.tsx +++ b/src/plugins/index_pattern_management/public/components/edit_index_pattern/indexed_fields_table/indexed_fields_table.test.tsx @@ -8,9 +8,8 @@ import React from 'react'; import { shallow } from 'enzyme'; -import { IndexPatternField, IndexPattern, IndexPatternType } from 'src/plugins/data/public'; +import { IndexPatternField, IndexPattern } from 'src/plugins/data/public'; import { IndexedFieldsTable } from './indexed_fields_table'; -import { RollupIndexPatternListConfig } from '../../../service/list'; jest.mock('@elastic/eui', () => ({ EuiFlexGroup: 'eui-flex-group', @@ -29,8 +28,7 @@ jest.mock('./components/table', () => ({ const helpers = { editField: (fieldName: string) => {}, deleteField: (fieldName: string) => {}, - // getFieldInfo handles non rollups as well - getFieldInfo: new RollupIndexPatternListConfig().getFieldInfo, + getFieldInfo: () => [], }; const indexPattern = ({ @@ -38,32 +36,6 @@ const indexPattern = ({ getFormatterForFieldNoDefault: () => ({ params: () => ({}) }), } as unknown) as IndexPattern; -const rollupIndexPattern = ({ - type: IndexPatternType.ROLLUP, - typeMeta: { - 'rollup-index': 'rollup', - aggs: { - date_histogram: { - timestamp: { - agg: 'date_histogram', - fixed_interval: '30s', - delay: '30s', - time_zone: 'UTC', - }, - }, - terms: { Elastic: { agg: 'terms' } }, - histogram: { amount: { agg: 'histogram', interval: 5 } }, - avg: { amount: { agg: 'avg' } }, - max: { amount: { agg: 'max' } }, - min: { amount: { agg: 'min' } }, - sum: { amount: { agg: 'sum' } }, - value_count: { amount: { agg: 'value_count' } }, - }, - }, - getNonScriptedFields: () => fields, - getFormatterForFieldNoDefault: () => ({ params: () => ({}) }), -} as unknown) as IndexPattern; - const mockFieldToIndexPatternField = ( spec: Record<string, string | string[] | boolean | undefined> ) => { @@ -79,7 +51,6 @@ const fields = [ }, { name: 'timestamp', displayName: 'timestamp', esTypes: ['date'] }, { name: 'conflictingField', displayName: 'conflictingField', esTypes: ['keyword', 'long'] }, - { name: 'amount', displayName: 'amount', esTypes: ['long'] }, ].map(mockFieldToIndexPatternField); describe('IndexedFieldsTable', () => { @@ -144,26 +115,4 @@ describe('IndexedFieldsTable', () => { expect(component).toMatchSnapshot(); }); - - describe('IndexedFieldsTable with rollup index pattern', () => { - test('should render normally', async () => { - const component = shallow( - <IndexedFieldsTable - fields={fields} - indexPattern={rollupIndexPattern} - helpers={helpers} - fieldWildcardMatcher={() => { - return () => false; - }} - indexedFieldTypeFilter="" - fieldFilter="" - /> - ); - - await new Promise((resolve) => process.nextTick(resolve)); - component.update(); - - expect(component).toMatchSnapshot(); - }); - }); }); diff --git a/src/plugins/index_pattern_management/public/components/edit_index_pattern/indexed_fields_table/indexed_fields_table.tsx b/src/plugins/index_pattern_management/public/components/edit_index_pattern/indexed_fields_table/indexed_fields_table.tsx index 4e9aeb1874c89..ee1147997079f 100644 --- a/src/plugins/index_pattern_management/public/components/edit_index_pattern/indexed_fields_table/indexed_fields_table.tsx +++ b/src/plugins/index_pattern_management/public/components/edit_index_pattern/indexed_fields_table/indexed_fields_table.tsx @@ -8,7 +8,7 @@ import React, { Component } from 'react'; import { createSelector } from 'reselect'; -import { IndexPatternField, IndexPattern } from '../../../../../../plugins/data/public'; +import { IndexPatternField, IndexPattern, IFieldType } from '../../../../../../plugins/data/public'; import { Table } from './components/table'; import { IndexedFieldItem } from './types'; @@ -20,7 +20,7 @@ interface IndexedFieldsTableProps { helpers: { editField: (fieldName: string) => void; deleteField: (fieldName: string) => void; - getFieldInfo: (indexPattern: IndexPattern, field: IndexPatternField) => string[]; + getFieldInfo: (indexPattern: IndexPattern, field: IFieldType) => string[]; }; fieldWildcardMatcher: (filters: any[]) => (val: any) => boolean; } diff --git a/src/plugins/index_pattern_management/public/service/list/config.ts b/src/plugins/index_pattern_management/public/service/list/config.ts index 4be27fc47d0db..e13f8c1c06241 100644 --- a/src/plugins/index_pattern_management/public/service/list/config.ts +++ b/src/plugins/index_pattern_management/public/service/list/config.ts @@ -7,7 +7,8 @@ */ import { i18n } from '@kbn/i18n'; -import { IndexPattern, IndexPatternField, IndexPatternType } from '../../../../data/public'; +import { IIndexPattern, IFieldType } from 'src/plugins/data/public'; +import { SimpleSavedObject } from 'src/core/public'; export interface IndexPatternTag { key: string; @@ -22,9 +23,12 @@ const defaultIndexPatternListName = i18n.translate( ); export class IndexPatternListConfig { - public readonly key: IndexPatternType = IndexPatternType.DEFAULT; + public readonly key = 'default'; - public getIndexPatternTags(indexPattern: IndexPattern, isDefault: boolean): IndexPatternTag[] { + public getIndexPatternTags( + indexPattern: IIndexPattern | SimpleSavedObject<IIndexPattern>, + isDefault: boolean + ): IndexPatternTag[] { return isDefault ? [ { @@ -35,11 +39,11 @@ export class IndexPatternListConfig { : []; } - public getFieldInfo(indexPattern: IndexPattern, field: IndexPatternField): string[] { + public getFieldInfo(indexPattern: IIndexPattern, field: IFieldType): string[] { return []; } - public areScriptedFieldsEnabled(indexPattern: IndexPattern): boolean { + public areScriptedFieldsEnabled(indexPattern: IIndexPattern): boolean { return true; } } diff --git a/src/plugins/index_pattern_management/public/service/list/manager.ts b/src/plugins/index_pattern_management/public/service/list/manager.ts index d9cefbd8001a5..bdb2d47057f1f 100644 --- a/src/plugins/index_pattern_management/public/service/list/manager.ts +++ b/src/plugins/index_pattern_management/public/service/list/manager.ts @@ -6,11 +6,13 @@ * Side Public License, v 1. */ -import { IndexPattern, IndexPatternField } from 'src/plugins/data/public'; +import { IIndexPattern, IFieldType } from 'src/plugins/data/public'; +import { SimpleSavedObject } from 'src/core/public'; import { once } from 'lodash'; import { CoreStart } from '../../../../../core/public'; import { IndexPatternListConfig, IndexPatternTag } from './config'; import { CONFIG_ROLLUPS } from '../../constants'; +// @ts-ignore import { RollupIndexPatternListConfig } from './rollup_list_config'; interface IndexPatternListManagerStart { @@ -30,7 +32,10 @@ export class IndexPatternListManager { return configs; }); return { - getIndexPatternTags: (indexPattern: IndexPattern, isDefault: boolean) => + getIndexPatternTags: ( + indexPattern: IIndexPattern | SimpleSavedObject<IIndexPattern>, + isDefault: boolean + ) => getConfigs().reduce( (tags: IndexPatternTag[], config) => config.getIndexPatternTags @@ -39,14 +44,14 @@ export class IndexPatternListManager { [] ), - getFieldInfo: (indexPattern: IndexPattern, field: IndexPatternField): string[] => + getFieldInfo: (indexPattern: IIndexPattern, field: IFieldType): string[] => getConfigs().reduce( (info: string[], config) => config.getFieldInfo ? info.concat(config.getFieldInfo(indexPattern, field)) : info, [] ), - areScriptedFieldsEnabled: (indexPattern: IndexPattern): boolean => + areScriptedFieldsEnabled: (indexPattern: IIndexPattern): boolean => getConfigs().every((config) => config.areScriptedFieldsEnabled ? config.areScriptedFieldsEnabled(indexPattern) : true ), diff --git a/src/plugins/index_pattern_management/public/service/list/rollup_list_config.ts b/src/plugins/index_pattern_management/public/service/list/rollup_list_config.js similarity index 69% rename from src/plugins/index_pattern_management/public/service/list/rollup_list_config.ts rename to src/plugins/index_pattern_management/public/service/list/rollup_list_config.js index bb9da0d461701..9a80d5fd0d622 100644 --- a/src/plugins/index_pattern_management/public/service/list/rollup_list_config.ts +++ b/src/plugins/index_pattern_management/public/service/list/rollup_list_config.js @@ -6,17 +6,18 @@ * Side Public License, v 1. */ -import { IndexPattern, IndexPatternField, IndexPatternType } from '../../../../data/public'; import { IndexPatternListConfig } from '.'; -function isRollup(indexPattern: IndexPattern) { - return indexPattern.type === IndexPatternType.ROLLUP; +function isRollup(indexPattern) { + return ( + indexPattern.type === 'rollup' || (indexPattern.get && indexPattern.get('type') === 'rollup') + ); } export class RollupIndexPatternListConfig extends IndexPatternListConfig { - key = IndexPatternType.ROLLUP; + key = 'rollup'; - getIndexPatternTags = (indexPattern: IndexPattern) => { + getIndexPatternTags = (indexPattern) => { return isRollup(indexPattern) ? [ { @@ -27,13 +28,13 @@ export class RollupIndexPatternListConfig extends IndexPatternListConfig { : []; }; - getFieldInfo = (indexPattern: IndexPattern, field: IndexPatternField) => { + getFieldInfo = (indexPattern, field) => { if (!isRollup(indexPattern)) { return []; } const allAggs = indexPattern.typeMeta && indexPattern.typeMeta.aggs; - const fieldAggs = allAggs && Object.keys(allAggs).filter((agg) => allAggs[agg][field.name]); + const fieldAggs = allAggs && Object.keys(allAggs).filter((agg) => allAggs[agg][field]); if (!fieldAggs || !fieldAggs.length) { return []; @@ -41,12 +42,13 @@ export class RollupIndexPatternListConfig extends IndexPatternListConfig { return ['Rollup aggregations:'].concat( fieldAggs.map((aggName) => { - const agg = allAggs![aggName][field.name]; + const agg = allAggs[aggName][field]; switch (aggName) { case 'date_histogram': - return `${aggName} (interval: ${agg.fixed_interval}, ${ + return `${aggName} (interval: ${agg.interval}, ${ agg.delay ? `delay: ${agg.delay},` : '' } ${agg.time_zone})`; + break; case 'histogram': return `${aggName} (interval: ${agg.interval})`; default: @@ -56,7 +58,7 @@ export class RollupIndexPatternListConfig extends IndexPatternListConfig { ); }; - areScriptedFieldsEnabled = (indexPattern: IndexPattern) => { + areScriptedFieldsEnabled = (indexPattern) => { return !isRollup(indexPattern); }; }