;
diff --git a/src/plugins/data/public/search/aggs/utils/index.ts b/src/plugins/data/public/search/aggs/utils/index.ts
index 23606bd109342..169d872b17d3a 100644
--- a/src/plugins/data/public/search/aggs/utils/index.ts
+++ b/src/plugins/data/public/search/aggs/utils/index.ts
@@ -18,4 +18,5 @@
*/
export * from './calculate_auto_time_expression';
+export * from './prop_filter';
export * from './to_angular_json';
diff --git a/src/plugins/data/public/search/aggs/filter/prop_filter.test.ts b/src/plugins/data/public/search/aggs/utils/prop_filter.test.ts
similarity index 100%
rename from src/plugins/data/public/search/aggs/filter/prop_filter.test.ts
rename to src/plugins/data/public/search/aggs/utils/prop_filter.test.ts
diff --git a/src/plugins/data/public/search/aggs/filter/prop_filter.ts b/src/plugins/data/public/search/aggs/utils/prop_filter.ts
similarity index 97%
rename from src/plugins/data/public/search/aggs/filter/prop_filter.ts
rename to src/plugins/data/public/search/aggs/utils/prop_filter.ts
index e6b5f3831e65d..01e98a68d3949 100644
--- a/src/plugins/data/public/search/aggs/filter/prop_filter.ts
+++ b/src/plugins/data/public/search/aggs/utils/prop_filter.ts
@@ -28,7 +28,7 @@ type FilterFunc = (item: T[P]) => boolean;
*
* @returns the filter function which can be registered with angular
*/
-function propFilter
(prop: P) {
+export function propFilter
(prop: P) {
/**
* List filtering function which accepts an array or list of values that a property
* must contain
@@ -92,5 +92,3 @@ function propFilter
(prop: P) {
});
};
}
-
-export { propFilter };
diff --git a/src/plugins/data/public/search/mocks.ts b/src/plugins/data/public/search/mocks.ts
index dd196074c8173..44082040b5b0b 100644
--- a/src/plugins/data/public/search/mocks.ts
+++ b/src/plugins/data/public/search/mocks.ts
@@ -18,7 +18,6 @@
*/
import { searchAggsSetupMock, searchAggsStartMock } from './aggs/mocks';
-import { AggTypeFieldFilters } from './aggs/param_types/filter';
import { ISearchStart } from './types';
import { searchSourceMock, createSearchSourceMock } from './search_source/mocks';
@@ -34,13 +33,6 @@ const searchStartMock: jest.Mocked = {
search: jest.fn(),
searchSource: searchSourceMock,
__LEGACY: {
- AggConfig: jest.fn() as any,
- AggType: jest.fn(),
- aggTypeFieldFilters: new AggTypeFieldFilters(),
- FieldParamType: jest.fn(),
- MetricAggType: jest.fn(),
- parentPipelineAggHelper: jest.fn() as any,
- siblingPipelineAggHelper: jest.fn() as any,
esClient: {
search: jest.fn(),
msearch: jest.fn(),
diff --git a/src/plugins/data/public/search/search_service.ts b/src/plugins/data/public/search/search_service.ts
index b59524baa9fa7..4d183797dfef0 100644
--- a/src/plugins/data/public/search/search_service.ts
+++ b/src/plugins/data/public/search/search_service.ts
@@ -39,16 +39,9 @@ import { SearchInterceptor } from './search_interceptor';
import {
getAggTypes,
getAggTypesFunctions,
- AggType,
AggTypesRegistry,
- AggConfig,
AggConfigs,
- FieldParamType,
getCalculateAutoTimeExpression,
- MetricAggType,
- aggTypeFieldFilters,
- parentPipelineAggHelper,
- siblingPipelineAggHelper,
} from './aggs';
import { FieldFormatsStart } from '../field_formats';
import { ISearchGeneric } from './i_search';
@@ -156,13 +149,6 @@ export class SearchService implements Plugin {
const legacySearch = {
esClient: this.esClient!,
- AggConfig,
- AggType,
- aggTypeFieldFilters,
- FieldParamType,
- MetricAggType,
- parentPipelineAggHelper,
- siblingPipelineAggHelper,
};
const searchSourceDependencies: SearchSourceDependencies = {
diff --git a/src/plugins/data/public/search/types.ts b/src/plugins/data/public/search/types.ts
index 99d111ce1574e..1687c8f983393 100644
--- a/src/plugins/data/public/search/types.ts
+++ b/src/plugins/data/public/search/types.ts
@@ -18,7 +18,7 @@
*/
import { CoreStart, SavedObjectReference } from 'kibana/public';
-import { SearchAggsSetup, SearchAggsStart, SearchAggsStartLegacy } from './aggs';
+import { SearchAggsSetup, SearchAggsStart } from './aggs';
import { ISearch, ISearchGeneric } from './i_search';
import { TStrategyTypes } from './strategy_types';
import { LegacyApiCaller } from './legacy/es_client';
@@ -88,5 +88,5 @@ export interface ISearchStart {
references: SavedObjectReference[]
) => Promise;
};
- __LEGACY: ISearchStartLegacy & SearchAggsStartLegacy;
+ __LEGACY: ISearchStartLegacy;
}
diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap b/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap
index fb3d6efa63826..1860a4625afc0 100644
--- a/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap
+++ b/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap
@@ -260,19 +260,10 @@ exports[`SavedObjectsTable import should show the flyout 1`] = `
search={
Object {
"__LEGACY": Object {
- "AggConfig": [MockFunction],
- "AggType": [MockFunction],
- "FieldParamType": [MockFunction],
- "MetricAggType": [MockFunction],
- "aggTypeFieldFilters": AggTypeFieldFilters {
- "filters": Set {},
- },
"esClient": Object {
"msearch": [MockFunction],
"search": [MockFunction],
},
- "parentPipelineAggHelper": [MockFunction],
- "siblingPipelineAggHelper": [MockFunction],
},
"aggs": Object {
"calculateAutoTimeExpression": [Function],
diff --git a/src/plugins/vis_default_editor/public/agg_filters/agg_type_field_filters.ts b/src/plugins/vis_default_editor/public/agg_filters/agg_type_field_filters.ts
new file mode 100644
index 0000000000000..15df2f0acccd1
--- /dev/null
+++ b/src/plugins/vis_default_editor/public/agg_filters/agg_type_field_filters.ts
@@ -0,0 +1,49 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { IAggConfig, IndexPatternField } from '../../../data/public';
+
+type AggTypeFieldFilter = (field: IndexPatternField, aggConfig: IAggConfig) => boolean;
+
+const filters: AggTypeFieldFilter[] = [
+ /**
+ * Check index pattern aggregation restrictions
+ * and limit available fields for a given aggType based on that.
+ */
+ (field, aggConfig) => {
+ const indexPattern = aggConfig.getIndexPattern();
+ const aggRestrictions = indexPattern.getAggregationRestrictions();
+
+ if (!aggRestrictions) {
+ return true;
+ }
+
+ const aggName = aggConfig.type && aggConfig.type.name;
+ const aggFields = aggRestrictions[aggName];
+ return !!aggFields && !!aggFields[field.name];
+ },
+];
+
+export function filterAggTypeFields(fields: IndexPatternField[], aggConfig: IAggConfig) {
+ const allowedAggTypeFields = fields.filter(field => {
+ const isAggTypeFieldAllowed = filters.every(filter => filter(field, aggConfig));
+ return isAggTypeFieldAllowed;
+ });
+ return allowedAggTypeFields;
+}
diff --git a/src/plugins/vis_default_editor/public/agg_filters/agg_type_filters.ts b/src/plugins/vis_default_editor/public/agg_filters/agg_type_filters.ts
new file mode 100644
index 0000000000000..2cf1acba4d228
--- /dev/null
+++ b/src/plugins/vis_default_editor/public/agg_filters/agg_type_filters.ts
@@ -0,0 +1,75 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { IAggType, IAggConfig, IndexPattern, search } from '../../../data/public';
+
+const { propFilter } = search.aggs;
+const filterByName = propFilter('name');
+
+type AggTypeFilter = (
+ aggType: IAggType,
+ indexPattern: IndexPattern,
+ aggConfig: IAggConfig,
+ aggFilter: string[]
+) => boolean;
+
+const filters: AggTypeFilter[] = [
+ /**
+ * This filter checks the defined aggFilter in the schemas of that visualization
+ * and limits available aggregations based on that.
+ */
+ (aggType, indexPattern, aggConfig, aggFilter) => {
+ const doesSchemaAllowAggType = filterByName([aggType], aggFilter).length !== 0;
+ return doesSchemaAllowAggType;
+ },
+ /**
+ * Check index pattern aggregation restrictions and limit available aggTypes.
+ */
+ (aggType, indexPattern, aggConfig, aggFilter) => {
+ const aggRestrictions = indexPattern.getAggregationRestrictions();
+
+ if (!aggRestrictions) {
+ return true;
+ }
+
+ const aggName = aggType.name;
+ // Only return agg types which are specified in the agg restrictions,
+ // except for `count` which should always be returned.
+ return (
+ aggName === 'count' ||
+ (!!aggRestrictions && Object.keys(aggRestrictions).includes(aggName)) ||
+ false
+ );
+ },
+];
+
+export function filterAggTypes(
+ aggTypes: IAggType[],
+ indexPattern: IndexPattern,
+ aggConfig: IAggConfig,
+ aggFilter: string[]
+) {
+ const allowedAggTypes = aggTypes.filter(aggType => {
+ const isAggTypeAllowed = filters.every(filter =>
+ filter(aggType, indexPattern, aggConfig, aggFilter)
+ );
+ return isAggTypeAllowed;
+ });
+ return allowedAggTypes;
+}
diff --git a/src/plugins/data/public/search/aggs/param_types/filter/index.ts b/src/plugins/vis_default_editor/public/agg_filters/index.ts
similarity index 91%
rename from src/plugins/data/public/search/aggs/param_types/filter/index.ts
rename to src/plugins/vis_default_editor/public/agg_filters/index.ts
index 2e0039c96a192..2b08449fb3161 100644
--- a/src/plugins/data/public/search/aggs/param_types/filter/index.ts
+++ b/src/plugins/vis_default_editor/public/agg_filters/index.ts
@@ -17,4 +17,5 @@
* under the License.
*/
-export { aggTypeFieldFilters, AggTypeFieldFilters } from './field_filters';
+export * from './agg_type_filters';
+export * from './agg_type_field_filters';
diff --git a/src/plugins/vis_default_editor/public/components/agg_common_props.ts b/src/plugins/vis_default_editor/public/components/agg_common_props.ts
index 0c130a96230b4..40d7b79bfbefc 100644
--- a/src/plugins/vis_default_editor/public/components/agg_common_props.ts
+++ b/src/plugins/vis_default_editor/public/components/agg_common_props.ts
@@ -18,7 +18,7 @@
*/
import { VisParams } from 'src/plugins/visualizations/public';
-import { IAggType, IAggConfig, IAggGroupNames } from 'src/plugins/data/public';
+import { IAggType, IAggConfig, AggGroupName } from 'src/plugins/data/public';
import { Schema } from '../schemas';
import { EditorVisState } from './sidebar/state/reducers';
@@ -30,7 +30,7 @@ export type ReorderAggs = (sourceAgg: IAggConfig, destinationAgg: IAggConfig) =>
export interface DefaultEditorCommonProps {
formIsTouched: boolean;
- groupName: IAggGroupNames;
+ groupName: AggGroupName;
metricAggs: IAggConfig[];
state: EditorVisState;
setAggParamValue: (
diff --git a/src/plugins/vis_default_editor/public/components/agg_group.tsx b/src/plugins/vis_default_editor/public/components/agg_group.tsx
index 72515d0845926..fae9de6959ef1 100644
--- a/src/plugins/vis_default_editor/public/components/agg_group.tsx
+++ b/src/plugins/vis_default_editor/public/components/agg_group.tsx
@@ -30,7 +30,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
-import { AggGroupNames, search, IAggConfig, TimeRange } from '../../../data/public';
+import { AggGroupNames, AggGroupLabels, IAggConfig, TimeRange } from '../../../data/public';
import { DefaultEditorAgg } from './agg';
import { DefaultEditorAggAdd } from './agg_add';
import { AddSchema, ReorderAggs, DefaultEditorAggCommonProps } from './agg_common_props';
@@ -70,7 +70,7 @@ function DefaultEditorAggGroup({
setValidity,
timeRange,
}: DefaultEditorAggGroupProps) {
- const groupNameLabel = (search.aggs.aggGroupNamesMap() as any)[groupName];
+ const groupNameLabel = AggGroupLabels[groupName];
// e.g. buckets can have no aggs
const schemaNames = schemas.map(s => s.name);
const group: IAggConfig[] = useMemo(
diff --git a/src/plugins/vis_default_editor/public/components/agg_param_props.ts b/src/plugins/vis_default_editor/public/components/agg_param_props.ts
index aec332e8674d7..076bddc9551ea 100644
--- a/src/plugins/vis_default_editor/public/components/agg_param_props.ts
+++ b/src/plugins/vis_default_editor/public/components/agg_param_props.ts
@@ -17,7 +17,12 @@
* under the License.
*/
-import { IAggConfig, AggParam, IndexPatternField } from 'src/plugins/data/public';
+import {
+ IAggConfig,
+ AggParam,
+ IndexPatternField,
+ OptionedValueProp,
+} from 'src/plugins/data/public';
import { ComboBoxGroupedOptions } from '../utils';
import { EditorConfig } from './utils';
import { Schema } from '../schemas';
@@ -46,3 +51,9 @@ export interface AggParamEditorProps extends AggParamCommonProp
setValidity(isValid: boolean): void;
setTouched(): void;
}
+
+export interface OptionedParamEditorProps {
+ aggParam: {
+ options: T[];
+ };
+}
diff --git a/src/plugins/vis_default_editor/public/components/agg_params.tsx b/src/plugins/vis_default_editor/public/components/agg_params.tsx
index 3674e39b558d2..d36c2d0e7625b 100644
--- a/src/plugins/vis_default_editor/public/components/agg_params.tsx
+++ b/src/plugins/vis_default_editor/public/components/agg_params.tsx
@@ -112,20 +112,8 @@ function DefaultEditorAggParams({
fieldName,
]);
const params = useMemo(
- () =>
- getAggParamsToRender(
- { agg, editorConfig, metricAggs, state, schemas, hideCustomLabel },
- services.data.search.__LEGACY.aggTypeFieldFilters
- ),
- [
- agg,
- editorConfig,
- metricAggs,
- state,
- schemas,
- hideCustomLabel,
- services.data.search.__LEGACY.aggTypeFieldFilters,
- ]
+ () => getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas, hideCustomLabel }),
+ [agg, editorConfig, metricAggs, state, schemas, hideCustomLabel]
);
const allParams = [...params.basic, ...params.advanced];
const [paramsState, onChangeParamsState] = useReducer(
diff --git a/src/plugins/vis_default_editor/public/components/agg_params_helper.test.ts b/src/plugins/vis_default_editor/public/components/agg_params_helper.test.ts
index bed2561341737..834ad8b70ad0d 100644
--- a/src/plugins/vis_default_editor/public/components/agg_params_helper.test.ts
+++ b/src/plugins/vis_default_editor/public/components/agg_params_helper.test.ts
@@ -23,7 +23,6 @@ import {
IAggConfig,
IAggType,
IndexPattern,
- IndexPatternField,
} from 'src/plugins/data/public';
import {
getAggParamsToRender,
@@ -39,12 +38,6 @@ jest.mock('../utils', () => ({
groupAndSortBy: jest.fn(() => ['indexedFields']),
}));
-const mockFilter: any = {
- filter(fields: IndexPatternField[]): IndexPatternField[] {
- return fields;
- },
-};
-
describe('DefaultEditorAggParams helpers', () => {
describe('getAggParamsToRender', () => {
let agg: IAggConfig;
@@ -72,20 +65,14 @@ describe('DefaultEditorAggParams helpers', () => {
},
schema: 'metric',
} as IAggConfig;
- const params = getAggParamsToRender(
- { agg, editorConfig, metricAggs, state, schemas },
- mockFilter
- );
+ const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas });
expect(params).toEqual(emptyParams);
});
it('should not create any param if there is no agg type', () => {
agg = { schema: 'metric' } as IAggConfig;
- const params = getAggParamsToRender(
- { agg, editorConfig, metricAggs, state, schemas },
- mockFilter
- );
+ const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas });
expect(params).toEqual(emptyParams);
});
@@ -101,10 +88,7 @@ describe('DefaultEditorAggParams helpers', () => {
hidden: true,
},
};
- const params = getAggParamsToRender(
- { agg, editorConfig, metricAggs, state, schemas },
- mockFilter
- );
+ const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas });
expect(params).toEqual(emptyParams);
});
@@ -116,10 +100,7 @@ describe('DefaultEditorAggParams helpers', () => {
},
schema: 'metric2',
} as any) as IAggConfig;
- const params = getAggParamsToRender(
- { agg, editorConfig, metricAggs, state, schemas },
- mockFilter
- );
+ const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas });
expect(params).toEqual(emptyParams);
});
@@ -152,16 +133,14 @@ describe('DefaultEditorAggParams helpers', () => {
{ name: '@timestamp', type: 'date' },
{ name: 'geo_desc', type: 'string' },
],
+ getAggregationRestrictions: jest.fn(),
})),
params: {
orderBy: 'orderBy',
field: 'field',
},
} as any) as IAggConfig;
- const params = getAggParamsToRender(
- { agg, editorConfig, metricAggs, state, schemas },
- mockFilter
- );
+ const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas });
expect(params).toEqual({
basic: [
@@ -190,7 +169,6 @@ describe('DefaultEditorAggParams helpers', () => {
],
advanced: [],
});
- expect(agg.getIndexPattern).toBeCalledTimes(1);
});
});
diff --git a/src/plugins/vis_default_editor/public/components/agg_params_helper.ts b/src/plugins/vis_default_editor/public/components/agg_params_helper.ts
index a32bd76bafa5a..9977f1e5e71fc 100644
--- a/src/plugins/vis_default_editor/public/components/agg_params_helper.ts
+++ b/src/plugins/vis_default_editor/public/components/agg_params_helper.ts
@@ -20,7 +20,6 @@
import { get, isEmpty } from 'lodash';
import {
- AggTypeFieldFilters,
IAggConfig,
AggParam,
IFieldParamType,
@@ -28,13 +27,13 @@ import {
IndexPattern,
IndexPatternField,
} from 'src/plugins/data/public';
+import { filterAggTypes, filterAggTypeFields } from '../agg_filters';
import { groupAndSortBy, ComboBoxGroupedOptions } from '../utils';
import { AggTypeState, AggParamsState } from './agg_params_state';
import { AggParamEditorProps } from './agg_param_props';
import { aggParamsMap } from './agg_params_map';
import { EditorConfig } from './utils';
import { Schema, getSchemaByName } from '../schemas';
-import { search } from '../../../data/public';
import { EditorVisState } from './sidebar/state/reducers';
interface ParamInstanceBase {
@@ -53,10 +52,14 @@ export interface ParamInstance extends ParamInstanceBase {
value: unknown;
}
-function getAggParamsToRender(
- { agg, editorConfig, metricAggs, state, schemas, hideCustomLabel }: ParamInstanceBase,
- aggTypeFieldFilters: AggTypeFieldFilters
-) {
+function getAggParamsToRender({
+ agg,
+ editorConfig,
+ metricAggs,
+ state,
+ schemas,
+ hideCustomLabel,
+}: ParamInstanceBase) {
const params = {
basic: [] as ParamInstance[],
advanced: [] as ParamInstance[],
@@ -89,7 +92,7 @@ function getAggParamsToRender(
availableFields = availableFields.filter(field => field.type === 'number');
}
}
- fields = aggTypeFieldFilters.filter(availableFields, agg);
+ fields = filterAggTypeFields(availableFields, agg);
indexedFields = groupAndSortBy(fields, 'type', 'name');
if (fields && !indexedFields.length && index > 0) {
@@ -138,12 +141,7 @@ function getAggTypeOptions(
groupName: string,
allowedAggs: string[]
): ComboBoxGroupedOptions {
- const aggTypeOptions = search.aggs.aggTypeFilters.filter(
- aggTypes[groupName],
- indexPattern,
- agg,
- allowedAggs
- );
+ const aggTypeOptions = filterAggTypes(aggTypes[groupName], indexPattern, agg, allowedAggs);
return groupAndSortBy(aggTypeOptions as any[], 'subtype', 'title');
}
diff --git a/src/plugins/vis_default_editor/public/components/controls/order.tsx b/src/plugins/vis_default_editor/public/components/controls/order.tsx
index e609bf9adf790..3c0224564300a 100644
--- a/src/plugins/vis_default_editor/public/components/controls/order.tsx
+++ b/src/plugins/vis_default_editor/public/components/controls/order.tsx
@@ -21,8 +21,8 @@ import React, { useEffect } from 'react';
import { EuiFormRow, EuiSelect } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
-import { OptionedValueProp, OptionedParamEditorProps } from 'src/plugins/data/public';
-import { AggParamEditorProps } from '../agg_param_props';
+import { OptionedValueProp } from 'src/plugins/data/public';
+import { AggParamEditorProps, OptionedParamEditorProps } from '../agg_param_props';
function OrderParamEditor({
aggParam,
diff --git a/src/plugins/vis_default_editor/public/components/controls/top_aggregate.tsx b/src/plugins/vis_default_editor/public/components/controls/top_aggregate.tsx
index ad23cec87800f..66abb88b97d29 100644
--- a/src/plugins/vis_default_editor/public/components/controls/top_aggregate.tsx
+++ b/src/plugins/vis_default_editor/public/components/controls/top_aggregate.tsx
@@ -26,10 +26,9 @@ import {
IAggConfig,
AggParam,
OptionedValueProp,
- OptionedParamEditorProps,
OptionedParamType,
} from 'src/plugins/data/public';
-import { AggParamEditorProps } from '../agg_param_props';
+import { AggParamEditorProps, OptionedParamEditorProps } from '../agg_param_props';
export interface AggregateValueProp extends OptionedValueProp {
isCompatible(aggConfig: IAggConfig): boolean;
diff --git a/src/plugins/vis_default_editor/public/default_editor.tsx b/src/plugins/vis_default_editor/public/default_editor.tsx
index 1c2ddbc314f99..8088921ba7fda 100644
--- a/src/plugins/vis_default_editor/public/default_editor.tsx
+++ b/src/plugins/vis_default_editor/public/default_editor.tsx
@@ -22,7 +22,6 @@ import React, { useEffect, useRef, useState, useCallback } from 'react';
import { EditorRenderProps } from 'src/plugins/visualize/public';
import { PanelsContainer, Panel } from '../../kibana_react/public';
-import './vis_type_agg_filter';
import { DefaultEditorSideBar } from './components/sidebar';
import { DefaultEditorControllerState } from './default_editor_controller';
import { getInitialWidth } from './editor_size';
diff --git a/src/plugins/vis_default_editor/public/schemas.ts b/src/plugins/vis_default_editor/public/schemas.ts
index 05ba5fa9c9419..26d1cbe91b996 100644
--- a/src/plugins/vis_default_editor/public/schemas.ts
+++ b/src/plugins/vis_default_editor/public/schemas.ts
@@ -21,7 +21,7 @@ import _, { defaults } from 'lodash';
import { Optional } from '@kbn/utility-types';
-import { AggGroupNames, AggParam, IAggGroupNames } from '../../data/public';
+import { AggGroupNames, AggParam, AggGroupName } from '../../data/public';
export interface ISchemas {
[AggGroupNames.Buckets]: Schema[];
@@ -32,7 +32,7 @@ export interface ISchemas {
export interface Schema {
aggFilter: string[];
editor: boolean | string;
- group: IAggGroupNames;
+ group: AggGroupName;
max: number;
min: number;
name: string;
diff --git a/src/plugins/vis_default_editor/public/vis_type_agg_filter.ts b/src/plugins/vis_default_editor/public/vis_type_agg_filter.ts
deleted file mode 100644
index bf5661f42a9f5..0000000000000
--- a/src/plugins/vis_default_editor/public/vis_type_agg_filter.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import { IAggType, IAggConfig, IndexPattern, search } from '../../data/public';
-
-const { aggTypeFilters, propFilter } = search.aggs;
-const filterByName = propFilter('name');
-
-/**
- * This filter checks the defined aggFilter in the schemas of that visualization
- * and limits available aggregations based on that.
- */
-aggTypeFilters.addFilter(
- (aggType: IAggType, indexPatterns: IndexPattern, aggConfig: IAggConfig, aggFilter: string[]) => {
- const doesSchemaAllowAggType = filterByName([aggType], aggFilter).length !== 0;
- return doesSchemaAllowAggType;
- }
-);
diff --git a/x-pack/plugins/rollup/kibana.json b/x-pack/plugins/rollup/kibana.json
index 4c7dcb48a4d3f..f897051d3ed8a 100644
--- a/x-pack/plugins/rollup/kibana.json
+++ b/x-pack/plugins/rollup/kibana.json
@@ -7,8 +7,7 @@
"requiredPlugins": [
"indexPatternManagement",
"management",
- "licensing",
- "data"
+ "licensing"
],
"optionalPlugins": [
"home",
diff --git a/x-pack/plugins/rollup/public/plugin.ts b/x-pack/plugins/rollup/public/plugin.ts
index fd1b90fbc9855..5bb678ac35d06 100644
--- a/x-pack/plugins/rollup/public/plugin.ts
+++ b/x-pack/plugins/rollup/public/plugin.ts
@@ -11,10 +11,6 @@ import { rollupBadgeExtension, rollupToggleExtension } from './extend_index_mana
import { RollupIndexPatternCreationConfig } from './index_pattern_creation/rollup_index_pattern_creation_config';
// @ts-ignore
import { RollupIndexPatternListConfig } from './index_pattern_list/rollup_index_pattern_list_config';
-// @ts-ignore
-import { initAggTypeFilter } from './visualize/agg_type_filter';
-// @ts-ignore
-import { initAggTypeFieldFilter } from './visualize/agg_type_field_filter';
import { CONFIG_ROLLUPS, UIM_APP_NAME } from '../common';
import {
FeatureCatalogueCategory,
@@ -25,7 +21,6 @@ import { CRUD_APP_BASE_PATH } from './crud_app/constants';
import { ManagementSetup } from '../../../../src/plugins/management/public';
import { IndexManagementPluginSetup } from '../../index_management/public';
import { IndexPatternManagementSetup } from '../../../../src/plugins/index_pattern_management/public';
-import { DataPublicPluginStart, search } from '../../../../src/plugins/data/public';
// @ts-ignore
import { setEsBaseAndXPackBase, setHttp } from './crud_app/services/index';
import { setNotifications, setFatalErrors, setUiStatsReporter } from './kibana_services';
@@ -39,10 +34,6 @@ export interface RollupPluginSetupDependencies {
usageCollection?: UsageCollectionSetup;
}
-export interface RollupPluginStartDependencies {
- data: DataPublicPluginStart;
-}
-
export class RollupPlugin implements Plugin {
setup(
core: CoreSetup,
@@ -108,16 +99,9 @@ export class RollupPlugin implements Plugin {
}
}
- start(core: CoreStart, plugins: RollupPluginStartDependencies) {
+ start(core: CoreStart) {
setHttp(core.http);
setNotifications(core.notifications);
setEsBaseAndXPackBase(core.docLinks.ELASTIC_WEBSITE_URL, core.docLinks.DOC_LINK_VERSION);
-
- const isRollupIndexPatternsEnabled = core.uiSettings.get(CONFIG_ROLLUPS);
-
- if (isRollupIndexPatternsEnabled) {
- initAggTypeFilter(search.aggs.aggTypeFilters);
- initAggTypeFieldFilter(plugins.data.search.__LEGACY.aggTypeFieldFilters);
- }
}
}
diff --git a/x-pack/plugins/rollup/public/visualize/agg_type_field_filter.js b/x-pack/plugins/rollup/public/visualize/agg_type_field_filter.js
deleted file mode 100644
index 6f44e0ef90efd..0000000000000
--- a/x-pack/plugins/rollup/public/visualize/agg_type_field_filter.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-export function initAggTypeFieldFilter(aggTypeFieldFilters) {
- /**
- * If rollup index pattern, check its capabilities
- * and limit available fields for a given aggType based on that.
- */
- aggTypeFieldFilters.addFilter((field, aggConfig) => {
- const indexPattern = aggConfig.getIndexPattern();
- if (!indexPattern || indexPattern.type !== 'rollup') {
- return true;
- }
- const aggName = aggConfig.type && aggConfig.type.name;
- const aggFields =
- indexPattern.typeMeta && indexPattern.typeMeta.aggs && indexPattern.typeMeta.aggs[aggName];
- return aggFields && aggFields[field.name];
- });
-}
diff --git a/x-pack/plugins/rollup/public/visualize/agg_type_filter.js b/x-pack/plugins/rollup/public/visualize/agg_type_filter.js
deleted file mode 100644
index 5f9fab3061a19..0000000000000
--- a/x-pack/plugins/rollup/public/visualize/agg_type_filter.js
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-export function initAggTypeFilter(aggTypeFilters) {
- /**
- * If rollup index pattern, check its capabilities
- * and limit available aggregations based on that.
- */
- aggTypeFilters.addFilter((aggType, indexPattern) => {
- if (indexPattern.type !== 'rollup') {
- return true;
- }
- const aggName = aggType.name;
- const aggs = indexPattern.typeMeta && indexPattern.typeMeta.aggs;
-
- // Return doc_count (which is collected by default for rollup date histogram, histogram, and terms)
- // and the rest of the defined metrics from capabilities.
- return aggName === 'count' || Object.keys(aggs).includes(aggName);
- });
-}