File tree 3 files changed +3
-51
lines changed
src/components/QueryEditor/MetricAggregationsEditor
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';
10
10
import { ElasticsearchQuery } from '../../../types' ;
11
11
import { ElasticsearchProvider } from '../ElasticsearchQueryContext' ;
12
12
13
- import { Average , Count , UniqueCount } from './../../../types' ;
13
+ import { Count , UniqueCount } from './../../../types' ;
14
14
import { MetricEditor } from './MetricEditor' ;
15
15
16
16
describe ( '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
-
54
17
it ( 'Should not display a "None" option for "field" if the metric does not support inline script' , async ( ) => {
55
18
const avg : UniqueCount = {
56
19
id : '1' ,
Original file line number Diff line number Diff line change @@ -15,10 +15,9 @@ import { segmentStyles } from '../styles';
15
15
import { SettingsEditor } from './SettingsEditor' ;
16
16
import {
17
17
isMetricAggregationWithField ,
18
- isMetricAggregationWithInlineScript ,
19
18
isMetricAggregationWithSettings ,
20
19
isPipelineAggregation ,
21
- isPipelineAggregationWithMultipleBucketPaths ,
20
+ isPipelineAggregationWithMultipleBucketPaths
22
21
} from './aggregations' ;
23
22
import { changeMetricField , changeMetricType } from './state/actions' ;
24
23
import { getStyles } from './styles' ;
@@ -64,13 +63,8 @@ export const MetricEditor = ({ value }: Props) => {
64
63
const loadOptions = useCallback ( async ( ) => {
65
64
const remoteFields = await getFields ( ) ;
66
65
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
-
72
66
return remoteFields ;
73
- } , [ getFields , value ] ) ;
67
+ } , [ getFields ] ) ;
74
68
75
69
const previousMetrics = query . metrics ! . slice (
76
70
0 ,
Original file line number Diff line number Diff line change 6
6
BaseMetricAggregation ,
7
7
MetricAggregationWithField ,
8
8
MetricAggregationWithMissingSupport ,
9
- MetricAggregationWithInlineScript ,
10
9
PipelineMetricAggregation ,
11
10
MetricAggregationWithSettings ,
12
11
} from '../../../types' ;
@@ -62,10 +61,6 @@ export const isMetricAggregationWithMeta = (
62
61
metric : BaseMetricAggregation | MetricAggregationWithMeta
63
62
) : metric is MetricAggregationWithMeta => metricAggregationConfig [ metric . type ] . hasMeta ;
64
63
65
- export const isMetricAggregationWithInlineScript = (
66
- metric : BaseMetricAggregation | MetricAggregationWithInlineScript
67
- ) : metric is MetricAggregationWithInlineScript => metricAggregationConfig [ metric . type ] . supportsInlineScript ;
68
-
69
64
export const METRIC_AGGREGATION_TYPES : MetricAggregationType [ ] = [
70
65
'count' ,
71
66
'avg' ,
You can’t perform that action at this time.
0 commit comments