diff --git a/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.test.tsx b/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.test.tsx index a4798e3..d98b9a9 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.test.tsx +++ b/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.test.tsx @@ -10,47 +10,10 @@ import { defaultBucketAgg } from '../../../queryDef'; import { ElasticsearchQuery } from '../../../types'; import { ElasticsearchProvider } from '../ElasticsearchQueryContext'; -import { Average, Count, UniqueCount } from './../../../types'; +import { Count, UniqueCount } from './../../../types'; import { MetricEditor } from './MetricEditor'; describe('Metric Editor', () => { - it('Should display a "None" option for "field" if the metric supports inline script', async () => { - const avg: Average = { - id: '1', - type: 'avg', - }; - - const query: ElasticsearchQuery = { - refId: 'A', - query: '', - metrics: [avg], - bucketAggs: [defaultBucketAgg('2')], - }; - - const getFields: ElasticDatasource['getFields'] = jest.fn(() => from([[]])); - - const wrapper = ({ children }: PropsWithChildren<{}>) => ( - {}} - onRunQuery={() => {}} - > - {children} - - ); - - render(, { wrapper }); - - act(() => { - fireEvent.click(screen.getByText('Select Field')); - }); - - expect(await screen.findByText('None')).toBeInTheDocument(); - }); - it('Should not display a "None" option for "field" if the metric does not support inline script', async () => { const avg: UniqueCount = { id: '1', diff --git a/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.tsx b/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.tsx index e64be88..b63f319 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.tsx +++ b/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.tsx @@ -15,10 +15,9 @@ import { segmentStyles } from '../styles'; import { SettingsEditor } from './SettingsEditor'; import { isMetricAggregationWithField, - isMetricAggregationWithInlineScript, isMetricAggregationWithSettings, isPipelineAggregation, - isPipelineAggregationWithMultipleBucketPaths, + isPipelineAggregationWithMultipleBucketPaths } from './aggregations'; import { changeMetricField, changeMetricType } from './state/actions'; import { getStyles } from './styles'; @@ -64,13 +63,8 @@ export const MetricEditor = ({ value }: Props) => { const loadOptions = useCallback(async () => { const remoteFields = await getFields(); - // Metric aggregations that have inline script support don't require a field to be set. - if (isMetricAggregationWithInlineScript(value)) { - return [{ label: 'None' }, ...remoteFields]; - } - return remoteFields; - }, [getFields, value]); + }, [getFields]); const previousMetrics = query.metrics!.slice( 0, diff --git a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.tsx b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.tsx index 82b9111..e7317da 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.tsx +++ b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.tsx @@ -7,7 +7,7 @@ import { extendedStats } from '../../../../queryDef'; import { MetricAggregation, ExtendedStat } from '../../../../types'; import { useQuery } from '../../ElasticsearchQueryContext'; import { SettingsEditorContainer } from '../../SettingsEditorContainer'; -import { isMetricAggregationWithInlineScript, isMetricAggregationWithMissingSupport } from '../aggregations'; +import { isMetricAggregationWithMissingSupport } from '../aggregations'; import { changeMetricMeta, changeMetricSetting } from '../state/actions'; import { metricAggregationConfig } from '../utils'; @@ -152,10 +152,6 @@ export const SettingsEditor = ({ metric, previousMetrics }: Props) => { )} - {isMetricAggregationWithInlineScript(metric) && ( - - )} - {isMetricAggregationWithMissingSupport(metric) && ( metricAggregationConfig[metric.type].hasMeta; -export const isMetricAggregationWithInlineScript = ( - metric: BaseMetricAggregation | MetricAggregationWithInlineScript -): metric is MetricAggregationWithInlineScript => metricAggregationConfig[metric.type].supportsInlineScript; - export const METRIC_AGGREGATION_TYPES: MetricAggregationType[] = [ 'count', 'avg',