Skip to content

Commit

Permalink
Remove angular dep from legacy shims
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipb committed Aug 18, 2021
1 parent 678aa4a commit 6b37eae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
8 changes: 5 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,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: {
Expand Down Expand Up @@ -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),
Expand Down
18 changes: 18 additions & 0 deletions x-pack/plugins/monitoring/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { i18n } from '@kbn/i18n';
import { Legacy } from './legacy_shims';
import {
App,
AppMountParameters,
Expand Down Expand Up @@ -65,6 +66,7 @@ export class MonitoringPlugin
if (!monitoring.ui.enabled || !monitoring.enabled) {
return false;
}


if (home) {
home.featureCatalogue.register({
Expand Down Expand Up @@ -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 === '') {
Expand Down

0 comments on commit 6b37eae

Please sign in to comment.