mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[8.16] [APM] Update onboarding link to use locator with "application" as category parameter (#197780) (#197819)
# Backport This will backport the following commits from `main` to `8.16`: - [[APM] Update onboarding link to use locator with "application" as category parameter (#197780)](https://github.com/elastic/kibana/pull/197780) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Irene Blanco","email":"irene.blanco@elastic.co"},"sourceCommit":{"committedDate":"2024-10-25T12:27:55Z","message":"[APM] Update onboarding link to use locator with \"application\" as category parameter (#197780)\n\n## Summary\r\n\r\nCloses https://github.com/elastic/kibana/issues/197590.\r\n\r\nThis PR addresses an issue with the onboarding link used by the\r\n`addApmData` constant, where the \"Application\" option fails to\r\npreselect. The issue is caused by the URL being incorrectly formed, with\r\nthe category parameter set to `apm` instead of `application`.\r\n\r\nTo resolve this, the PR introduces two main changes:\r\n- Update to use the correct locator\r\n- Modify the category parameter to use `application` instead of `apm`\r\n\r\n|Before|After|\r\n|-|-|\r\n\r\n||","sha":"4798c59158f2bd7dc09bfd07c8ab69bcfb23c0b8","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-infra_services","v8.16.0","v8.17.0"],"title":"[APM] Update onboarding link to use locator with \"application\" as category parameter","number":197780,"url":"https://github.com/elastic/kibana/pull/197780","mergeCommit":{"message":"[APM] Update onboarding link to use locator with \"application\" as category parameter (#197780)\n\n## Summary\r\n\r\nCloses https://github.com/elastic/kibana/issues/197590.\r\n\r\nThis PR addresses an issue with the onboarding link used by the\r\n`addApmData` constant, where the \"Application\" option fails to\r\npreselect. The issue is caused by the URL being incorrectly formed, with\r\nthe category parameter set to `apm` instead of `application`.\r\n\r\nTo resolve this, the PR introduces two main changes:\r\n- Update to use the correct locator\r\n- Modify the category parameter to use `application` instead of `apm`\r\n\r\n|Before|After|\r\n|-|-|\r\n\r\n||","sha":"4798c59158f2bd7dc09bfd07c8ab69bcfb23c0b8"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197780","number":197780,"mergeCommit":{"message":"[APM] Update onboarding link to use locator with \"application\" as category parameter (#197780)\n\n## Summary\r\n\r\nCloses https://github.com/elastic/kibana/issues/197590.\r\n\r\nThis PR addresses an issue with the onboarding link used by the\r\n`addApmData` constant, where the \"Application\" option fails to\r\npreselect. The issue is caused by the URL being incorrectly formed, with\r\nthe category parameter set to `apm` instead of `application`.\r\n\r\nTo resolve this, the PR introduces two main changes:\r\n- Update to use the correct locator\r\n- Modify the category parameter to use `application` instead of `apm`\r\n\r\n|Before|After|\r\n|-|-|\r\n\r\n||","sha":"4798c59158f2bd7dc09bfd07c8ab69bcfb23c0b8"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Irene Blanco <irene.blanco@elastic.co>
This commit is contained in:
parent
14c8a9e2ec
commit
724be35d2d
5 changed files with 95 additions and 44 deletions
|
@ -5,10 +5,13 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import type { ObservabilityOnboardingLocatorParams } from '@kbn/deeplinks-observability';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import type { AddDataPanelProps } from '@kbn/observability-shared-plugin/public';
|
||||
import type { LocatorPublic } from '@kbn/share-plugin/common';
|
||||
import {
|
||||
ApmOnboardingLocatorCategory,
|
||||
ApmOnboardingLocatorParams,
|
||||
} from '../../../locator/onboarding_locator';
|
||||
|
||||
export type AddAPMCalloutKeys =
|
||||
| 'serviceOverview'
|
||||
|
@ -19,13 +22,11 @@ export type AddAPMCalloutKeys =
|
|||
| 'metrics'
|
||||
| 'errorGroupOverview';
|
||||
|
||||
const defaultActions = (
|
||||
locator: LocatorPublic<ObservabilityOnboardingLocatorParams> | undefined
|
||||
) => {
|
||||
const defaultActions = (locator: LocatorPublic<ApmOnboardingLocatorParams> | undefined) => {
|
||||
return {
|
||||
actions: {
|
||||
primary: {
|
||||
href: locator?.getRedirectUrl({ category: 'application' }),
|
||||
href: locator?.getRedirectUrl({ category: ApmOnboardingLocatorCategory.Apm }),
|
||||
label: i18n.translate('xpack.apm.serviceTabEmptyState.defaultPrimaryActionLabel', {
|
||||
defaultMessage: 'Add APM',
|
||||
}),
|
||||
|
@ -42,7 +43,7 @@ const defaultActions = (
|
|||
|
||||
export const addAPMCalloutDefinitions = (
|
||||
baseFolderPath: string,
|
||||
locator: LocatorPublic<ObservabilityOnboardingLocatorParams> | undefined
|
||||
locator: LocatorPublic<ApmOnboardingLocatorParams> | undefined
|
||||
): Record<
|
||||
AddAPMCalloutKeys,
|
||||
Omit<AddDataPanelProps, 'onDismiss' | 'onAddData' | 'onLearnMore' | 'onTryIt'>
|
||||
|
|
|
@ -8,10 +8,8 @@
|
|||
import React from 'react';
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import { AddDataPanel } from '@kbn/observability-shared-plugin/public';
|
||||
import {
|
||||
OBSERVABILITY_ONBOARDING_LOCATOR,
|
||||
ObservabilityOnboardingLocatorParams,
|
||||
} from '@kbn/deeplinks-observability';
|
||||
import { OBSERVABILITY_ONBOARDING_LOCATOR } from '@kbn/deeplinks-observability';
|
||||
import { ApmOnboardingLocatorParams } from '../../../locator/onboarding_locator';
|
||||
import { useApmPluginContext } from '../../../context/apm_plugin/use_apm_plugin_context';
|
||||
import { EmptyStateClickParams, EntityInventoryAddDataParams } from '../../../services/telemetry';
|
||||
import { ApmPluginStartDeps, ApmServices } from '../../../plugin';
|
||||
|
@ -39,7 +37,7 @@ export function ServiceTabEmptyState({ id, onDismiss }: ServiceTabEmptyStateProp
|
|||
|
||||
const { share } = useApmPluginContext();
|
||||
|
||||
const onboardingLocator = share.url.locators.get<ObservabilityOnboardingLocatorParams>(
|
||||
const onboardingLocator = share.url.locators.get<ApmOnboardingLocatorParams>(
|
||||
OBSERVABILITY_ONBOARDING_LOCATOR
|
||||
);
|
||||
|
||||
|
|
|
@ -13,14 +13,16 @@ import {
|
|||
} from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import React, { useState } from 'react';
|
||||
import { OBSERVABILITY_ONBOARDING_LOCATOR } from '@kbn/deeplinks-observability';
|
||||
import { ApmOnboardingLocatorParams } from '../../../../locator/onboarding_locator';
|
||||
import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context';
|
||||
import { useKibana } from '../../../../context/kibana_context/use_kibana';
|
||||
import { ApmPluginStartDeps, ApmServices } from '../../../../plugin';
|
||||
import { EntityInventoryAddDataParams } from '../../../../services/telemetry';
|
||||
import {
|
||||
associateServiceLogs,
|
||||
collectServiceLogs,
|
||||
addApmData,
|
||||
associateServiceLogsProps,
|
||||
collectServiceLogsProps,
|
||||
addApmDataProps,
|
||||
} from '../../../shared/add_data_buttons/buttons';
|
||||
|
||||
const addData = i18n.translate('xpack.apm.addDataContextMenu.link', {
|
||||
|
@ -34,8 +36,17 @@ export function AddDataContextMenu() {
|
|||
core: {
|
||||
http: { basePath },
|
||||
},
|
||||
share: {
|
||||
url: { locators },
|
||||
},
|
||||
} = useApmPluginContext();
|
||||
|
||||
const onboardingLocator = locators.get<ApmOnboardingLocatorParams>(
|
||||
OBSERVABILITY_ONBOARDING_LOCATOR
|
||||
);
|
||||
|
||||
const addApmButtonData = addApmDataProps(onboardingLocator);
|
||||
|
||||
const button = (
|
||||
<EuiHeaderLink
|
||||
color="text"
|
||||
|
@ -61,8 +72,8 @@ export function AddDataContextMenu() {
|
|||
title: addData,
|
||||
items: [
|
||||
{
|
||||
name: associateServiceLogs.name,
|
||||
href: associateServiceLogs.link,
|
||||
name: associateServiceLogsProps.name,
|
||||
href: associateServiceLogsProps.link,
|
||||
'data-test-subj': 'apmAddDataAssociateServiceLogs',
|
||||
target: '_blank',
|
||||
onClick: () => {
|
||||
|
@ -70,22 +81,26 @@ export function AddDataContextMenu() {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: collectServiceLogs.name,
|
||||
href: basePath.prepend(collectServiceLogs.link),
|
||||
name: collectServiceLogsProps.name,
|
||||
href: basePath.prepend(collectServiceLogsProps.link),
|
||||
'data-test-subj': 'apmAddDataCollectServiceLogs',
|
||||
onClick: () => {
|
||||
reportButtonClick('collect_new_service_logs');
|
||||
},
|
||||
},
|
||||
{
|
||||
name: addApmData.name,
|
||||
href: basePath.prepend(addApmData.link),
|
||||
icon: 'plusInCircle',
|
||||
'data-test-subj': 'apmAddDataApmAgent',
|
||||
onClick: () => {
|
||||
reportButtonClick('add_apm_agent');
|
||||
},
|
||||
},
|
||||
...(addApmButtonData.link
|
||||
? [
|
||||
{
|
||||
name: addApmButtonData.name,
|
||||
href: addApmButtonData.link,
|
||||
icon: 'plusInCircle',
|
||||
'data-test-subj': 'apmAddDataApmAgent',
|
||||
onClick: () => {
|
||||
reportButtonClick('add_apm_agent');
|
||||
},
|
||||
},
|
||||
]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
];
|
||||
|
|
|
@ -11,23 +11,31 @@
|
|||
import { EuiButton, EuiButtonSize } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import React from 'react';
|
||||
import { OBSERVABILITY_ONBOARDING_LOCATOR } from '@kbn/deeplinks-observability';
|
||||
import { LocatorPublic } from '@kbn/share-plugin/common';
|
||||
import { useApmPluginContext } from '../../../context/apm_plugin/use_apm_plugin_context';
|
||||
import {
|
||||
ApmOnboardingLocatorCategory,
|
||||
ApmOnboardingLocatorParams,
|
||||
} from '../../../locator/onboarding_locator';
|
||||
|
||||
export const addApmData = {
|
||||
name: i18n.translate('xpack.apm.add.apm.agent.button.', {
|
||||
defaultMessage: 'Add APM',
|
||||
}),
|
||||
link: '/app/observabilityOnboarding/?category=apm',
|
||||
export const addApmDataProps = (locator: LocatorPublic<ApmOnboardingLocatorParams> | undefined) => {
|
||||
return {
|
||||
name: i18n.translate('xpack.apm.add.apm.agent.button.', {
|
||||
defaultMessage: 'Add APM',
|
||||
}),
|
||||
link: locator?.getRedirectUrl({ category: ApmOnboardingLocatorCategory.Apm }),
|
||||
};
|
||||
};
|
||||
|
||||
export const associateServiceLogs = {
|
||||
export const associateServiceLogsProps = {
|
||||
name: i18n.translate('xpack.apm.associate.service.logs.button', {
|
||||
defaultMessage: 'Associate existing service logs',
|
||||
}),
|
||||
link: 'https://ela.st/new-experience-associate-service-logs',
|
||||
};
|
||||
|
||||
export const collectServiceLogs = {
|
||||
export const collectServiceLogsProps = {
|
||||
name: i18n.translate('xpack.apm.collect.service.logs.button', {
|
||||
defaultMessage: 'Collect new service logs',
|
||||
}),
|
||||
|
@ -42,18 +50,31 @@ interface AddApmDataProps {
|
|||
}
|
||||
|
||||
export function AddApmData({ fill = false, size = 's', ...props }: AddApmDataProps) {
|
||||
const { core } = useApmPluginContext();
|
||||
const { basePath } = core.http;
|
||||
const {
|
||||
share: {
|
||||
url: { locators },
|
||||
},
|
||||
} = useApmPluginContext();
|
||||
|
||||
const onboardingLocator = locators.get<ApmOnboardingLocatorParams>(
|
||||
OBSERVABILITY_ONBOARDING_LOCATOR
|
||||
);
|
||||
|
||||
const addApmDataButtonProps = addApmDataProps(onboardingLocator);
|
||||
|
||||
if (!addApmDataButtonProps.link) {
|
||||
return;
|
||||
}
|
||||
|
||||
return (
|
||||
<EuiButton
|
||||
data-test-subj={props['data-test-subj']}
|
||||
size={size}
|
||||
onClick={props.onClick}
|
||||
href={basePath.prepend(addApmData.link)}
|
||||
href={addApmDataButtonProps?.link}
|
||||
fill={fill}
|
||||
>
|
||||
{addApmData.name}
|
||||
{addApmDataButtonProps.name}
|
||||
</EuiButton>
|
||||
);
|
||||
}
|
||||
|
@ -61,15 +82,15 @@ export function AddApmData({ fill = false, size = 's', ...props }: AddApmDataPro
|
|||
export function AssociateServiceLogs({ onClick }: { onClick?: () => void }) {
|
||||
return (
|
||||
<EuiButton
|
||||
data-test-subj="associateServiceLogsButton"
|
||||
data-test-subj="associateServiceLogsPropsButton"
|
||||
size="s"
|
||||
onClick={onClick}
|
||||
href={associateServiceLogs.link}
|
||||
href={associateServiceLogsProps.link}
|
||||
target="_blank"
|
||||
iconType="popout"
|
||||
iconSide="right"
|
||||
>
|
||||
{associateServiceLogs.name}
|
||||
{associateServiceLogsProps.name}
|
||||
</EuiButton>
|
||||
);
|
||||
}
|
||||
|
@ -80,12 +101,12 @@ export function CollectServiceLogs({ onClick }: { onClick?: () => void }) {
|
|||
|
||||
return (
|
||||
<EuiButton
|
||||
data-test-subj="collectServiceLogsButton"
|
||||
data-test-subj="collectServiceLogsPropsButton"
|
||||
size="s"
|
||||
onClick={onClick}
|
||||
href={basePath.prepend(collectServiceLogs.link)}
|
||||
href={basePath.prepend(collectServiceLogsProps.link)}
|
||||
>
|
||||
{collectServiceLogs.name}
|
||||
{collectServiceLogsProps.name}
|
||||
</EuiButton>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { ObservabilityOnboardingLocatorParams } from '@kbn/deeplinks-observability';
|
||||
|
||||
export enum ApmOnboardingLocatorCategory {
|
||||
Apm = 'application',
|
||||
}
|
||||
|
||||
export interface ApmOnboardingLocatorParams extends ObservabilityOnboardingLocatorParams {
|
||||
category: ApmOnboardingLocatorCategory;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue