File tree Expand file tree Collapse file tree 3 files changed +3
-51
lines changed
src/components/QueryEditor/MetricAggregationsEditor Expand file tree Collapse file tree 3 files changed +3
-51
lines changed Original file line number Diff line number Diff line change @@ -10,47 +10,10 @@ import { defaultBucketAgg } from '../../../queryDef';
1010import { ElasticsearchQuery } from '../../../types' ;
1111import { ElasticsearchProvider } from '../ElasticsearchQueryContext' ;
1212
13- import { Average , Count , UniqueCount } from './../../../types' ;
13+ import { Count , UniqueCount } from './../../../types' ;
1414import { MetricEditor } from './MetricEditor' ;
1515
1616describe ( 'Metric Editor' , ( ) => {
17- it ( 'Should display a "None" option for "field" if the metric supports inline script' , async ( ) => {
18- const avg : Average = {
19- id : '1' ,
20- type : 'avg' ,
21- } ;
22-
23- const query : ElasticsearchQuery = {
24- refId : 'A' ,
25- query : '' ,
26- metrics : [ avg ] ,
27- bucketAggs : [ defaultBucketAgg ( '2' ) ] ,
28- } ;
29-
30- const getFields : ElasticDatasource [ 'getFields' ] = jest . fn ( ( ) => from ( [ [ ] ] ) ) ;
31-
32- const wrapper = ( { children } : PropsWithChildren < { } > ) => (
33- < ElasticsearchProvider
34- datasource = { { getFields } as ElasticDatasource }
35- query = { query }
36- app = { undefined }
37- range = { getDefaultTimeRange ( ) }
38- onChange = { ( ) => { } }
39- onRunQuery = { ( ) => { } }
40- >
41- { children }
42- </ ElasticsearchProvider >
43- ) ;
44-
45- render ( < MetricEditor value = { avg } /> , { wrapper } ) ;
46-
47- act ( ( ) => {
48- fireEvent . click ( screen . getByText ( 'Select Field' ) ) ;
49- } ) ;
50-
51- expect ( await screen . findByText ( 'None' ) ) . toBeInTheDocument ( ) ;
52- } ) ;
53-
5417 it ( 'Should not display a "None" option for "field" if the metric does not support inline script' , async ( ) => {
5518 const avg : UniqueCount = {
5619 id : '1' ,
Original file line number Diff line number Diff line change @@ -15,10 +15,9 @@ import { segmentStyles } from '../styles';
1515import { SettingsEditor } from './SettingsEditor' ;
1616import {
1717 isMetricAggregationWithField ,
18- isMetricAggregationWithInlineScript ,
1918 isMetricAggregationWithSettings ,
2019 isPipelineAggregation ,
21- isPipelineAggregationWithMultipleBucketPaths ,
20+ isPipelineAggregationWithMultipleBucketPaths
2221} from './aggregations' ;
2322import { changeMetricField , changeMetricType } from './state/actions' ;
2423import { getStyles } from './styles' ;
@@ -64,13 +63,8 @@ export const MetricEditor = ({ value }: Props) => {
6463 const loadOptions = useCallback ( async ( ) => {
6564 const remoteFields = await getFields ( ) ;
6665
67- // Metric aggregations that have inline script support don't require a field to be set.
68- if ( isMetricAggregationWithInlineScript ( value ) ) {
69- return [ { label : 'None' } , ...remoteFields ] ;
70- }
71-
7266 return remoteFields ;
73- } , [ getFields , value ] ) ;
67+ } , [ getFields ] ) ;
7468
7569 const previousMetrics = query . metrics ! . slice (
7670 0 ,
Original file line number Diff line number Diff line change 66 BaseMetricAggregation ,
77 MetricAggregationWithField ,
88 MetricAggregationWithMissingSupport ,
9- MetricAggregationWithInlineScript ,
109 PipelineMetricAggregation ,
1110 MetricAggregationWithSettings ,
1211} from '../../../types' ;
@@ -62,10 +61,6 @@ export const isMetricAggregationWithMeta = (
6261 metric : BaseMetricAggregation | MetricAggregationWithMeta
6362) : metric is MetricAggregationWithMeta => metricAggregationConfig [ metric . type ] . hasMeta ;
6463
65- export const isMetricAggregationWithInlineScript = (
66- metric : BaseMetricAggregation | MetricAggregationWithInlineScript
67- ) : metric is MetricAggregationWithInlineScript => metricAggregationConfig [ metric . type ] . supportsInlineScript ;
68-
6964export const METRIC_AGGREGATION_TYPES : MetricAggregationType [ ] = [
7065 'count' ,
7166 'avg' ,
You can’t perform that action at this time.
0 commit comments