@@ -25,6 +25,7 @@ import {
25
25
import { useHistory , useLocation } from 'react-router-dom' ;
26
26
import { CoreStart } from 'opensearch-dashboards/public' ;
27
27
import { QUERY_INSIGHTS , MetricSettings , GroupBySettings } from '../TopNQueries/TopNQueries' ;
28
+ import { METRIC_TYPES , TIME_UNITS , MINUTES_OPTIONS , GROUP_BY_OPTIONS } from '../Utils/Constants' ;
28
29
29
30
const Configuration = ( {
30
31
latencySettings,
@@ -41,29 +42,6 @@ const Configuration = ({
41
42
configInfo : any ;
42
43
core : CoreStart ;
43
44
} ) => {
44
- const metricTypes = [
45
- { value : 'latency' , text : 'Latency' } ,
46
- { value : 'cpu' , text : 'CPU' } ,
47
- { value : 'memory' , text : 'Memory' } ,
48
- ] ;
49
-
50
- const timeUnits = [
51
- { value : 'MINUTES' , text : 'Minute(s)' } ,
52
- { value : 'HOURS' , text : 'Hour(s)' } ,
53
- ] ;
54
-
55
- const minutesOptions = [
56
- { value : '1' , text : '1' } ,
57
- { value : '5' , text : '5' } ,
58
- { value : '10' , text : '10' } ,
59
- { value : '30' , text : '30' } ,
60
- ] ;
61
-
62
- const groupByOptions = [
63
- { value : 'none' , text : 'None' } ,
64
- { value : 'similarity' , text : 'Similarity' } ,
65
- ] ;
66
-
67
45
const history = useHistory ( ) ;
68
46
const location = useLocation ( ) ;
69
47
@@ -147,7 +125,7 @@ const Configuration = ({
147
125
< EuiSelect
148
126
id = "minutes"
149
127
required = { true }
150
- options = { minutesOptions }
128
+ options = { MINUTES_OPTIONS }
151
129
value = { windowSize }
152
130
onChange = { onWindowSizeChange }
153
131
/>
@@ -163,7 +141,7 @@ const Configuration = ({
163
141
/>
164
142
) ;
165
143
166
- const WindowChoice = time === timeUnits [ 0 ] . value ? MinutesBox : HoursBox ;
144
+ const WindowChoice = time === TIME_UNITS [ 0 ] . value ? MinutesBox : HoursBox ;
167
145
168
146
const isChanged =
169
147
isEnabled !== metricSettingsMap [ metric ] . isEnabled ||
@@ -175,7 +153,7 @@ const Configuration = ({
175
153
const isValid = ( ( ) => {
176
154
const nVal = parseInt ( topNSize , 10 ) ;
177
155
if ( nVal < 1 || nVal > 100 ) return false ;
178
- if ( time === timeUnits [ 0 ] . value ) return true ;
156
+ if ( time === TIME_UNITS [ 0 ] . value ) return true ;
179
157
const windowVal = parseInt ( windowSize , 10 ) ;
180
158
return windowVal >= 1 && windowVal <= 24 ;
181
159
} ) ( ) ;
@@ -213,7 +191,7 @@ const Configuration = ({
213
191
< EuiSelect
214
192
id = "metricType"
215
193
required = { true }
216
- options = { metricTypes }
194
+ options = { METRIC_TYPES }
217
195
value = { metric }
218
196
onChange = { onMetricChange }
219
197
/>
@@ -283,7 +261,7 @@ const Configuration = ({
283
261
< EuiSelect
284
262
id = "timeUnit"
285
263
required = { isEnabled }
286
- options = { timeUnits }
264
+ options = { TIME_UNITS }
287
265
value = { time }
288
266
onChange = { onTimeChange }
289
267
/>
@@ -365,7 +343,7 @@ const Configuration = ({
365
343
< EuiSelect
366
344
id = "groupBy"
367
345
required = { true }
368
- options = { groupByOptions }
346
+ options = { GROUP_BY_OPTIONS }
369
347
value = { groupBy }
370
348
onChange = { onGroupByChange }
371
349
/>
0 commit comments