import { EuiLink } from '@elastic/eui' ; import React from 'react' ; import { APMQueryParams } from '../url_helpers' ; import { APMLinkExtendProps , useAPMHref } from './apm_link' ; import { removeUndefinedProps } from '../../../../context/url_params_context/helpers' ; const persistedFilters = [ 'transactionResult' , 'host' , 'containerId' , 'podName' , 'serviceVersion' , 'latencyAggregationType' , ] ; interface Props extends APMLinkExtendProps { serviceName : string ; environment ? : string ; transactionType ? : string ; } export function useServiceOrTransactionsOverviewHref ( { serviceName , environment , transactionType , } ) { const query = { environment , transactionType } ; return useAPMHref ( { path : `/services/${ serviceName }` , persistedFilters , query : removeUndefinedProps ( query ) , } ) ; } export function ServiceOrTransactionsOverviewLink ( { serviceName , environment , transactionType , ... rest } ) { const href = useServiceOrTransactionsOverviewHref ( { serviceName , environment , transactionType , } ) ; return < EuiLink href = { href } { ... rest } />; }