chore: rename getApmHref to getLegacyApmHref (#115689)
* chore: rename getApmHref to getLegacyApmHref * chore: lint Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
d7f202937f
commit
8d195db519
13 changed files with 39 additions and 31 deletions
|
@ -69,7 +69,7 @@ const serviceOverviewLink = apmRouter.link('/services/:serviceName', { path: { s
|
|||
|
||||
If you're not in React context, you can also import `apmRouter` directly and call its `link` function - but you have to prepend the basePath manually in that case.
|
||||
|
||||
We also have the [`getAPMHref` function and `APMLink` component](../public/components/shared/Links/apm/APMLink.tsx), but we should consider them deprecated, in favor of `router.link`. Other components inside that directory contain other functions and components that provide the same functionality for linking to more specific sections inside the APM plugin.
|
||||
We also have the [`getLegacyApmHref` function and `APMLink` component](../public/components/shared/Links/apm/APMLink.tsx), but we should consider them deprecated, in favor of `router.link`. Other components inside that directory contain other functions and components that provide the same functionality for linking to more specific sections inside the APM plugin.
|
||||
|
||||
### Cross-app linking
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import { euiStyled } from '../../../../../../../src/plugins/kibana_react/common'
|
|||
import { useApmPluginContext } from '../../../context/apm_plugin/use_apm_plugin_context';
|
||||
import { useTheme } from '../../../hooks/use_theme';
|
||||
import { useUrlParams } from '../../../context/url_params_context/use_url_params';
|
||||
import { getAPMHref } from '../../shared/Links/apm/APMLink';
|
||||
import { getLegacyApmHref } from '../../shared/Links/apm/APMLink';
|
||||
import { APMQueryParams } from '../../shared/Links/url_helpers';
|
||||
import { CytoscapeContext } from './Cytoscape';
|
||||
import { getAnimationOptions, getNodeHeight } from './cytoscape_options';
|
||||
|
@ -112,7 +112,7 @@ export function Controls() {
|
|||
const [zoom, setZoom] = useState((cy && cy.zoom()) || 1);
|
||||
const duration = parseInt(theme.eui.euiAnimSpeedFast, 10);
|
||||
const downloadUrl = useDebugDownloadUrl(cy);
|
||||
const viewFullMapUrl = getAPMHref({
|
||||
const viewFullMapUrl = getLegacyApmHref({
|
||||
basePath,
|
||||
path: '/service-map',
|
||||
search: `kuery=${encodeURIComponent(kuery)}`,
|
||||
|
|
|
@ -13,7 +13,7 @@ import { useHistory } from 'react-router-dom';
|
|||
import { CoreStart } from 'kibana/public';
|
||||
import { ApmMainTemplate } from './apm_main_template';
|
||||
import { useApmPluginContext } from '../../../context/apm_plugin/use_apm_plugin_context';
|
||||
import { getAPMHref } from '../../shared/Links/apm/APMLink';
|
||||
import { getLegacyApmHref } from '../../shared/Links/apm/APMLink';
|
||||
|
||||
type Tab = NonNullable<EuiPageHeaderProps['tabs']>[0] & {
|
||||
key:
|
||||
|
@ -69,7 +69,7 @@ function getTabs({
|
|||
label: i18n.translate('xpack.apm.settings.agentConfig', {
|
||||
defaultMessage: 'Agent Configuration',
|
||||
}),
|
||||
href: getAPMHref({
|
||||
href: getLegacyApmHref({
|
||||
basePath,
|
||||
path: `/settings/agent-configuration`,
|
||||
search,
|
||||
|
@ -80,7 +80,7 @@ function getTabs({
|
|||
label: i18n.translate('xpack.apm.settings.anomalyDetection', {
|
||||
defaultMessage: 'Anomaly detection',
|
||||
}),
|
||||
href: getAPMHref({
|
||||
href: getLegacyApmHref({
|
||||
basePath,
|
||||
path: `/settings/anomaly-detection`,
|
||||
search,
|
||||
|
@ -92,21 +92,29 @@ function getTabs({
|
|||
label: i18n.translate('xpack.apm.settings.customizeApp', {
|
||||
defaultMessage: 'Customize app',
|
||||
}),
|
||||
href: getAPMHref({ basePath, path: `/settings/customize-ui`, search }),
|
||||
href: getLegacyApmHref({
|
||||
basePath,
|
||||
path: `/settings/customize-ui`,
|
||||
search,
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 'apm-indices',
|
||||
label: i18n.translate('xpack.apm.settings.indices', {
|
||||
defaultMessage: 'Indices',
|
||||
}),
|
||||
href: getAPMHref({ basePath, path: `/settings/apm-indices`, search }),
|
||||
href: getLegacyApmHref({
|
||||
basePath,
|
||||
path: `/settings/apm-indices`,
|
||||
search,
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 'schema',
|
||||
label: i18n.translate('xpack.apm.settings.schema', {
|
||||
defaultMessage: 'Schema',
|
||||
}),
|
||||
href: getAPMHref({ basePath, path: `/settings/schema`, search }),
|
||||
href: getLegacyApmHref({ basePath, path: `/settings/schema`, search }),
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
@ -54,13 +54,13 @@ export function useAPMHref({
|
|||
...query,
|
||||
};
|
||||
|
||||
return getAPMHref({ basePath, path, query: nextQuery, search });
|
||||
return getLegacyApmHref({ basePath, path, query: nextQuery, search });
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an APM link for a path.
|
||||
*/
|
||||
export function getAPMHref({
|
||||
export function getLegacyApmHref({
|
||||
basePath,
|
||||
path = '',
|
||||
search,
|
||||
|
@ -91,7 +91,7 @@ export function APMLink({ path = '', query, mergeQuery, ...rest }: Props) {
|
|||
|
||||
const mergedQuery = mergeQuery ? mergeQuery(query ?? {}) : query;
|
||||
|
||||
const href = getAPMHref({ basePath, path, search, query: mergedQuery });
|
||||
const href = getLegacyApmHref({ basePath, path, search, query: mergedQuery });
|
||||
|
||||
return <EuiLink {...rest} href={href} />;
|
||||
}
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
|
||||
import { IBasePath } from 'kibana/public';
|
||||
import { AgentConfigurationIntake } from '../../../../../common/agent_configuration/configuration_types';
|
||||
import { getAPMHref } from './APMLink';
|
||||
import { getLegacyApmHref } from './APMLink';
|
||||
|
||||
export function editAgentConfigurationHref(
|
||||
configService: AgentConfigurationIntake['service'],
|
||||
search: string,
|
||||
basePath: IBasePath
|
||||
) {
|
||||
return getAPMHref({
|
||||
return getLegacyApmHref({
|
||||
basePath,
|
||||
path: '/settings/agent-configuration/edit',
|
||||
search,
|
||||
|
|
|
@ -9,7 +9,7 @@ import React from 'react';
|
|||
import { useLocation } from 'react-router-dom';
|
||||
import { EuiLink } from '@elastic/eui';
|
||||
import { pickBy, identity } from 'lodash';
|
||||
import { getAPMHref, APMLinkExtendProps } from './APMLink';
|
||||
import { getLegacyApmHref, APMLinkExtendProps } from './APMLink';
|
||||
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
|
||||
import { pickKeys } from '../../../../../common/utils/pick_keys';
|
||||
import { APMQueryParams } from '../url_helpers';
|
||||
|
@ -43,7 +43,7 @@ export function TransactionDetailLink({
|
|||
const { urlParams } = useUrlParams();
|
||||
const { core } = useApmPluginContext();
|
||||
const location = useLocation();
|
||||
const href = getAPMHref({
|
||||
const href = getLegacyApmHref({
|
||||
basePath: core.http.basePath,
|
||||
path: `/services/${serviceName}/transactions/view`,
|
||||
query: {
|
||||
|
|
|
@ -10,7 +10,7 @@ import React from 'react';
|
|||
import { useLocation } from 'react-router-dom';
|
||||
import { removeUndefinedProps } from '../../../../context/url_params_context/helpers';
|
||||
import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context';
|
||||
import { APMLinkExtendProps, getAPMHref } from './APMLink';
|
||||
import { APMLinkExtendProps, getLegacyApmHref } from './APMLink';
|
||||
|
||||
interface Props extends APMLinkExtendProps {
|
||||
serviceName: string;
|
||||
|
@ -29,7 +29,7 @@ export function useTransactionsOverviewHref({
|
|||
|
||||
const query = { latencyAggregationType, transactionType };
|
||||
|
||||
return getAPMHref({
|
||||
return getLegacyApmHref({
|
||||
basePath: core.http.basePath,
|
||||
path: `/services/${serviceName}/transactions`,
|
||||
query: removeUndefinedProps(query),
|
||||
|
|
|
@ -24,7 +24,7 @@ import { useApmParams } from '../../../hooks/use_apm_params';
|
|||
import { FETCH_STATUS } from '../../../hooks/use_fetcher';
|
||||
import { useTheme } from '../../../hooks/use_theme';
|
||||
import { APIReturnType } from '../../../services/rest/createCallApmApi';
|
||||
import { getAPMHref } from '../Links/apm/APMLink';
|
||||
import { getLegacyApmHref } from '../Links/apm/APMLink';
|
||||
|
||||
export type AnomalyDetectionApiResponse =
|
||||
APIReturnType<'GET /internal/apm/settings/anomaly-detection/jobs'>;
|
||||
|
@ -47,7 +47,7 @@ export function AnomalyDetectionSetupLink() {
|
|||
return (
|
||||
<EuiHeaderLink
|
||||
color="text"
|
||||
href={getAPMHref({ basePath, path: '/settings/anomaly-detection' })}
|
||||
href={getLegacyApmHref({ basePath, path: '/settings/anomaly-detection' })}
|
||||
style={{ whiteSpace: 'nowrap' }}
|
||||
>
|
||||
{canGetJobs && hasValidLicense ? (
|
||||
|
|
|
@ -9,7 +9,7 @@ import { EuiHeaderLink, EuiHeaderLinks } from '@elastic/eui';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import React from 'react';
|
||||
import { getAlertingCapabilities } from '../../alerting/get_alerting_capabilities';
|
||||
import { getAPMHref } from '../Links/apm/APMLink';
|
||||
import { getLegacyApmHref } from '../Links/apm/APMLink';
|
||||
import { useApmPluginContext } from '../../../context/apm_plugin/use_apm_plugin_context';
|
||||
import { AlertingPopoverAndFlyout } from './alerting_popover_flyout';
|
||||
import { AnomalyDetectionSetupLink } from './anomaly_detection_setup_link';
|
||||
|
@ -33,7 +33,7 @@ export function ApmHeaderActionMenu() {
|
|||
const canSaveApmAlerts = capabilities.apm.save && canSaveAlerts;
|
||||
|
||||
function apmHref(path: string) {
|
||||
return getAPMHref({ basePath, path, search });
|
||||
return getLegacyApmHref({ basePath, path, search });
|
||||
}
|
||||
|
||||
function kibanaHref(path: string) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n';
|
|||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { IntegrationLink } from './integration_link';
|
||||
import {
|
||||
getApmHref,
|
||||
getLegacyApmHref,
|
||||
getInfraContainerHref,
|
||||
getInfraIpHref,
|
||||
getInfraKubernetesHref,
|
||||
|
@ -65,7 +65,7 @@ export const IntegrationGroup = ({ summary }: IntegrationGroupProps) => {
|
|||
description:
|
||||
'This value is shown to users when they hover over an icon that will take them to the APM app.',
|
||||
})}
|
||||
href={getApmHref(summary, basePath, dateRangeStart, dateRangeEnd)}
|
||||
href={getLegacyApmHref(summary, basePath, dateRangeStart, dateRangeEnd)}
|
||||
iconType="apmApp"
|
||||
message={i18n.translate('xpack.uptime.apmIntegrationAction.text', {
|
||||
defaultMessage: 'Show APM Data',
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { getApmHref } from './get_apm_href';
|
||||
import { getLegacyApmHref } from './get_apm_href';
|
||||
import { MonitorSummary, makePing } from '../../../../common/runtime_types';
|
||||
|
||||
describe('getApmHref', () => {
|
||||
describe('getLegacyApmHref', () => {
|
||||
let summary: MonitorSummary;
|
||||
beforeEach(() => {
|
||||
summary = {
|
||||
|
@ -37,14 +37,14 @@ describe('getApmHref', () => {
|
|||
});
|
||||
|
||||
it('creates href with base path when present', () => {
|
||||
const result = getApmHref(summary, 'foo', 'now-15m', 'now');
|
||||
const result = getLegacyApmHref(summary, 'foo', 'now-15m', 'now');
|
||||
expect(result).toMatchInlineSnapshot(
|
||||
`"foo/app/apm#/services?kuery=url.domain:%20%22www.elastic.co%22&rangeFrom=now-15m&rangeTo=now"`
|
||||
);
|
||||
});
|
||||
|
||||
it('does not add a base path or extra slash when base path is empty string', () => {
|
||||
const result = getApmHref(summary, '', 'now-15m', 'now');
|
||||
const result = getLegacyApmHref(summary, '', 'now-15m', 'now');
|
||||
expect(result).toMatchInlineSnapshot(
|
||||
`"/app/apm#/services?kuery=url.domain:%20%22www.elastic.co%22&rangeFrom=now-15m&rangeTo=now"`
|
||||
);
|
||||
|
@ -57,7 +57,7 @@ describe('getApmHref', () => {
|
|||
});
|
||||
|
||||
it('links to the named service', () => {
|
||||
const result = getApmHref(summary, 'foo', 'now-15m', 'now');
|
||||
const result = getLegacyApmHref(summary, 'foo', 'now-15m', 'now');
|
||||
expect(result).toMatchInlineSnapshot(
|
||||
`"foo/app/apm#/services?kuery=service.name:%20%22${serviceName}%22&rangeFrom=now-15m&rangeTo=now"`
|
||||
);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { addBasePath } from './add_base_path';
|
||||
import { MonitorSummary } from '../../../../common/runtime_types';
|
||||
|
||||
export const getApmHref = (
|
||||
export const getLegacyApmHref = (
|
||||
summary: MonitorSummary,
|
||||
basePath: string,
|
||||
dateRangeStart: string,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
export { getApmHref } from './get_apm_href';
|
||||
export { getLegacyApmHref } from './get_apm_href';
|
||||
export { getInfraContainerHref, getInfraIpHref, getInfraKubernetesHref } from './get_infra_href';
|
||||
export {
|
||||
getLoggingContainerHref,
|
||||
|
|
Loading…
Reference in a new issue