From 63ea74c43cd3c053780d0e7be2411651985ca3ee Mon Sep 17 00:00:00 2001 From: Daniil Suleiman <31325372+sulemanof@users.noreply.github.com> Date: Wed, 10 Apr 2019 16:55:41 +0300 Subject: [PATCH] [Vis: Default editor] EUIficate min doc count control (#34700) * EUIficate min doc count control * Add a common class name * Move tooltip to the right --- .../ui/public/agg_types/buckets/histogram.js | 6 +-- .../agg_types/controls/drop_partials.tsx | 2 +- .../agg_types/controls/min_doc_count.html | 17 ------- .../agg_types/controls/min_doc_count.tsx | 45 +++++++++++++++++++ 4 files changed, 49 insertions(+), 21 deletions(-) delete mode 100644 src/legacy/ui/public/agg_types/controls/min_doc_count.html create mode 100644 src/legacy/ui/public/agg_types/controls/min_doc_count.tsx diff --git a/src/legacy/ui/public/agg_types/buckets/histogram.js b/src/legacy/ui/public/agg_types/buckets/histogram.js index 8e71a49f1c82..21d8f4e1496a 100644 --- a/src/legacy/ui/public/agg_types/buckets/histogram.js +++ b/src/legacy/ui/public/agg_types/buckets/histogram.js @@ -26,7 +26,7 @@ import chrome from '../../chrome'; import { BucketAggType } from './_bucket_agg_type'; import { createFilterHistogram } from './create_filter/histogram'; import intervalTemplate from '../controls/number_interval.html'; -import minDocCountTemplate from '../controls/min_doc_count.html'; +import { MinDocCountParamEditor } from '../controls/min_doc_count'; import extendedBoundsTemplate from '../controls/extended_bounds.html'; import { i18n } from '@kbn/i18n'; @@ -148,8 +148,8 @@ export const histogramBucketAgg = new BucketAggType({ { name: 'min_doc_count', - default: null, - editor: minDocCountTemplate, + default: false, + editorComponent: MinDocCountParamEditor, write: function (aggConfig, output) { if (aggConfig.params.min_doc_count) { output.params.min_doc_count = 0; diff --git a/src/legacy/ui/public/agg_types/controls/drop_partials.tsx b/src/legacy/ui/public/agg_types/controls/drop_partials.tsx index 7d4c969602df..37c4965b302e 100644 --- a/src/legacy/ui/public/agg_types/controls/drop_partials.tsx +++ b/src/legacy/ui/public/agg_types/controls/drop_partials.tsx @@ -46,7 +46,7 @@ function DropPartialsParamEditor({ agg, aggParam, value, setValue }: AggParamEdi return ( <> - + - - diff --git a/src/legacy/ui/public/agg_types/controls/min_doc_count.tsx b/src/legacy/ui/public/agg_types/controls/min_doc_count.tsx new file mode 100644 index 000000000000..7948d5f34e81 --- /dev/null +++ b/src/legacy/ui/public/agg_types/controls/min_doc_count.tsx @@ -0,0 +1,45 @@ +/* + * 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 React from 'react'; + +import { EuiSpacer, EuiSwitch, EuiToolTip } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { AggParamEditorProps } from 'ui/vis/editors/default'; + +function MinDocCountParamEditor({ value, setValue }: AggParamEditorProps) { + const label = i18n.translate('common.ui.aggTypes.showEmptyBucketsLabel', { + defaultMessage: 'Show empty buckets', + }); + + const content = i18n.translate('common.ui.aggTypes.showEmptyBucketsTooltip', { + defaultMessage: 'Show all buckets, not only the buckets with results', + }); + + return ( +
+ + setValue(ev.target.checked)} /> + + +
+ ); +} + +export { MinDocCountParamEditor };