From f7db5592e437c201c0a814090ad024e2ccbb7fea Mon Sep 17 00:00:00 2001 From: Uladzislau Lasitsa Date: Mon, 30 Aug 2021 19:01:13 +0300 Subject: [PATCH] [TSVB] Geo_point should be excluded from terms aggregation (#109210) * Add field type restriction for terms agg * Fix test * Add restriction for 'group by' in table Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../public/application/components/panel_config/table.tsx | 8 ++++++++ .../components/splits/__snapshots__/terms.test.js.snap | 9 +++++++++ .../public/application/components/splits/terms.js | 7 +++++++ 3 files changed, 24 insertions(+) diff --git a/src/plugins/vis_type_timeseries/public/application/components/panel_config/table.tsx b/src/plugins/vis_type_timeseries/public/application/components/panel_config/table.tsx index 3633f8add7457..d9d5401fd131f 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/panel_config/table.tsx +++ b/src/plugins/vis_type_timeseries/public/application/components/panel_config/table.tsx @@ -42,6 +42,7 @@ import { BUCKET_TYPES } from '../../../../common/enums'; import { PanelConfigProps, PANEL_CONFIG_TABS } from './types'; import { TimeseriesVisParams } from '../../../types'; import { getIndexPatternKey } from '../../../../common/index_patterns_utils'; +import { KBN_FIELD_TYPES } from '../../../../../data/public'; export class TablePanelConfig extends Component< PanelConfigProps, @@ -115,6 +116,13 @@ export class TablePanelConfig extends Component< defaultMessage="Group by field" /> } + restrict={[ + KBN_FIELD_TYPES.NUMBER, + KBN_FIELD_TYPES.BOOLEAN, + KBN_FIELD_TYPES.DATE, + KBN_FIELD_TYPES.IP, + KBN_FIELD_TYPES.STRING, + ]} fields={this.props.fields} value={model.pivot_id} indexPattern={model.index_pattern} diff --git a/src/plugins/vis_type_timeseries/public/application/components/splits/__snapshots__/terms.test.js.snap b/src/plugins/vis_type_timeseries/public/application/components/splits/__snapshots__/terms.test.js.snap index ce381a0e539d0..524e35f9d29e1 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/splits/__snapshots__/terms.test.js.snap +++ b/src/plugins/vis_type_timeseries/public/application/components/splits/__snapshots__/terms.test.js.snap @@ -54,6 +54,15 @@ exports[`src/legacy/core_plugins/metrics/public/components/splits/terms.test.js /> } onChange={[Function]} + restrict={ + Array [ + "number", + "boolean", + "date", + "ip", + "string", + ] + } type="terms" value="OriginCityName" /> diff --git a/src/plugins/vis_type_timeseries/public/application/components/splits/terms.js b/src/plugins/vis_type_timeseries/public/application/components/splits/terms.js index 9c097de38d56a..a668e5b727b48 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/splits/terms.js +++ b/src/plugins/vis_type_timeseries/public/application/components/splits/terms.js @@ -120,6 +120,13 @@ export const SplitByTermsUI = ({ description="This labels a field selector allowing the user to chose 'by' which field to group." /> } + restrict={[ + KBN_FIELD_TYPES.NUMBER, + KBN_FIELD_TYPES.BOOLEAN, + KBN_FIELD_TYPES.DATE, + KBN_FIELD_TYPES.IP, + KBN_FIELD_TYPES.STRING, + ]} data-test-subj="groupByField" indexPattern={indexPattern} onChange={handleSelectChange('terms_field')}