import { UI_SETTINGS } from '../../../../../src/plugins/data/public' ; import { ML_PAGES , useMlHref } from '../../../ml/public' ; import { TimePickerRefreshInterval } from '../components/shared/date_picker/typings' ; import { useApmPluginContext } from '../context/apm_plugin/use_apm_plugin_context' ; import { useLegacyUrlParams } from '../context/url_params_context/use_url_params' ; export function useMlManageJobsHref ( { jobId } = { } ) { const { core , plugins : { ml } , } = useApmPluginContext ( ) ; const { urlParams } = useLegacyUrlParams ( ) ; const timePickerRefreshIntervalDefaults = core . uiSettings . get < TimePickerRefreshInterval > ( UI_SETTINGS . TIMEPICKER_REFRESH_INTERVAL_DEFAULTS ) ; const { rangeFrom = 'now-1h' , rangeTo = 'now' , refreshInterval = timePickerRefreshIntervalDefaults . value , refreshPaused = timePickerRefreshIntervalDefaults . pause , } = urlParams ; const mlADLink = useMlHref ( ml , core . http . basePath . get ( ) , { page : ML_PAGES . ANOMALY_DETECTION_JOBS_MANAGE , pageState : { groupIds : [ 'apm' ] , jobId , globalState : { time : { from : rangeFrom , to : rangeTo } , refreshInterval : { pause : refreshPaused , value : refreshInterval } , } , } , } ) ; return mlADLink ; }