[Infra] fix serverless link (#178728)

## Summary

Closes https://github.com/elastic/kibana/issues/178645

Introduced in https://github.com/elastic/kibana/pull/176539, the link
for the user to take further action is pointing to a page that does not
exist in serverless. This updates the link depending on the environment.
It will continue to point the link to the apm tutorial
(`/app/home#/tutorial/apm`) in non serverless and point to onboarding in
serverless (`/app/apm/onboarding`)

<img width="862" alt="Screenshot 2024-03-14 at 9 39 26 AM"
src="cce07e8e-13da-4deb-8edb-3ecca4991d75">
This commit is contained in:
Sandra G 2024-03-14 11:45:48 -04:00 committed by GitHub
parent bc4f656893
commit c62a19d883
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -17,6 +17,7 @@ import { HOST_FIELD } from '../../../../../common/constants';
import { LinkToApmServices } from '../../links';
import { APM_HOST_FILTER_FIELD } from '../../constants';
import { LinkToApmService } from '../../links/link_to_apm_service';
import { useKibanaEnvironmentContext } from '../../../../hooks/use_kibana';
export const ServicesContent = ({
hostName,
@ -25,10 +26,15 @@ export const ServicesContent = ({
hostName: string;
dateRange: TimeRange;
}) => {
const { isServerlessEnv } = useKibanaEnvironmentContext();
const linkProps = useLinkProps({
app: 'home',
hash: '/tutorial/apm',
});
const serverlessLinkProps = useLinkProps({
app: 'apm',
pathname: '/onboarding',
});
const params = useMemo(
() => ({
filters: { [HOST_FIELD]: hostName },
@ -87,7 +93,10 @@ export const ServicesContent = ({
defaultMessage="No services found on this host. Click {apmTutorialLink} to instrument your services with APM."
values={{
apmTutorialLink: (
<EuiLink data-test-subj="assetDetailsTooltiAPMTutorialLink" href={linkProps.href}>
<EuiLink
data-test-subj="assetDetailsTooltiAPMTutorialLink"
href={isServerlessEnv ? serverlessLinkProps.href : linkProps.href}
>
<FormattedMessage
id="xpack.infra.assetDetails.table.services.noServices.tutorialLink"
defaultMessage="here"