mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
# Backport This will backport the following commits from `main` to `8.11`: - [[ObsUX] Hide Infra subnav item from top-level navigation (#170231)](https://github.com/elastic/kibana/pull/170231) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Mykola Harmash","email":"mykola.harmash@gmail.com"},"sourceCommit":{"committedDate":"2023-11-01T12:25:01Z","message":"[ObsUX] Hide Infra subnav item from top-level navigation (#170231)\n\nCloses https://github.com/elastic/kibana/issues/170116\r\n\r\n## Summary\r\n\r\n- Adds conditions to show/hide \"Infrastructure\" and \"Hosts\" in the\r\ntop-level navigation based on the `isServerlessEnv` flag\r\n\r\n**Traditional**\r\n<img width=\"1771\" alt=\"CleanShot 2023-10-31 at 14 10 25@2x\"\r\nsrc=\"bc0558af
-87a1-43f2-81b1-111d8c45e7b7\">\r\n\r\n**Serverless**\r\n<img width=\"1760\" alt=\"CleanShot 2023-10-31 at 14 11 56@2x\"\r\nsrc=\"7ea0be1a
-7e1c-4689-991d-21ecba69357f\">","sha":"15c4dcfba025cdd284da8cf9147c0b9717f8b7f3","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","v8.12.0","Team:obs-ux-infra_services"],"number":170231,"url":"https://github.com/elastic/kibana/pull/170231","mergeCommit":{"message":"[ObsUX] Hide Infra subnav item from top-level navigation (#170231)\n\nCloses https://github.com/elastic/kibana/issues/170116\r\n\r\n## Summary\r\n\r\n- Adds conditions to show/hide \"Infrastructure\" and \"Hosts\" in the\r\ntop-level navigation based on the `isServerlessEnv` flag\r\n\r\n**Traditional**\r\n<img width=\"1771\" alt=\"CleanShot 2023-10-31 at 14 10 25@2x\"\r\nsrc=\"bc0558af
-87a1-43f2-81b1-111d8c45e7b7\">\r\n\r\n**Serverless**\r\n<img width=\"1760\" alt=\"CleanShot 2023-10-31 at 14 11 56@2x\"\r\nsrc=\"7ea0be1a
-7e1c-4689-991d-21ecba69357f\">","sha":"15c4dcfba025cdd284da8cf9147c0b9717f8b7f3"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/170231","number":170231,"mergeCommit":{"message":"[ObsUX] Hide Infra subnav item from top-level navigation (#170231)\n\nCloses https://github.com/elastic/kibana/issues/170116\r\n\r\n## Summary\r\n\r\n- Adds conditions to show/hide \"Infrastructure\" and \"Hosts\" in the\r\ntop-level navigation based on the `isServerlessEnv` flag\r\n\r\n**Traditional**\r\n<img width=\"1771\" alt=\"CleanShot 2023-10-31 at 14 10 25@2x\"\r\nsrc=\"bc0558af
-87a1-43f2-81b1-111d8c45e7b7\">\r\n\r\n**Serverless**\r\n<img width=\"1760\" alt=\"CleanShot 2023-10-31 at 14 11 56@2x\"\r\nsrc=\"7ea0be1a
-7e1c-4689-991d-21ecba69357f\">","sha":"15c4dcfba025cdd284da8cf9147c0b9717f8b7f3"}}]}] BACKPORT--> Co-authored-by: Mykola Harmash <mykola.harmash@gmail.com>
This commit is contained in:
parent
00995c2169
commit
27d974b5a4
1 changed files with 62 additions and 38 deletions
|
@ -56,6 +56,7 @@ export class Plugin implements InfraClientPluginClass {
|
|||
private telemetry: TelemetryService;
|
||||
private locators?: InfraLocators;
|
||||
private kibanaVersion: string;
|
||||
private isServerlessEnv: boolean;
|
||||
private readonly appUpdater$ = new BehaviorSubject<AppUpdater>(() => ({}));
|
||||
|
||||
constructor(context: PluginInitializerContext<InfraPublicConfig>) {
|
||||
|
@ -67,6 +68,7 @@ export class Plugin implements InfraClientPluginClass {
|
|||
: undefined;
|
||||
this.telemetry = new TelemetryService();
|
||||
this.kibanaVersion = context.env.packageInfo.version;
|
||||
this.isServerlessEnv = context.env.packageInfo.buildFlavor === 'serverless';
|
||||
}
|
||||
|
||||
setup(core: InfraClientCoreSetup, pluginsSetup: InfraClientSetupDeps) {
|
||||
|
@ -222,42 +224,58 @@ export class Plugin implements InfraClientPluginClass {
|
|||
});
|
||||
|
||||
// !! Need to be kept in sync with the routes in x-pack/plugins/infra/public/pages/metrics/index.tsx
|
||||
const infraDeepLinks: AppDeepLink[] = [
|
||||
{
|
||||
id: 'inventory',
|
||||
title: i18n.translate('xpack.infra.homePage.inventoryTabTitle', {
|
||||
defaultMessage: 'Inventory',
|
||||
}),
|
||||
path: '/inventory',
|
||||
navLinkStatus: AppNavLinkStatus.visible,
|
||||
},
|
||||
{
|
||||
id: 'hosts',
|
||||
title: i18n.translate('xpack.infra.homePage.metricsHostsTabTitle', {
|
||||
defaultMessage: 'Hosts',
|
||||
}),
|
||||
path: '/hosts',
|
||||
navLinkStatus: AppNavLinkStatus.visible,
|
||||
},
|
||||
...(this.config.featureFlags.metricsExplorerEnabled
|
||||
? [
|
||||
{
|
||||
id: 'metrics-explorer',
|
||||
title: i18n.translate('xpack.infra.homePage.metricsExplorerTabTitle', {
|
||||
defaultMessage: 'Metrics Explorer',
|
||||
}),
|
||||
path: '/explorer',
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
id: 'settings',
|
||||
title: i18n.translate('xpack.infra.homePage.settingsTabTitle', {
|
||||
defaultMessage: 'Settings',
|
||||
}),
|
||||
path: '/settings',
|
||||
},
|
||||
];
|
||||
const getInfraDeepLinks = ({
|
||||
hostsEnabled,
|
||||
metricsExplorerEnabled,
|
||||
}: {
|
||||
hostsEnabled: boolean;
|
||||
metricsExplorerEnabled: boolean;
|
||||
}): AppDeepLink[] => {
|
||||
const serverlessNavLinkStatus = this.isServerlessEnv
|
||||
? AppNavLinkStatus.visible
|
||||
: AppNavLinkStatus.hidden;
|
||||
|
||||
return [
|
||||
{
|
||||
id: 'inventory',
|
||||
title: i18n.translate('xpack.infra.homePage.inventoryTabTitle', {
|
||||
defaultMessage: 'Inventory',
|
||||
}),
|
||||
path: '/inventory',
|
||||
navLinkStatus: serverlessNavLinkStatus,
|
||||
},
|
||||
...(hostsEnabled
|
||||
? [
|
||||
{
|
||||
id: 'hosts',
|
||||
title: i18n.translate('xpack.infra.homePage.metricsHostsTabTitle', {
|
||||
defaultMessage: 'Hosts',
|
||||
}),
|
||||
path: '/hosts',
|
||||
navLinkStatus: serverlessNavLinkStatus,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(metricsExplorerEnabled
|
||||
? [
|
||||
{
|
||||
id: 'metrics-explorer',
|
||||
title: i18n.translate('xpack.infra.homePage.metricsExplorerTabTitle', {
|
||||
defaultMessage: 'Metrics Explorer',
|
||||
}),
|
||||
path: '/explorer',
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
id: 'settings',
|
||||
title: i18n.translate('xpack.infra.homePage.settingsTabTitle', {
|
||||
defaultMessage: 'Settings',
|
||||
}),
|
||||
path: '/settings',
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
core.application.register({
|
||||
id: 'metrics',
|
||||
|
@ -269,7 +287,10 @@ export class Plugin implements InfraClientPluginClass {
|
|||
appRoute: '/app/metrics',
|
||||
category: DEFAULT_APP_CATEGORIES.observability,
|
||||
updater$: this.appUpdater$,
|
||||
deepLinks: infraDeepLinks,
|
||||
deepLinks: getInfraDeepLinks({
|
||||
hostsEnabled: core.settings.client.get<boolean>(enableInfrastructureHostsView),
|
||||
metricsExplorerEnabled: this.config.featureFlags.metricsExplorerEnabled,
|
||||
}),
|
||||
mount: async (params: AppMountParameters) => {
|
||||
// mount callback should not use setup dependencies, get start dependencies instead
|
||||
const [coreStart, plugins, pluginStart] = await core.getStartServices();
|
||||
|
@ -288,7 +309,10 @@ export class Plugin implements InfraClientPluginClass {
|
|||
startDep$AndHostViewFlag$.subscribe(
|
||||
([_startServices]: [[CoreStart, InfraClientStartDeps, InfraClientStartExports], boolean]) => {
|
||||
this.appUpdater$.next(() => ({
|
||||
deepLinks: infraDeepLinks,
|
||||
deepLinks: getInfraDeepLinks({
|
||||
hostsEnabled: core.settings.client.get<boolean>(enableInfrastructureHostsView),
|
||||
metricsExplorerEnabled: this.config.featureFlags.metricsExplorerEnabled,
|
||||
}),
|
||||
}));
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue