Skip to content

Commit

Permalink
[Deployment management] Mark devtools and management sidenav deeplink…
Browse files Browse the repository at this point in the history
…s as visible on serverless (#161227)
  • Loading branch information
sabarasaba authored Jul 11, 2023
1 parent 31c081a commit 68b3bae
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 11 deletions.
4 changes: 4 additions & 0 deletions config/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/dev_tools/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"owner": "@elastic/platform-deployment-management",
"plugin": {
"id": "devTools",
"server": false,
"server": true,
"browser": true,
"requiredPlugins": [
"urlForwarding"
Expand Down
5 changes: 2 additions & 3 deletions src/plugins/dev_tools/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
20 changes: 18 additions & 2 deletions src/plugins/dev_tools/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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(
Expand All @@ -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,
};
});
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/plugins/dev_tools/public/types.ts
Original file line number Diff line number Diff line change
@@ -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;
};
}
25 changes: 25 additions & 0 deletions src/plugins/dev_tools/server/config.ts
Original file line number Diff line number Diff line change
@@ -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,
};
15 changes: 15 additions & 0 deletions src/plugins/dev_tools/server/index.ts
Original file line number Diff line number Diff line change
@@ -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);
23 changes: 23 additions & 0 deletions src/plugins/dev_tools/server/plugin.ts
Original file line number Diff line number Diff line change
@@ -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() {}
}
4 changes: 3 additions & 1 deletion src/plugins/dev_tools/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "target/types",
},
"include": ["public/**/*"],
"include": ["public/**/*", "server/**/*"],
"kbn_references": [
"@kbn/core",
"@kbn/url-forwarding-plugin",
Expand All @@ -14,6 +14,8 @@
"@kbn/kibana-react-plugin",
"@kbn/shared-ux-router",
"@kbn/deeplinks-devtools",
"@kbn/config-schema",
"@kbn/core-plugins-server",
],
"exclude": [
"target/**/*",
Expand Down
10 changes: 8 additions & 2 deletions src/plugins/management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
})),
})
);
Expand All @@ -78,7 +84,7 @@ export class ManagementPlugin
hideLinksTo: [],
});

constructor(private initializerContext: PluginInitializerContext) {}
constructor(private initializerContext: PluginInitializerContext<ConfigSchema>) {}

public setup(
core: CoreSetup<ManagementStartDependencies>,
Expand Down
7 changes: 7 additions & 0 deletions src/plugins/management/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -93,3 +94,9 @@ export interface AppDependencies {
sections: ManagementSection[];
cardsNavigationConfig?: NavigationCardsSubject;
}

export interface ConfigSchema {
deeplinks: {
navLinkStatus: keyof typeof AppNavLinkStatus;
};
}
27 changes: 27 additions & 0 deletions src/plugins/management/server/config.ts
Original file line number Diff line number Diff line change
@@ -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,
};
1 change: 1 addition & 0 deletions src/plugins/management/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
5 changes: 3 additions & 2 deletions src/plugins/management/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"outDir": "target/types"
},
"include": [
"common/**/*",
Expand All @@ -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/**/*"
]
}
2 changes: 2 additions & 0 deletions test/plugin_functional/test_suites/core_plugins/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
Expand Down

0 comments on commit 68b3bae

Please sign in to comment.