[8.13] [Infra] fix serverless link (#178728) (#178749)

# Backport

This will backport the following commits from `main` to `8.13`:
- [[Infra] fix serverless link
(#178728)](https://github.com/elastic/kibana/pull/178728)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Sandra
G","email":"neptunian@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-03-14T15:45:48Z","message":"[Infra]
fix serverless link (#178728)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/178645\r\n\r\nIntroduced in
https://github.com/elastic/kibana/pull/176539, the link\r\nfor the user
to take further action is pointing to a page that does not\r\nexist in
serverless. This updates the link depending on the environment.\r\nIt
will continue to point the link to the apm
tutorial\r\n(`/app/home#/tutorial/apm`) in non serverless and point to
onboarding in\r\nserverless (`/app/apm/onboarding`)\r\n\r\n<img
width=\"862\" alt=\"Screenshot 2024-03-14 at 9 39
26 AM\"\r\nsrc=\"cce07e8e-13da-4deb-8edb-3ecca4991d75\">","sha":"c62a19d8837fd62c989a0481243c1cdb8869db3a","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:obs-ux-infra_services","v8.13.0","v8.14.0"],"title":"[Infra]
fix serverless
link","number":178728,"url":"https://github.com/elastic/kibana/pull/178728","mergeCommit":{"message":"[Infra]
fix serverless link (#178728)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/178645\r\n\r\nIntroduced in
https://github.com/elastic/kibana/pull/176539, the link\r\nfor the user
to take further action is pointing to a page that does not\r\nexist in
serverless. This updates the link depending on the environment.\r\nIt
will continue to point the link to the apm
tutorial\r\n(`/app/home#/tutorial/apm`) in non serverless and point to
onboarding in\r\nserverless (`/app/apm/onboarding`)\r\n\r\n<img
width=\"862\" alt=\"Screenshot 2024-03-14 at 9 39
26 AM\"\r\nsrc=\"cce07e8e-13da-4deb-8edb-3ecca4991d75\">","sha":"c62a19d8837fd62c989a0481243c1cdb8869db3a"}},"sourceBranch":"main","suggestedTargetBranches":["8.13"],"targetPullRequestStates":[{"branch":"8.13","label":"v8.13.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/178728","number":178728,"mergeCommit":{"message":"[Infra]
fix serverless link (#178728)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/178645\r\n\r\nIntroduced in
https://github.com/elastic/kibana/pull/176539, the link\r\nfor the user
to take further action is pointing to a page that does not\r\nexist in
serverless. This updates the link depending on the environment.\r\nIt
will continue to point the link to the apm
tutorial\r\n(`/app/home#/tutorial/apm`) in non serverless and point to
onboarding in\r\nserverless (`/app/apm/onboarding`)\r\n\r\n<img
width=\"862\" alt=\"Screenshot 2024-03-14 at 9 39
26 AM\"\r\nsrc=\"cce07e8e-13da-4deb-8edb-3ecca4991d75\">","sha":"c62a19d8837fd62c989a0481243c1cdb8869db3a"}}]}]
BACKPORT-->

---------

Co-authored-by: Sandra G <neptunian@users.noreply.github.com>
Co-authored-by: neptunian <sandra.gonzales@elastic.co>
This commit is contained in:
Kibana Machine 2024-03-14 16:36:31 -04:00 committed by GitHub
parent 41e313ed78
commit c7ba73a309
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 2 deletions

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"

View file

@ -6,7 +6,7 @@
*/
import type { PropsOf } from '@elastic/eui';
import React, { useMemo, createElement, createContext } from 'react';
import React, { useMemo, createElement, createContext, useContext } from 'react';
import { CoreStart } from '@kbn/core/public';
import {
createKibanaReactContext,
@ -73,6 +73,10 @@ export const useKibanaEnvironmentContextProvider = (kibanaEnvironment?: KibanaEn
return Provider;
};
export function useKibanaEnvironmentContext() {
return useContext(KibanaEnvironmentContext);
}
export const createLazyComponentWithKibanaContext = <T extends React.ComponentType<any>>(
coreSetup: InfraClientCoreSetup,
lazyComponentFactory: () => Promise<{ default: T }>