import { useEffect } from 'react' ; import { useMlKibana } from './kibana_context' ; interface UseTimefilterOptions { timeRangeSelector ? : boolean ; autoRefreshSelector ? : boolean ; } export const useTimefilter = ( { timeRangeSelector , autoRefreshSelector , } = { } ) => { const { services } = useMlKibana ( ) ; const { timefilter } = services . data . query . timefilter ; useEffect ( ( ) => { if ( timeRangeSelector === true ) { timefilter . enableTimeRangeSelector ( ) ; } else if ( timeRangeSelector === false ) { timefilter . disableTimeRangeSelector ( ) ; } if ( autoRefreshSelector === true ) { timefilter . enableAutoRefreshSelector ( ) ; } else if ( autoRefreshSelector === false ) { timefilter . disableAutoRefreshSelector ( ) ; } } , [ timeRangeSelector , autoRefreshSelector ] ) ; return timefilter ; } ;