import { QueryStart , SavedQuery } from '../../../query' ; export const populateStateFromSavedQuery = ( queryService , savedQuery ) => { const { timefilter : { timefilter } , filterManager , queryString , } = queryService ; if ( savedQuery . attributes . timefilter ) { timefilter . setTime ( { from : savedQuery . attributes . timefilter . from , to : savedQuery . attributes . timefilter . to , } ) ; if ( savedQuery . attributes . timefilter . refreshInterval ) { timefilter . setRefreshInterval ( savedQuery . attributes . timefilter . refreshInterval ) ; } } queryString . setQuery ( savedQuery . attributes . query ) ; const savedQueryFilters = savedQuery . attributes . filters || [ ] ; const globalFilters = filterManager . getGlobalFilters ( ) ; filterManager . setFilters ( [ ... globalFilters , ... savedQueryFilters ] ) ; } ;