From 6b37eaeff0e024ab0398fc726e51fc4f1d5e8aae Mon Sep 17 00:00:00 2001 From: Phillip Burch Date: Wed, 18 Aug 2021 11:43:37 -0500 Subject: [PATCH] Remove angular dep from legacy shims --- .../plugins/monitoring/public/legacy_shims.ts | 8 +++++--- x-pack/plugins/monitoring/public/plugin.ts | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/monitoring/public/legacy_shims.ts b/x-pack/plugins/monitoring/public/legacy_shims.ts index 1d897b710d7fa..46c4212e350e2 100644 --- a/x-pack/plugins/monitoring/public/legacy_shims.ts +++ b/x-pack/plugins/monitoring/public/legacy_shims.ts @@ -37,10 +37,12 @@ export interface KFetchKibanaOptions { prependBasePath?: boolean; } +const angularNoop = () => { throw new Error('Angular has been removed.') } + export interface IShims { toastNotifications: CoreStart['notifications']['toasts']; capabilities: CoreStart['application']['capabilities']; - getAngularInjector: () => angular.auto.IInjectorService; + getAngularInjector: typeof angularNoop | (() => angular.auto.IInjectorService); getBasePath: () => string; getInjected: (name: string, defaultValue?: unknown) => unknown; breadcrumbs: { @@ -78,12 +80,12 @@ export class Legacy { usageCollection, appMountParameters, }: MonitoringStartPluginDependencies, - ngInjector: angular.auto.IInjectorService + ngInjector?: angular.auto.IInjectorService ) { this._shims = { toastNotifications: core.notifications.toasts, capabilities: core.application.capabilities, - getAngularInjector: (): angular.auto.IInjectorService => ngInjector, + getAngularInjector: ngInjector ? (): angular.auto.IInjectorService => ngInjector : angularNoop, getBasePath: (): string => core.http.basePath.get(), getInjected: (name: string, defaultValue?: unknown): string | unknown => core.injectedMetadata.getInjectedVar(name, defaultValue), diff --git a/x-pack/plugins/monitoring/public/plugin.ts b/x-pack/plugins/monitoring/public/plugin.ts index 710b453e7f21e..0868ca2abcabd 100644 --- a/x-pack/plugins/monitoring/public/plugin.ts +++ b/x-pack/plugins/monitoring/public/plugin.ts @@ -6,6 +6,7 @@ */ import { i18n } from '@kbn/i18n'; +import { Legacy } from './legacy_shims'; import { App, AppMountParameters, @@ -65,6 +66,7 @@ export class MonitoringPlugin if (!monitoring.ui.enabled || !monitoring.enabled) { return false; } + if (home) { home.featureCatalogue.register({ @@ -108,6 +110,22 @@ export class MonitoringPlugin appMountParameters: params, }; + Legacy.init( + { + core: deps.core, + element: deps.element, + data: deps.data, + navigation: deps.navigation, + isCloud: deps.isCloud, + pluginInitializerContext: deps.pluginInitializerContext, + externalConfig: deps.externalConfig, + kibanaLegacy: deps.kibanaLegacy, + triggersActionsUi: deps.triggersActionsUi, + usageCollection: deps.usageCollection, + appMountParameters: deps.appMountParameters, + } + ); + const monitoringApp = new AngularApp(deps); const removeHistoryListener = params.history.listen((location) => { if (location.pathname === '' && location.hash === '') {