import React , { useEffect , useRef } from 'react' ; import { i18n } from '@osd/i18n' ; import { search } from '../../../../data/public' ; import { SwitchParamEditor } from './switch' ; import { AggParamEditorProps } from '../agg_param_props' ; const { isType } = search . aggs ; function HasExtendedBoundsParamEditor ( props ) { const { agg , setValue , value } = props ; const minDocCount = useRef ( agg . params . min_doc_count ) ; useEffect ( ( ) => { if ( minDocCount . current !== agg . params . min_doc_count ) { minDocCount . current = agg . params . min_doc_count ; setValue ( value && agg . params . min_doc_count ) ; } } , [ agg . params . min_doc_count , setValue , value ] ) ; return ( < SwitchParamEditor { ... props } displayLabel = { i18n . translate ( 'visDefaultEditor.controls.extendedBoundsLabel' , { defaultMessage : 'Extend bounds' , } ) } displayToolTip = { i18n . translate ( 'visDefaultEditor.controls.extendedBoundsTooltip' , { defaultMessage : 'Min and Max do not filter the results, but rather extend the bounds of the result set.' , } ) } disabled = { ! props . agg . params . min_doc_count || ! ( isType ( 'number' ) ( props . agg ) || isType ( 'date' ) ( props . agg ) ) } />); } export { HasExtendedBoundsParamEditor } ;