Skip to content

Commit

Permalink
[7.x] Move angular related parts from kibana_legacy to monitoring (#1…
Browse files Browse the repository at this point in the history
…14977) (#115198)

* Move angular related parts from kibana_legacy to monitoring (#114977)

* Move angular related parts from kibana_legacy to monitoring

Closes: #114977

* remove private

* move format angular http error into monitoring

* fix translations

* fix type error

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
alexwizp and kibanamachine authored Oct 18, 2021
1 parent bf9eefd commit 4df4755
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 270 deletions.
3 changes: 0 additions & 3 deletions src/plugins/kibana_legacy/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@ export const plugin = (initializerContext: PluginInitializerContext) =>
new KibanaLegacyPlugin(initializerContext);

export * from './plugin';

export * from './angular';
export * from './notify';
export * from './utils';
5 changes: 0 additions & 5 deletions src/plugins/kibana_legacy/public/notify/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,3 @@

export { formatESMsg } from './format_es_msg';
export { formatMsg } from './format_msg';
export {
isAngularHttpError,
formatAngularHttpError,
AngularHttpError,
} from './format_angular_http_error';
10 changes: 0 additions & 10 deletions src/plugins/kibana_legacy/public/utils/index.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/plugins/kibana_legacy/public/utils/private.d.ts

This file was deleted.

192 changes: 0 additions & 192 deletions src/plugins/kibana_legacy/public/utils/private.js

This file was deleted.

6 changes: 3 additions & 3 deletions src/plugins/vis_types/vislib/public/vislib/lib/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ export class Binder {
destroyers.forEach((fn) => fn());
}

jqOn(el: HTMLElement, ...args: [string, (event: JQueryEventObject) => void]) {
jqOn(el: HTMLElement, ...args: [string, (event: JQuery.Event) => void]) {
const $el = $(el);
$el.on(...args);
this.disposal.push(() => $el.off(...args));
}

fakeD3Bind(el: HTMLElement, event: string, handler: (event: JQueryEventObject) => void) {
this.jqOn(el, event, (e: JQueryEventObject) => {
fakeD3Bind(el: HTMLElement, event: string, handler: (event: JQuery.Event) => void) {
this.jqOn(el, event, (e: JQuery.Event) => {
// mimic https://github.com/mbostock/d3/blob/3abb00113662463e5c19eb87cd33f6d0ddc23bc0/src/selection/on.js#L87-L94
const o = d3.event; // Events can be reentrant (e.g., focus).
d3.event = e;
Expand Down
18 changes: 9 additions & 9 deletions x-pack/plugins/monitoring/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@
"githubTeam": "stack-monitoring-ui"
},
"configPath": ["monitoring"],
"requiredPlugins": [
"licensing",
"features",
"data",
"navigation",
"kibanaLegacy",
"observability"
],
"requiredPlugins": ["licensing", "features", "data", "navigation", "observability"],
"optionalPlugins": [
"infra",
"usageCollection",
Expand All @@ -27,5 +20,12 @@
],
"server": true,
"ui": true,
"requiredBundles": ["kibanaUtils", "home", "alerting", "kibanaReact", "licenseManagement"]
"requiredBundles": [
"kibanaUtils",
"home",
"alerting",
"kibanaReact",
"licenseManagement",
"kibanaLegacy"
]
}
5 changes: 1 addition & 4 deletions x-pack/plugins/monitoring/public/angular/app_modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ import { upperFirst } from 'lodash';
import { CoreStart } from 'kibana/public';
import { i18nDirective, i18nFilter, I18nProvider } from './angular_i18n';
import { Storage } from '../../../../../src/plugins/kibana_utils/public';
import {
createTopNavDirective,
createTopNavHelper,
} from '../../../../../src/plugins/kibana_legacy/public';
import { createTopNavDirective, createTopNavHelper } from './top_nav';
import { MonitoringStartPluginDependencies } from '../types';
import { GlobalState } from '../url_state';
import { getSafeForExternalLink } from '../lib/get_safe_for_external_link';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/*
* 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.
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { i18n } from '@kbn/i18n';
import { IHttpResponse } from 'angular';
import type { IHttpResponse } from 'angular';

export type AngularHttpError = IHttpResponse<{ message: string }>;
type AngularHttpError = IHttpResponse<{ message: string }>;

export function isAngularHttpError(error: any): error is AngularHttpError {
return (
Expand All @@ -25,15 +24,15 @@ export function formatAngularHttpError(error: AngularHttpError) {
// is an Angular $http "error object"
if (error.status === -1) {
// status = -1 indicates that the request was failed to reach the server
return i18n.translate('kibana_legacy.notify.fatalError.unavailableServerErrorMessage', {
return i18n.translate('xpack.monitoring.notify.fatalError.unavailableServerErrorMessage', {
defaultMessage:
'An HTTP request has failed to connect. ' +
'Please check if the Kibana server is running and that your browser has a working connection, ' +
'or contact your system administrator.',
});
}

return i18n.translate('kibana_legacy.notify.fatalError.errorStatusMessage', {
return i18n.translate('xpack.monitoring.notify.fatalError.errorStatusMessage', {
defaultMessage: 'Error {errStatus} {errStatusText}: {errMessage}',
values: {
errStatus: error.status,
Expand Down
4 changes: 1 addition & 3 deletions x-pack/plugins/monitoring/public/angular/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import angular, { IModule } from 'angular';
import { uiRoutes } from './helpers/routes';
import { Legacy } from '../legacy_shims';
import { configureAppAngularModule } from '../../../../../src/plugins/kibana_legacy/public';
import { configureAppAngularModule } from '../angular/top_nav';
import { localAppModule, appModuleName } from './app_modules';
import { APP_WRAPPER_CLASS } from '../../../../../src/core/public';

Expand All @@ -28,7 +28,6 @@ export class AngularApp {
externalConfig,
triggersActionsUi,
usageCollection,
kibanaLegacy,
appMountParameters,
} = deps;
const app: IModule = localAppModule(deps);
Expand All @@ -43,7 +42,6 @@ export class AngularApp {
isCloud,
pluginInitializerContext,
externalConfig,
kibanaLegacy,
triggersActionsUi,
usageCollection,
appMountParameters,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/*
* 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.
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import {
Expand All @@ -23,7 +22,7 @@ import { ChromeBreadcrumb, EnvironmentMode, PackageInfo } from 'kibana/public';
import { History } from 'history';

import { CoreStart } from 'kibana/public';
import { formatAngularHttpError, isAngularHttpError } from '../notify/lib';
import { formatAngularHttpError, isAngularHttpError } from '../helpers/format_angular_http_error';

export interface RouteConfiguration {
controller?: string | ((...args: any[]) => void);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* 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.
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export * from './angular_config';
// @ts-ignore
export { createTopNavDirective, createTopNavHelper, loadKbnTopNavDirectives } from './kbn_top_nav';
Loading

0 comments on commit 4df4755

Please sign in to comment.