import { i18n } from '@kbn/i18n' ; import type { ChromeRecentlyAccessed } from 'kibana/public' ; import { getRecentlyAccessed } from './dependency_cache' ; export function addItemToRecentlyAccessed ( page , itemId , url , recentlyAccessedService ? ) { let pageLabel = '' ; let id = `ml-job-${ itemId }` ; switch ( page ) { case 'explorer' : pageLabel = i18n . translate ( 'xpack.ml.anomalyExplorerPageLabel' , { defaultMessage : 'Anomaly Explorer' , } ) ; break ; case 'timeseriesexplorer' : pageLabel = i18n . translate ( 'xpack.ml.singleMetricViewerPageLabel' , { defaultMessage : 'Single Metric Viewer' , } ) ; break ; case 'jobs/new_job/datavisualizer' : pageLabel = i18n . translate ( 'xpack.ml.dataVisualizerPageLabel' , { defaultMessage : 'Data Visualizer' , } ) ; id = `ml-datavisualizer-${ itemId }` ; break ; default : console . error ( 'addItemToRecentlyAccessed - No page specified' ) ; return ; } const recentlyAccessed = recentlyAccessedService ?? getRecentlyAccessed ( ) ; recentlyAccessed . add ( url , `ML - ${ itemId } - ${ pageLabel }` , id ) ; }