import React from 'react' ; import { i18n } from '@kbn/i18n' ; import { EuiSuperSelect } from '@elastic/eui' ; import { useSeriesStorage } from '../../hooks/use_series_storage' ; import { OperationType } from '../../../../../../../lens/public' ; import { SeriesUrl } from '../../types' ; export function OperationTypeSelect ( { seriesId , series , defaultOperationType , } ) { const { setSeries } = useSeriesStorage ( ) ; const operationType = series ?. operationType ; const onChange = ( value ) => { setSeries ( seriesId , { ... series , operationType : value } ) ; } ; return ( < OperationTypeComponent onChange = { onChange } operationType = { operationType || defaultOperationType } />); } export function OperationTypeComponent ( { operationType , onChange , } ) { const options = [ { value : 'average' as OperationType , inputDisplay : i18n . translate ( 'xpack.observability.expView.operationType.average' , { defaultMessage : 'Average' , } ) , } , { value : 'median' as OperationType , inputDisplay : i18n . translate ( 'xpack.observability.expView.operationType.median' , { defaultMessage : 'Median' , } ) , } , { value : 'sum' as OperationType , inputDisplay : i18n . translate ( 'xpack.observability.expView.operationType.sum' , { defaultMessage : 'Sum' , } ) , } , { value : 'last_value' as OperationType , inputDisplay : i18n . translate ( 'xpack.observability.expView.operationType.lastValue' , { defaultMessage : 'Last value' , } ) , } , { value : '75th' as OperationType , inputDisplay : i18n . translate ( 'xpack.observability.expView.operationType.75thPercentile' , { defaultMessage : '75th Percentile' , } ) , } , { value : '90th' as OperationType , inputDisplay : i18n . translate ( 'xpack.observability.expView.operationType.90thPercentile' , { defaultMessage : '90th Percentile' , } ) , } , { value : '95th' as OperationType , inputDisplay : i18n . translate ( 'xpack.observability.expView.operationType.95thPercentile' , { defaultMessage : '95th Percentile' , } ) , } , { value : '99th' as OperationType , inputDisplay : i18n . translate ( 'xpack.observability.expView.operationType.99thPercentile' , { defaultMessage : '99th Percentile' , } ) , } , ] ; return ( < EuiSuperSelect fullWidth data - test - subj = "operationTypeSelect" valueOfSelected = { operationType } options = { options } onChange = { onChange } / > ) ; }