Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Only register items in side nav if user has permissions to see app #101707

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 54 additions & 55 deletions x-pack/plugins/apm/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*/

import { i18n } from '@kbn/i18n';
import { of } from 'rxjs';
import { from } from 'rxjs';
import { map } from 'rxjs/operators';
import type { ConfigSchema } from '.';
import {
AppMountParameters,
Expand Down Expand Up @@ -86,19 +87,56 @@ export class ApmPlugin implements Plugin<ApmPluginSetup, ApmPluginStart> {
pluginSetupDeps.home.featureCatalogue.register(featureCatalogueEntry);
}

// register observability nav
const servicesTitle = i18n.translate('xpack.apm.navigation.servicesTitle', {
defaultMessage: 'Services',
});
const tracesTitle = i18n.translate('xpack.apm.navigation.tracesTitle', {
defaultMessage: 'Traces',
});
const serviceMapTitle = i18n.translate(
'xpack.apm.navigation.serviceMapTitle',
{ defaultMessage: 'Service Map' }
);

// register observability nav if user has access to plugin
plugins.observability.navigation.registerSections(
of([
{
label: 'APM',
sortKey: 200,
entries: [
{ label: 'Services', app: 'apm', path: '/services' },
{ label: 'Traces', app: 'apm', path: '/traces' },
{ label: 'Service Map', app: 'apm', path: '/service-map' },
],
},
])
from(core.getStartServices()).pipe(
map(([coreStart]) => {
if (coreStart.application.capabilities.apm.show) {
return [
// APM navigation
{
label: 'APM',
sortKey: 200,
entries: [
{ label: servicesTitle, app: 'apm', path: '/services' },
{ label: tracesTitle, app: 'apm', path: '/traces' },
{ label: serviceMapTitle, app: 'apm', path: '/service-map' },
],
},

// UX navigation
{
label: 'User Experience',
sortKey: 201,
entries: [
{
label: i18n.translate('xpack.apm.ux.overview.heading', {
defaultMessage: 'Overview',
}),
app: 'ux',
path: '/',
matchFullPath: true,
ignoreTrailingSlash: true,
},
],
},
];
}

return [];
})
)
);

const getApmDataHelper = async () => {
Expand Down Expand Up @@ -150,26 +188,6 @@ export class ApmPlugin implements Plugin<ApmPluginSetup, ApmPluginStart> {
},
});

plugins.observability.navigation.registerSections(
of([
{
label: 'User Experience',
sortKey: 201,
entries: [
{
label: i18n.translate('xpack.apm.ux.overview.heading', {
defaultMessage: 'Overview',
}),
app: 'ux',
path: '/',
matchFullPath: true,
ignoreTrailingSlash: true,
},
],
},
])
);

core.application.register({
id: 'apm',
title: 'APM',
Expand All @@ -178,29 +196,10 @@ export class ApmPlugin implements Plugin<ApmPluginSetup, ApmPluginStart> {
appRoute: '/app/apm',
icon: 'plugins/apm/public/icon.svg',
category: DEFAULT_APP_CATEGORIES.observability,
// !! Need to be kept in sync with the routes in x-pack/plugins/apm/public/components/app/Main/route_config/index.tsx
deepLinks: [
{
id: 'services',
title: i18n.translate('xpack.apm.breadcrumb.servicesTitle', {
defaultMessage: 'Services',
}),
path: '/services',
},
{
id: 'traces',
title: i18n.translate('xpack.apm.breadcrumb.tracesTitle', {
defaultMessage: 'Traces',
}),
path: '/traces',
},
{
id: 'service-map',
title: i18n.translate('xpack.apm.breadcrumb.serviceMapTitle', {
defaultMessage: 'Service Map',
}),
path: '/service-map',
},
{ id: 'services', title: servicesTitle, path: '/services' },
{ id: 'traces', title: tracesTitle, path: '/traces' },
{ id: 'service-map', title: serviceMapTitle, path: '/service-map' },
],

async mount(appMountParameters: AppMountParameters<unknown>) {
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -5390,9 +5390,6 @@
"xpack.apm.apply.label": "適用",
"xpack.apm.applyFilter": "{title} フィルターを適用",
"xpack.apm.applyOptions": "オプションを適用",
"xpack.apm.breadcrumb.serviceMapTitle": "サービスマップ",
"xpack.apm.breadcrumb.servicesTitle": "サービス",
"xpack.apm.breadcrumb.tracesTitle": "トレース",
"xpack.apm.chart.annotation.version": "バージョン",
"xpack.apm.chart.cpuSeries.processAverageLabel": "プロセス平均",
"xpack.apm.chart.cpuSeries.processMaxLabel": "プロセス最大",
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -5419,9 +5419,6 @@
"xpack.apm.apply.label": "应用",
"xpack.apm.applyFilter": "应用 {title} 筛选",
"xpack.apm.applyOptions": "应用选项",
"xpack.apm.breadcrumb.serviceMapTitle": "服务地图",
"xpack.apm.breadcrumb.servicesTitle": "服务",
"xpack.apm.breadcrumb.tracesTitle": "追溯",
"xpack.apm.chart.annotation.version": "版本",
"xpack.apm.chart.cpuSeries.processAverageLabel": "进程平均值",
"xpack.apm.chart.cpuSeries.processMaxLabel": "进程最大值",
Expand Down