Skip to content

Commit

Permalink
[Stack Monitoring] Remove angular dep from legacy shims (#109132)
Browse files Browse the repository at this point in the history
* Remove angular dep from legacy shims

* Fix ES lint
  • Loading branch information
phillipb authored Aug 26, 2021
1 parent b15b3ce commit 85e1361
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
12 changes: 9 additions & 3 deletions x-pack/plugins/monitoring/public/legacy_shims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ 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: {
Expand Down Expand Up @@ -78,12 +82,14 @@ 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),
Expand Down
15 changes: 15 additions & 0 deletions x-pack/plugins/monitoring/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
Plugin,
PluginInitializerContext,
} from 'kibana/public';
import { Legacy } from './legacy_shims';
import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/public';
import {
FeatureCatalogueCategory,
Expand Down Expand Up @@ -109,6 +110,20 @@ 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 config = Object.fromEntries(externalConfig);
if (config.renderReactApp) {
const { renderApp } = await import('./application');
Expand Down

0 comments on commit 85e1361

Please sign in to comment.