[Deployment management] Mark devtools and management sidenav deeplinks as visible on serverless (#161227)

This commit is contained in:
Ignacio Rivas 2023-07-11 10:31:21 +02:00 committed by GitHub
parent 31c081a1d7
commit 68b3baec93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 154 additions and 11 deletions

View file

@ -36,6 +36,10 @@ xpack.remote_clusters.enabled: false
xpack.snapshot_restore.enabled: false
xpack.license_management.enabled: false
# Keep deeplinks visible so that they are shown in the sidenav
dev_tools.deeplinks.navLinkStatus: visible
management.deeplinks.navLinkStatus: visible
# Other disabled plugins
#xpack.canvas.enabled: false #only disabable in dev-mode
xpack.reporting.enabled: false

View file

@ -4,7 +4,7 @@
"owner": "@elastic/platform-deployment-management",
"plugin": {
"id": "devTools",
"server": false,
"server": true,
"browser": true,
"requiredPlugins": [
"urlForwarding"

View file

@ -11,9 +11,8 @@
import { PluginInitializerContext } from '@kbn/core/public';
import { DevToolsPlugin } from './plugin';
export * from './plugin';
export function plugin(initializerContext: PluginInitializerContext) {
return new DevToolsPlugin();
return new DevToolsPlugin(initializerContext);
}
export * from './plugin';

View file

@ -12,9 +12,14 @@ import { AppUpdater } from '@kbn/core/public';
import { i18n } from '@kbn/i18n';
import { sortBy } from 'lodash';
import { AppNavLinkStatus, DEFAULT_APP_CATEGORIES } from '@kbn/core/public';
import {
PluginInitializerContext,
AppNavLinkStatus,
DEFAULT_APP_CATEGORIES,
} from '@kbn/core/public';
import { UrlForwardingSetup } from '@kbn/url-forwarding-plugin/public';
import { deepLinkIds as devtoolsDeeplinkIds } from '@kbn/deeplinks-devtools';
import { ConfigSchema } from './types';
import { CreateDevToolArgs, DevToolApp, createDevToolApp } from './dev_tool';
import { DocTitleService, BreadcrumbService } from './services';
@ -45,6 +50,8 @@ export class DevToolsPlugin implements Plugin<DevToolsSetup, void> {
return sortBy([...this.devTools.values()], 'order');
}
constructor(private initializerContext: PluginInitializerContext<ConfigSchema>) {}
public setup(coreSetup: CoreSetup, { urlForwarding }: { urlForwarding: UrlForwardingSetup }) {
const { application: applicationSetup, getStartServices } = coreSetup;
@ -107,6 +114,10 @@ export class DevToolsPlugin implements Plugin<DevToolsSetup, void> {
if (this.getSortedDevTools().length === 0) {
this.appStateUpdater.next(() => ({ navLinkStatus: AppNavLinkStatus.hidden }));
} else {
const config = this.initializerContext.config.get();
const navLinkStatus =
AppNavLinkStatus[config.deeplinks.navLinkStatus as keyof typeof AppNavLinkStatus];
this.appStateUpdater.next(() => {
const deepLinks: AppDeepLink[] = [...this.devTools.values()]
.filter(
@ -118,13 +129,18 @@ export class DevToolsPlugin implements Plugin<DevToolsSetup, void> {
id: tool.id,
title: tool.title as string,
path: `#/${tool.id}`,
navLinkStatus,
};
if (!devtoolsDeeplinkIds.some((id) => id === deepLink.id)) {
throw new Error('Deeplink must be registered in package.');
}
return deepLink;
});
return { deepLinks };
return {
deepLinks,
navLinkStatus,
};
});
}
}

View file

@ -0,0 +1,15 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { AppNavLinkStatus } from '@kbn/core/public';
export interface ConfigSchema {
deeplinks: {
navLinkStatus: keyof typeof AppNavLinkStatus;
};
}

View file

@ -0,0 +1,25 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { schema, TypeOf } from '@kbn/config-schema';
import { PluginConfigDescriptor } from '@kbn/core-plugins-server';
const configSchema = schema.object({
deeplinks: schema.object({
navLinkStatus: schema.string({ defaultValue: 'default' }),
}),
});
export type DevToolsConfig = TypeOf<typeof configSchema>;
export const config: PluginConfigDescriptor<DevToolsConfig> = {
exposeToBrowser: {
deeplinks: true,
},
schema: configSchema,
};

View file

@ -0,0 +1,15 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { PluginInitializerContext } from '@kbn/core/server';
import { DevToolsServerPlugin } from './plugin';
export { config } from './config';
export const plugin = (initContext: PluginInitializerContext) =>
new DevToolsServerPlugin(initContext);

View file

@ -0,0 +1,23 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { PluginInitializerContext, Plugin } from '@kbn/core/server';
export class DevToolsServerPlugin implements Plugin<object, object> {
constructor(initializerContext: PluginInitializerContext) {}
public setup() {
return {};
}
public start() {
return {};
}
public stop() {}
}

View file

@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "target/types",
},
"include": ["public/**/*"],
"include": ["public/**/*", "server/**/*"],
"kbn_references": [
"@kbn/core",
"@kbn/url-forwarding-plugin",
@ -14,6 +14,8 @@
"@kbn/kibana-react-plugin",
"@kbn/shared-ux-router",
"@kbn/deeplinks-devtools",
"@kbn/config-schema",
"@kbn/core-plugins-server",
],
"exclude": [
"target/**/*",

View file

@ -22,7 +22,7 @@ import {
AppNavLinkStatus,
AppDeepLink,
} from '@kbn/core/public';
import { ManagementSetup, ManagementStart, NavigationCardsSubject } from './types';
import { ConfigSchema, ManagementSetup, ManagementStart, NavigationCardsSubject } from './types';
import { MANAGEMENT_APP_ID } from '../common/contants';
import { ManagementAppLocatorDefinition } from '../common/locator';
@ -53,15 +53,21 @@ export class ManagementPlugin
private readonly managementSections = new ManagementSectionsService();
private readonly appUpdater = new BehaviorSubject<AppUpdater>(() => {
const config = this.initializerContext.config.get();
const navLinkStatus =
AppNavLinkStatus[config.deeplinks.navLinkStatus as keyof typeof AppNavLinkStatus];
const deepLinks: AppDeepLink[] = Object.values(this.managementSections.definedSections).map(
(section: ManagementSection) => ({
id: section.id,
title: section.title,
navLinkStatus,
deepLinks: section.getAppsEnabled().map((mgmtApp) => ({
id: mgmtApp.id,
title: mgmtApp.title,
path: mgmtApp.basePath,
keywords: mgmtApp.keywords,
navLinkStatus,
})),
})
);
@ -78,7 +84,7 @@ export class ManagementPlugin
hideLinksTo: [],
});
constructor(private initializerContext: PluginInitializerContext) {}
constructor(private initializerContext: PluginInitializerContext<ConfigSchema>) {}
public setup(
core: CoreSetup<ManagementStartDependencies>,

View file

@ -11,6 +11,7 @@ import { ScopedHistory, Capabilities } from '@kbn/core/public';
import type { LocatorPublic } from '@kbn/share-plugin/common';
import { ChromeBreadcrumb, CoreTheme } from '@kbn/core/public';
import type { AppId } from '@kbn/management-cards-navigation';
import { AppNavLinkStatus } from '@kbn/core/public';
import { ManagementSection, RegisterManagementSectionArgs } from './utils';
import type { ManagementAppLocatorParams } from '../common/locator';
@ -93,3 +94,9 @@ export interface AppDependencies {
sections: ManagementSection[];
cardsNavigationConfig?: NavigationCardsSubject;
}
export interface ConfigSchema {
deeplinks: {
navLinkStatus: keyof typeof AppNavLinkStatus;
};
}

View file

@ -0,0 +1,27 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { schema, TypeOf } from '@kbn/config-schema';
import { PluginConfigDescriptor } from '@kbn/core/server';
export const configSchema = schema.object({
deeplinks: schema.object({
navLinkStatus: schema.string({ defaultValue: 'default' }),
}),
});
export type ManagementConfig = TypeOf<typeof configSchema>;
export type ManagementPublicConfig = TypeOf<typeof configSchema>;
export const config: PluginConfigDescriptor<ManagementPublicConfig> = {
exposeToBrowser: {
deeplinks: true,
},
schema: configSchema,
};

View file

@ -8,6 +8,7 @@
import { PluginInitializerContext } from '@kbn/core/server';
import { ManagementServerPlugin } from './plugin';
export { config } from './config';
export const plugin = (initContext: PluginInitializerContext) =>
new ManagementServerPlugin(initContext);

View file

@ -1,7 +1,7 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"outDir": "target/types"
},
"include": [
"common/**/*",
@ -23,10 +23,11 @@
"@kbn/management-cards-navigation",
"@kbn/shared-ux-link-redirect-app",
"@kbn/test-jest-helpers",
"@kbn/config-schema",
"@kbn/core-application-browser",
"@kbn/core-http-browser"
],
"exclude": [
"target/**/*",
"target/**/*"
]
}

View file

@ -103,9 +103,11 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
'data.search.sessions.management.refreshTimeout (duration)',
'data.search.sessions.maxUpdateRetries (number)',
'data.search.sessions.notTouchedTimeout (duration)',
'dev_tools.deeplinks.navLinkStatus (string)',
'enterpriseSearch.canDeployEntSearch (boolean)',
'enterpriseSearch.host (string)',
'home.disableWelcomeScreen (boolean)',
'management.deeplinks.navLinkStatus (string)',
'map.emsFileApiUrl (string)',
'map.emsFontLibraryUrl (string)',
'map.emsLandingPageUrl (string)',