diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 425f373ff99d3..9c25879df947f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -24,7 +24,7 @@ /x-pack/plugins/lens/ @elastic/kibana-vis-editors /src/plugins/advanced_settings/ @elastic/kibana-vis-editors /src/plugins/charts/ @elastic/kibana-vis-editors -/src/plugins/kibana_legacy/ @elastic/kibana-vis-editors +/src/plugins/management/ @elastic/kibana-vis-editors /src/plugins/vis_default_editor/ @elastic/kibana-vis-editors /src/plugins/vis_types/metric/ @elastic/kibana-vis-editors /src/plugins/vis_types/table/ @elastic/kibana-vis-editors diff --git a/.i18nrc.json b/.i18nrc.json index 733f2b90acc7d..80dbfee949a6c 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -46,7 +46,6 @@ "indexPatternManagement": "src/plugins/data_view_management", "interactiveSetup": "src/plugins/interactive_setup", "advancedSettings": "src/plugins/advanced_settings", - "kibana_legacy": "src/plugins/kibana_legacy", "kibanaOverview": "src/plugins/kibana_overview", "kibana_react": "src/legacy/core_plugins/kibana_react", "kibana-react": "src/plugins/kibana_react", diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index 39766ff2f8936..2f0be0c39a3b8 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -162,10 +162,6 @@ in Kibana, e.g. visualizations. It has the form of a flyout panel. |The plugin provides UI and APIs for the interactive setup mode. -|{kib-repo}blob/{branch}/src/plugins/kibana_legacy/README.md[kibanaLegacy] -|This plugin contains several helpers and services to integrate pieces of the legacy Kibana app with the new Kibana platform. - - |{kib-repo}blob/{branch}/src/plugins/kibana_overview/README.md[kibanaOverview] |An overview page highlighting Kibana apps diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index b22d2fa1a46b3..e08b34f70b2a1 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -29,7 +29,6 @@ pageLoadAssetSize: ingestPipelines: 58003 inputControlVis: 172675 inspector: 148711 - kibanaLegacy: 107711 kibanaOverview: 56279 lens: 96624 licenseManagement: 41817 diff --git a/src/plugins/kibana_legacy/README.md b/src/plugins/kibana_legacy/README.md deleted file mode 100644 index d66938cca6d13..0000000000000 --- a/src/plugins/kibana_legacy/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# kibana-legacy - -This plugin contains several helpers and services to integrate pieces of the legacy Kibana app with the new Kibana platform. - -This plugin will be removed once all parts of legacy Kibana are removed from other plugins. - -All of this plugin should be considered deprecated. New code should never integrate with the services provided from this plugin. \ No newline at end of file diff --git a/src/plugins/kibana_legacy/jest.config.js b/src/plugins/kibana_legacy/jest.config.js deleted file mode 100644 index a2bdf5649f900..0000000000000 --- a/src/plugins/kibana_legacy/jest.config.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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. - */ - -module.exports = { - preset: '@kbn/test', - rootDir: '../../..', - roots: ['/src/plugins/kibana_legacy'], - coverageDirectory: '/target/kibana-coverage/jest/src/plugins/kibana_legacy', - coverageReporters: ['text', 'html'], - collectCoverageFrom: ['/src/plugins/kibana_legacy/public/**/*.{js,ts,tsx}'], -}; diff --git a/src/plugins/kibana_legacy/kibana.json b/src/plugins/kibana_legacy/kibana.json deleted file mode 100644 index afca886ad9376..0000000000000 --- a/src/plugins/kibana_legacy/kibana.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "id": "kibanaLegacy", - "version": "kibana", - "server": false, - "ui": true, - "owner": { - "name": "Vis Editors", - "githubTeam": "kibana-vis-editors" - } -} diff --git a/src/plugins/kibana_legacy/public/index.ts b/src/plugins/kibana_legacy/public/index.ts deleted file mode 100644 index 2acb501a7262f..0000000000000 --- a/src/plugins/kibana_legacy/public/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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. - */ - -// TODO: https://github.com/elastic/kibana/issues/110891 -/* eslint-disable @kbn/eslint/no_export_all */ - -import { KibanaLegacyPlugin } from './plugin'; - -export const plugin = () => new KibanaLegacyPlugin(); - -export * from './plugin'; -export * from './notify'; diff --git a/src/plugins/kibana_legacy/public/mocks.ts b/src/plugins/kibana_legacy/public/mocks.ts deleted file mode 100644 index 3eac98a84d40a..0000000000000 --- a/src/plugins/kibana_legacy/public/mocks.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 { KibanaLegacyPlugin } from './plugin'; - -export type Setup = jest.Mocked>; -export type Start = jest.Mocked>; - -const createSetupContract = (): Setup => ({}); - -const createStartContract = (): Start => ({ - loadFontAwesome: jest.fn(), -}); - -export const kibanaLegacyPluginMock = { - createSetupContract, - createStartContract, -}; diff --git a/src/plugins/kibana_legacy/public/notify/index.ts b/src/plugins/kibana_legacy/public/notify/index.ts deleted file mode 100644 index d4dcaa77cc47a..0000000000000 --- a/src/plugins/kibana_legacy/public/notify/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* - * 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. - */ - -export * from './lib'; diff --git a/src/plugins/kibana_legacy/public/notify/lib/format_es_msg.test.js b/src/plugins/kibana_legacy/public/notify/lib/format_es_msg.test.js deleted file mode 100644 index d99db9f19f32e..0000000000000 --- a/src/plugins/kibana_legacy/public/notify/lib/format_es_msg.test.js +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 { formatESMsg } from './format_es_msg'; -import expect from '@kbn/expect'; - -describe('formatESMsg', () => { - test('should return undefined if passed a basic error', () => { - const err = new Error('This is a normal error'); - - const actual = formatESMsg(err); - - expect(actual).to.be(undefined); - }); - - test('should return undefined if passed a string', () => { - const err = 'This is a error string'; - - const actual = formatESMsg(err); - - expect(actual).to.be(undefined); - }); - - test('should return the root_cause if passed an extended elasticsearch', () => { - const err = new Error('This is an elasticsearch error'); - err.resp = { - error: { - root_cause: [ - { - reason: 'I am the detailed message', - }, - ], - }, - }; - - const actual = formatESMsg(err); - - expect(actual).to.equal('I am the detailed message'); - }); - - test('should combine the reason messages if more than one is returned.', () => { - const err = new Error('This is an elasticsearch error'); - err.resp = { - error: { - root_cause: [ - { - reason: 'I am the detailed message 1', - }, - { - reason: 'I am the detailed message 2', - }, - ], - }, - }; - - const actual = formatESMsg(err); - - expect(actual).to.equal('I am the detailed message 1\nI am the detailed message 2'); - }); -}); diff --git a/src/plugins/kibana_legacy/public/notify/lib/format_es_msg.ts b/src/plugins/kibana_legacy/public/notify/lib/format_es_msg.ts deleted file mode 100644 index 9c86899209a9c..0000000000000 --- a/src/plugins/kibana_legacy/public/notify/lib/format_es_msg.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 _ from 'lodash'; - -const getRootCause = (err: Record | string) => _.get(err, 'resp.error.root_cause'); - -/** - * Utilize the extended error information returned from elasticsearch - * @param {Error|String} err - * @returns {string} - */ -export const formatESMsg = (err: Record | string) => { - const rootCause = getRootCause(err); - - if (!Array.isArray(rootCause)) { - return; - } - - return rootCause.map((cause: Record) => cause.reason).join('\n'); -}; diff --git a/src/plugins/kibana_legacy/public/notify/lib/index.ts b/src/plugins/kibana_legacy/public/notify/lib/index.ts deleted file mode 100644 index 7f1cfb0e5b1fe..0000000000000 --- a/src/plugins/kibana_legacy/public/notify/lib/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* - * 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. - */ - -export { formatESMsg } from './format_es_msg'; -export { formatMsg } from './format_msg'; diff --git a/src/plugins/kibana_legacy/public/plugin.ts b/src/plugins/kibana_legacy/public/plugin.ts deleted file mode 100644 index a154770bbfffd..0000000000000 --- a/src/plugins/kibana_legacy/public/plugin.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 type { CoreSetup } from 'kibana/public'; - -export class KibanaLegacyPlugin { - public setup(core: CoreSetup<{}, KibanaLegacyStart>) { - return {}; - } - - public start() { - return { - /** - * Loads the font-awesome icon font. Should be removed once the last consumer has migrated to EUI - * @deprecated - */ - loadFontAwesome: async () => { - await import('./font_awesome'); - }, - }; - } -} - -export type KibanaLegacySetup = ReturnType; -export type KibanaLegacyStart = ReturnType; diff --git a/src/plugins/kibana_legacy/tsconfig.json b/src/plugins/kibana_legacy/tsconfig.json deleted file mode 100644 index 17f1a70838fd7..0000000000000 --- a/src/plugins/kibana_legacy/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./target/types", - "emitDeclarationOnly": true, - "declaration": true, - "declarationMap": true - }, - "include": ["../../../typings/**/*", "public/**/*", "server/**/*", "config.ts"], - "references": [{ "path": "../../core/tsconfig.json" }] -} diff --git a/src/plugins/telemetry_management_section/tsconfig.json b/src/plugins/telemetry_management_section/tsconfig.json index 0f00f12e71c20..1e2b2e57d51c8 100644 --- a/src/plugins/telemetry_management_section/tsconfig.json +++ b/src/plugins/telemetry_management_section/tsconfig.json @@ -16,7 +16,6 @@ { "path": "../kibana_utils/tsconfig.json" }, { "path": "../usage_collection/tsconfig.json" }, { "path": "../telemetry/tsconfig.json" }, - { "path": "../kibana_legacy/tsconfig.json"}, { "path": "../ui_actions/tsconfig.json" }, { "path": "../expressions/tsconfig.json" }, { "path": "../home/tsconfig.json" }, diff --git a/src/plugins/url_forwarding/tsconfig.json b/src/plugins/url_forwarding/tsconfig.json index c6ef2a0286da1..464cca51c6b9f 100644 --- a/src/plugins/url_forwarding/tsconfig.json +++ b/src/plugins/url_forwarding/tsconfig.json @@ -9,6 +9,5 @@ "include": ["public/**/*"], "references": [ { "path": "../../core/tsconfig.json" }, - { "path": "../kibana_legacy/tsconfig.json" } ] } diff --git a/x-pack/plugins/canvas/kibana.json b/x-pack/plugins/canvas/kibana.json index 2fd312502a3c7..a00dd94ce346c 100644 --- a/x-pack/plugins/canvas/kibana.json +++ b/x-pack/plugins/canvas/kibana.json @@ -33,7 +33,6 @@ "requiredBundles": [ "discover", "home", - "kibanaLegacy", "kibanaReact", "kibanaUtils", "lens", diff --git a/src/plugins/kibana_legacy/public/notify/lib/format_msg.test.js b/x-pack/plugins/canvas/public/lib/format_msg.test.ts similarity index 50% rename from src/plugins/kibana_legacy/public/notify/lib/format_msg.test.js rename to x-pack/plugins/canvas/public/lib/format_msg.test.ts index 30061141ee46d..0643e2a6f2b95 100644 --- a/src/plugins/kibana_legacy/public/notify/lib/format_msg.test.js +++ b/x-pack/plugins/canvas/public/lib/format_msg.test.ts @@ -1,13 +1,12 @@ /* * 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 { formatMsg } from './format_msg'; import expect from '@kbn/expect'; +import { formatMsg, formatESMsg } from './format_msg'; describe('formatMsg', () => { test('should prepend the second argument to result', () => { @@ -65,4 +64,59 @@ describe('formatMsg', () => { expect(actual).to.equal('I am the detailed message'); }); + + describe('formatESMsg', () => { + test('should return undefined if passed a basic error', () => { + const err = new Error('This is a normal error'); + + const actual = formatESMsg(err); + + expect(actual).to.be(undefined); + }); + + test('should return undefined if passed a string', () => { + const err = 'This is a error string'; + + const actual = formatESMsg(err); + + expect(actual).to.be(undefined); + }); + + test('should return the root_cause if passed an extended elasticsearch', () => { + const err: Record = new Error('This is an elasticsearch error'); + err.resp = { + error: { + root_cause: [ + { + reason: 'I am the detailed message', + }, + ], + }, + }; + + const actual = formatESMsg(err); + + expect(actual).to.equal('I am the detailed message'); + }); + + test('should combine the reason messages if more than one is returned.', () => { + const err: Record = new Error('This is an elasticsearch error'); + err.resp = { + error: { + root_cause: [ + { + reason: 'I am the detailed message 1', + }, + { + reason: 'I am the detailed message 2', + }, + ], + }, + }; + + const actual = formatESMsg(err); + + expect(actual).to.equal('I am the detailed message 1\nI am the detailed message 2'); + }); + }); }); diff --git a/src/plugins/kibana_legacy/public/notify/lib/format_msg.ts b/x-pack/plugins/canvas/public/lib/format_msg.ts similarity index 71% rename from src/plugins/kibana_legacy/public/notify/lib/format_msg.ts rename to x-pack/plugins/canvas/public/lib/format_msg.ts index 53fe0ba800a27..c996fe6c890be 100644 --- a/src/plugins/kibana_legacy/public/notify/lib/format_msg.ts +++ b/x-pack/plugins/canvas/public/lib/format_msg.ts @@ -1,16 +1,31 @@ /* * 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 _ from 'lodash'; import { i18n } from '@kbn/i18n'; -import { formatESMsg } from './format_es_msg'; const has = _.has; +const getRootCause = (err: Record | string) => _.get(err, 'resp.error.root_cause'); + +/** + * Utilize the extended error information returned from elasticsearch + * @param {Error|String} err + * @returns {string} + */ +export const formatESMsg = (err: Record | string) => { + const rootCause = getRootCause(err); + + if (!Array.isArray(rootCause)) { + return; + } + + return rootCause.map((cause: Record) => cause.reason).join('\n'); +}; + /** * Formats the error message from an error object, extended elasticsearch * object or simple string; prepends optional second parameter to the message @@ -36,14 +51,14 @@ export function formatMsg(err: Record | string, source: string = '' // is an Angular $http "error object" if (err.status === -1) { // status = -1 indicates that the request was failed to reach the server - message += i18n.translate('kibana_legacy.notify.toaster.unavailableServerErrorMessage', { + message += i18n.translate('xpack.canvas.formatMsg.toaster.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.', }); } else { - message += i18n.translate('kibana_legacy.notify.toaster.errorStatusMessage', { + message += i18n.translate('xpack.canvas.formatMsg.toaster.errorStatusMessage', { defaultMessage: 'Error {errStatus} {errStatusText}: {errMessage}', values: { errStatus: err.status, diff --git a/x-pack/plugins/canvas/public/services/kibana/notify.ts b/x-pack/plugins/canvas/public/services/kibana/notify.ts index 1752840127fe1..22d4b6f8a476d 100644 --- a/x-pack/plugins/canvas/public/services/kibana/notify.ts +++ b/x-pack/plugins/canvas/public/services/kibana/notify.ts @@ -8,7 +8,7 @@ import { get } from 'lodash'; import { KibanaPluginServiceFactory } from '../../../../../../src/plugins/presentation_util/public'; -import { formatMsg } from '../../../../../../src/plugins/kibana_legacy/public'; +import { formatMsg } from '../../lib/format_msg'; import { ToastInputFields } from '../../../../../../src/core/public'; import { CanvasStartDeps } from '../../plugin'; import { CanvasNotifyService } from '../notify'; diff --git a/x-pack/plugins/canvas/storybook/canvas.webpack.ts b/x-pack/plugins/canvas/storybook/canvas.webpack.ts index f4980741cc3e2..db59af20440e2 100644 --- a/x-pack/plugins/canvas/storybook/canvas.webpack.ts +++ b/x-pack/plugins/canvas/storybook/canvas.webpack.ts @@ -45,7 +45,6 @@ export const canvasWebpack = { test: [ resolve(KIBANA_ROOT, 'x-pack/plugins/canvas/public/components/embeddable_flyout'), resolve(KIBANA_ROOT, 'x-pack/plugins/reporting/public'), - resolve(KIBANA_ROOT, 'src/plugins/kibana_legacy/public/paginate'), ], use: 'null-loader', }, diff --git a/x-pack/plugins/canvas/tsconfig.json b/x-pack/plugins/canvas/tsconfig.json index 5064bac975a9c..f0dd93fa0f7a0 100644 --- a/x-pack/plugins/canvas/tsconfig.json +++ b/x-pack/plugins/canvas/tsconfig.json @@ -39,7 +39,6 @@ { "path": "../../../src/plugins/expression_shape/tsconfig.json" }, { "path": "../../../src/plugins/home/tsconfig.json" }, { "path": "../../../src/plugins/inspector/tsconfig.json" }, - { "path": "../../../src/plugins/kibana_legacy/tsconfig.json" }, { "path": "../../../src/plugins/kibana_react/tsconfig.json" }, { "path": "../../../src/plugins/kibana_utils/tsconfig.json" }, { "path": "../../../src/plugins/presentation_util/tsconfig.json" }, diff --git a/x-pack/plugins/graph/kibana.json b/x-pack/plugins/graph/kibana.json index 03729c706df25..e8b651a9eb0ea 100644 --- a/x-pack/plugins/graph/kibana.json +++ b/x-pack/plugins/graph/kibana.json @@ -8,8 +8,7 @@ "licensing", "data", "navigation", - "savedObjects", - "kibanaLegacy" + "savedObjects" ], "optionalPlugins": [ "home", diff --git a/x-pack/plugins/graph/public/application.ts b/x-pack/plugins/graph/public/application.ts index fc6c6170509d9..5a7f931538bf6 100644 --- a/x-pack/plugins/graph/public/application.ts +++ b/x-pack/plugins/graph/public/application.ts @@ -25,9 +25,9 @@ import { LicensingPluginStart } from '../../licensing/public'; import { checkLicense } from '../common/check_license'; import { NavigationPublicPluginStart as NavigationStart } from '../../../../src/plugins/navigation/public'; import { Storage } from '../../../../src/plugins/kibana_utils/public'; -import { KibanaLegacyStart } from '../../../../src/plugins/kibana_legacy/public'; import './index.scss'; +import('./font_awesome'); import { SavedObjectsStart } from '../../../../src/plugins/saved_objects/public'; import { GraphSavePolicy } from './types'; import { graphRouter } from './router'; @@ -60,18 +60,16 @@ export interface GraphDependencies { graphSavePolicy: GraphSavePolicy; overlays: OverlayStart; savedObjects: SavedObjectsStart; - kibanaLegacy: KibanaLegacyStart; setHeaderActionMenu: AppMountParameters['setHeaderActionMenu']; uiSettings: IUiSettingsClient; history: ScopedHistory; spaces?: SpacesApi; } -export type GraphServices = Omit; +export type GraphServices = Omit; -export const renderApp = ({ history, kibanaLegacy, element, ...deps }: GraphDependencies) => { +export const renderApp = ({ history, element, ...deps }: GraphDependencies) => { const { chrome, capabilities } = deps; - kibanaLegacy.loadFontAwesome(); if (!capabilities.graph.save) { chrome.setBadge({ diff --git a/src/plugins/kibana_legacy/public/font_awesome/font_awesome.scss b/x-pack/plugins/graph/public/font_awesome/font_awesome.scss similarity index 100% rename from src/plugins/kibana_legacy/public/font_awesome/font_awesome.scss rename to x-pack/plugins/graph/public/font_awesome/font_awesome.scss diff --git a/src/plugins/kibana_legacy/public/font_awesome/index.ts b/x-pack/plugins/graph/public/font_awesome/index.ts similarity index 50% rename from src/plugins/kibana_legacy/public/font_awesome/index.ts rename to x-pack/plugins/graph/public/font_awesome/index.ts index 3a2a6fb94dd9b..162622c9dc526 100644 --- a/src/plugins/kibana_legacy/public/font_awesome/index.ts +++ b/x-pack/plugins/graph/public/font_awesome/index.ts @@ -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 './font_awesome.scss'; diff --git a/x-pack/plugins/graph/public/plugin.ts b/x-pack/plugins/graph/public/plugin.ts index a1bc8a93f7f7a..1782f8202c415 100644 --- a/x-pack/plugins/graph/public/plugin.ts +++ b/x-pack/plugins/graph/public/plugin.ts @@ -20,7 +20,6 @@ import { } from '../../../../src/core/public'; import { Storage } from '../../../../src/plugins/kibana_utils/public'; -import { KibanaLegacyStart } from '../../../../src/plugins/kibana_legacy/public'; import { NavigationPublicPluginStart as NavigationStart } from '../../../../src/plugins/navigation/public'; import { DataPublicPluginStart } from '../../../../src/plugins/data/public'; @@ -43,7 +42,6 @@ export interface GraphPluginStartDependencies { licensing: LicensingPluginStart; data: DataPublicPluginStart; savedObjects: SavedObjectsStart; - kibanaLegacy: KibanaLegacyStart; home?: HomePublicPluginStart; spaces?: SpacesApi; } @@ -99,7 +97,6 @@ export class GraphPlugin coreStart, navigation: pluginsStart.navigation, data: pluginsStart.data, - kibanaLegacy: pluginsStart.kibanaLegacy, savedObjectsClient: coreStart.savedObjects.client, addBasePath: core.http.basePath.prepend, getBasePath: core.http.basePath.get, diff --git a/x-pack/plugins/graph/tsconfig.json b/x-pack/plugins/graph/tsconfig.json index 6a5623b311d5e..bd7e4907ed4e4 100644 --- a/x-pack/plugins/graph/tsconfig.json +++ b/x-pack/plugins/graph/tsconfig.json @@ -21,7 +21,6 @@ { "path": "../../../src/plugins/data/tsconfig.json"}, { "path": "../../../src/plugins/navigation/tsconfig.json" }, { "path": "../../../src/plugins/saved_objects/tsconfig.json"}, - { "path": "../../../src/plugins/kibana_legacy/tsconfig.json"}, { "path": "../../../src/plugins/home/tsconfig.json"}, { "path": "../../../src/plugins/kibana_utils/tsconfig.json" }, { "path": "../../../src/plugins/kibana_react/tsconfig.json" }, diff --git a/x-pack/plugins/ml/kibana.json b/x-pack/plugins/ml/kibana.json index 9ed05bbdc2edf..577e41b8816cd 100644 --- a/x-pack/plugins/ml/kibana.json +++ b/x-pack/plugins/ml/kibana.json @@ -16,7 +16,6 @@ "share", "embeddable", "uiActions", - "kibanaLegacy", "discover", "triggersActionsUi", "fieldFormats" diff --git a/x-pack/plugins/ml/public/__mocks__/ml_start_deps.ts b/x-pack/plugins/ml/public/__mocks__/ml_start_deps.ts index 4bbbe10df7f6c..42cbb4bf3485b 100644 --- a/x-pack/plugins/ml/public/__mocks__/ml_start_deps.ts +++ b/x-pack/plugins/ml/public/__mocks__/ml_start_deps.ts @@ -7,7 +7,6 @@ import { uiActionsPluginMock } from '../../../../../src/plugins/ui_actions/public/mocks'; import { dataPluginMock } from '../../../../../src/plugins/data/public/mocks'; -import { kibanaLegacyPluginMock } from '../../../../../src/plugins/kibana_legacy/public/mocks'; import { sharePluginMock } from '../../../../../src/plugins/share/public/mocks'; import { embeddablePluginMock } from '../../../../../src/plugins/embeddable/public/mocks'; import { triggersActionsUiMock } from '../../../triggers_actions_ui/public/mocks'; @@ -15,7 +14,6 @@ import { triggersActionsUiMock } from '../../../triggers_actions_ui/public/mocks export const createMlStartDepsMock = () => ({ data: dataPluginMock.createStartContract(), share: sharePluginMock.createStartContract(), - kibanaLegacy: kibanaLegacyPluginMock.createStartContract(), uiActions: uiActionsPluginMock.createStartContract(), spaces: jest.fn(), embeddable: embeddablePluginMock.createStartContract(), diff --git a/x-pack/plugins/ml/public/plugin.ts b/x-pack/plugins/ml/public/plugin.ts index e5346b6618098..59419303d7a6f 100644 --- a/x-pack/plugins/ml/public/plugin.ts +++ b/x-pack/plugins/ml/public/plugin.ts @@ -25,7 +25,6 @@ import type { SpacesPluginStart } from '../../spaces/public'; import { AppStatus, AppUpdater, DEFAULT_APP_CATEGORIES } from '../../../../src/core/public'; import type { UiActionsSetup, UiActionsStart } from '../../../../src/plugins/ui_actions/public'; -import type { KibanaLegacyStart } from '../../../../src/plugins/kibana_legacy/public'; import type { LicenseManagementUIPluginSetup } from '../../license_management/public'; import type { LicensingPluginSetup } from '../../licensing/public'; @@ -54,7 +53,6 @@ import type { export interface MlStartDependencies { data: DataPublicPluginStart; share: SharePluginStart; - kibanaLegacy: KibanaLegacyStart; uiActions: UiActionsStart; spaces?: SpacesPluginStart; embeddable: EmbeddableStart; @@ -109,7 +107,6 @@ export class MlPlugin implements Plugin { { data: pluginsStart.data, share: pluginsStart.share, - kibanaLegacy: pluginsStart.kibanaLegacy, security: pluginsSetup.security, licensing: pluginsSetup.licensing, management: pluginsSetup.management, diff --git a/x-pack/plugins/monitoring/kibana.json b/x-pack/plugins/monitoring/kibana.json index bc0cf47181585..d10d8d674fcaf 100644 --- a/x-pack/plugins/monitoring/kibana.json +++ b/x-pack/plugins/monitoring/kibana.json @@ -24,7 +24,6 @@ "kibanaUtils", "home", "alerting", - "kibanaReact", - "kibanaLegacy" + "kibanaReact" ] } diff --git a/x-pack/plugins/monitoring/public/application/hooks/use_request_error_handler.tsx b/x-pack/plugins/monitoring/public/application/hooks/use_request_error_handler.tsx index b4c2a4e86d374..4da427156c19d 100644 --- a/x-pack/plugins/monitoring/public/application/hooks/use_request_error_handler.tsx +++ b/x-pack/plugins/monitoring/public/application/hooks/use_request_error_handler.tsx @@ -10,7 +10,7 @@ import { includes } from 'lodash'; import { IHttpFetchError, ResponseErrorBody } from 'kibana/public'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiButton, EuiSpacer, EuiText } from '@elastic/eui'; -import { formatMsg } from '../../../../../../src/plugins/kibana_legacy/public'; +import { formatMsg } from '../../lib/format_msg'; import { toMountPoint, useKibana } from '../../../../../../src/plugins/kibana_react/public'; import { MonitoringStartPluginDependencies } from '../../types'; diff --git a/x-pack/plugins/monitoring/public/lib/ajax_error_handler.tsx b/x-pack/plugins/monitoring/public/lib/ajax_error_handler.tsx index 33bf10d59fb42..2622a6c9e553d 100644 --- a/x-pack/plugins/monitoring/public/lib/ajax_error_handler.tsx +++ b/x-pack/plugins/monitoring/public/lib/ajax_error_handler.tsx @@ -10,7 +10,7 @@ import { includes } from 'lodash'; import { EuiButton, EuiSpacer, EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { Legacy } from '../legacy_shims'; -import { formatMsg } from '../../../../../src/plugins/kibana_legacy/public'; +import { formatMsg } from './format_msg'; import { toMountPoint } from '../../../../../src/plugins/kibana_react/public'; export function formatMonitoringError(err: any) { diff --git a/x-pack/plugins/monitoring/public/lib/format_msg.test.ts b/x-pack/plugins/monitoring/public/lib/format_msg.test.ts new file mode 100644 index 0000000000000..0643e2a6f2b95 --- /dev/null +++ b/x-pack/plugins/monitoring/public/lib/format_msg.test.ts @@ -0,0 +1,122 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import expect from '@kbn/expect'; +import { formatMsg, formatESMsg } from './format_msg'; + +describe('formatMsg', () => { + test('should prepend the second argument to result', () => { + const actual = formatMsg('error message', 'unit_test'); + + expect(actual).to.equal('unit_test: error message'); + }); + + test('should handle a simple string', () => { + const actual = formatMsg('error message'); + + expect(actual).to.equal('error message'); + }); + + test('should handle a simple Error object', () => { + const err = new Error('error message'); + const actual = formatMsg(err); + + expect(actual).to.equal('error message'); + }); + + test('should handle a simple Angular $http error object', () => { + const err = { + data: { + statusCode: 403, + error: 'Forbidden', + message: + '[security_exception] action [indices:data/read/msearch] is unauthorized for user [user]', + }, + status: 403, + config: {}, + statusText: 'Forbidden', + }; + const actual = formatMsg(err); + + expect(actual).to.equal( + 'Error 403 Forbidden: [security_exception] action [indices:data/read/msearch] is unauthorized for user [user]' + ); + }); + + test('should handle an extended elasticsearch error', () => { + const err = { + resp: { + error: { + root_cause: [ + { + reason: 'I am the detailed message', + }, + ], + }, + }, + }; + + const actual = formatMsg(err); + + expect(actual).to.equal('I am the detailed message'); + }); + + describe('formatESMsg', () => { + test('should return undefined if passed a basic error', () => { + const err = new Error('This is a normal error'); + + const actual = formatESMsg(err); + + expect(actual).to.be(undefined); + }); + + test('should return undefined if passed a string', () => { + const err = 'This is a error string'; + + const actual = formatESMsg(err); + + expect(actual).to.be(undefined); + }); + + test('should return the root_cause if passed an extended elasticsearch', () => { + const err: Record = new Error('This is an elasticsearch error'); + err.resp = { + error: { + root_cause: [ + { + reason: 'I am the detailed message', + }, + ], + }, + }; + + const actual = formatESMsg(err); + + expect(actual).to.equal('I am the detailed message'); + }); + + test('should combine the reason messages if more than one is returned.', () => { + const err: Record = new Error('This is an elasticsearch error'); + err.resp = { + error: { + root_cause: [ + { + reason: 'I am the detailed message 1', + }, + { + reason: 'I am the detailed message 2', + }, + ], + }, + }; + + const actual = formatESMsg(err); + + expect(actual).to.equal('I am the detailed message 1\nI am the detailed message 2'); + }); + }); +}); diff --git a/x-pack/plugins/monitoring/public/lib/format_msg.ts b/x-pack/plugins/monitoring/public/lib/format_msg.ts new file mode 100644 index 0000000000000..97ba63546a9e4 --- /dev/null +++ b/x-pack/plugins/monitoring/public/lib/format_msg.ts @@ -0,0 +1,84 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import _ from 'lodash'; +import { i18n } from '@kbn/i18n'; +const has = _.has; + +const getRootCause = (err: Record | string) => _.get(err, 'resp.error.root_cause'); + +/** + * Utilize the extended error information returned from elasticsearch + * @param {Error|String} err + * @returns {string} + */ +export const formatESMsg = (err: Record | string) => { + const rootCause = getRootCause(err); + + if (!Array.isArray(rootCause)) { + return; + } + + return rootCause.map((cause: Record) => cause.reason).join('\n'); +}; + +/** + * Formats the error message from an error object, extended elasticsearch + * object or simple string; prepends optional second parameter to the message + * @param {Error|String} err + * @param {String} source - Prefix for message indicating source (optional) + * @returns {string} + */ +export function formatMsg(err: Record | string, source: string = '') { + let message = ''; + if (source) { + message += source + ': '; + } + + const esMsg = formatESMsg(err); + + if (typeof err === 'string') { + message += err; + } else if (esMsg) { + message += esMsg; + } else if (err instanceof Error) { + message += formatMsg.describeError(err); + } else if (has(err, 'status') && has(err, 'data')) { + // is an Angular $http "error object" + if (err.status === -1) { + // status = -1 indicates that the request was failed to reach the server + message += i18n.translate( + 'xpack.monitoring.formatMsg.toaster.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.', + } + ); + } else { + message += i18n.translate('xpack.monitoring.formatMsg.toaster.errorStatusMessage', { + defaultMessage: 'Error {errStatus} {errStatusText}: {errMessage}', + values: { + errStatus: err.status, + errStatusText: err.statusText, + errMessage: err.data.message, + }, + }); + } + } + + return message; +} + +formatMsg.describeError = function (err: Record) { + if (!err) return undefined; + if (err.shortMessage) return err.shortMessage; + if (err.body && err.body.message) return err.body.message; + if (err.message) return err.message; + return '' + err; +}; diff --git a/x-pack/plugins/monitoring/tsconfig.json b/x-pack/plugins/monitoring/tsconfig.json index 756b8528865ce..79fcff4d840ff 100644 --- a/x-pack/plugins/monitoring/tsconfig.json +++ b/x-pack/plugins/monitoring/tsconfig.json @@ -15,7 +15,6 @@ { "path": "../../../src/core/tsconfig.json" }, { "path": "../../../src/plugins/data/tsconfig.json" }, { "path": "../../../src/plugins/home/tsconfig.json" }, - { "path": "../../../src/plugins/kibana_legacy/tsconfig.json" }, { "path": "../../../src/plugins/navigation/tsconfig.json" }, { "path": "../../../src/plugins/kibana_react/tsconfig.json" }, { "path": "../../../src/plugins/kibana_utils/tsconfig.json" }, diff --git a/x-pack/plugins/runtime_fields/tsconfig.json b/x-pack/plugins/runtime_fields/tsconfig.json index 5dc704ec57693..321854e2d7bbe 100644 --- a/x-pack/plugins/runtime_fields/tsconfig.json +++ b/x-pack/plugins/runtime_fields/tsconfig.json @@ -13,6 +13,5 @@ "references": [ { "path": "../../../src/core/tsconfig.json" }, { "path": "../../../src/plugins/es_ui_shared/tsconfig.json" }, - { "path": "../../../src/plugins/kibana_legacy/tsconfig.json"} ] } diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index bb8db5a11fb28..6c685f7ec71ea 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -3442,8 +3442,6 @@ "kbnConfig.deprecations.replacedSettingMessage": "\"{fullOldPath}\"設定は\"{fullNewPath}\"で置換されました", "kbnConfig.deprecations.unusedSetting.manualStepOneMessage": "Kibana構成ファイル、CLIフラグ、または環境変数(Dockerのみ)から\"{fullPath}\"を削除します。", "kbnConfig.deprecations.unusedSettingMessage": "\"{fullPath}\"を構成する必要はありません。", - "kibana_legacy.notify.toaster.errorStatusMessage": "エラー {errStatus} {errStatusText}: {errMessage}", - "kibana_legacy.notify.toaster.unavailableServerErrorMessage": "HTTP リクエストで接続に失敗しました。Kibana サーバーが実行されていて、ご使用のブラウザの接続が正常に動作していることを確認するか、システム管理者にお問い合わせください。", "kibana_utils.history.savedObjectIsMissingNotificationMessage": "保存されたオブジェクトがありません", "kibana_utils.stateManagement.stateHash.unableToRestoreUrlErrorMessage": "URL を完全に復元できません。共有機能を使用していることを確認してください。", "kibana_utils.stateManagement.stateHash.unableToStoreHistoryInSessionErrorMessage": "セッションがいっぱいで安全に削除できるアイテムが見つからないため、Kibana は履歴アイテムを保存できません。\n\nこれは大抵新規タブに移動することで解決されますが、より大きな問題が原因である可能性もあります。このメッセージが定期的に表示される場合は、{gitHubIssuesUrl} で問題を報告してください。", @@ -7526,6 +7524,8 @@ "xpack.canvas.workpadTemplates.table.descriptionColumnTitle": "説明", "xpack.canvas.workpadTemplates.table.nameColumnTitle": "テンプレート名", "xpack.canvas.workpadTemplates.table.tagsColumnTitle": "タグ", + "xpack.canvas.formatMsg.toaster.errorStatusMessage": "错误 {errStatus} {errStatusText}:{errMessage}", + "xpack.canvas.formatMsg.toaster.unavailableServerErrorMessage": "HTTP 请求无法连接。请检查 Kibana 服务器是否正在运行以及您的浏览器是否具有有效的连接,或请联系您的系统管理员。", "xpack.cases.addConnector.title": "コネクターの追加", "xpack.cases.allCases.actions": "アクション", "xpack.cases.allCases.comments": "コメント", @@ -19279,6 +19279,8 @@ "xpack.monitoring.updateLicenseButtonLabel": "ライセンスを更新", "xpack.monitoring.updateLicenseTitle": "ライセンスの更新", "xpack.monitoring.useAvailableLicenseDescription": "すでに新しいライセンスがある場合は、今すぐアップロードしてください。", + "xpack.monitoring.formatMsg.toaster.errorStatusMessage": "错误 {errStatus} {errStatusText}:{errMessage}", + "xpack.monitoring.formatMsg.toaster.unavailableServerErrorMessage": "HTTP 请求无法连接。请检查 Kibana 服务器是否正在运行以及您的浏览器是否具有有效的连接,或请联系您的系统管理员。", "xpack.observability..synthetics.addDataButtonLabel": "Syntheticsデータの追加", "xpack.observability.alerts.manageRulesButtonLabel": "ルールの管理", "xpack.observability.alerts.searchBarPlaceholder": "検索アラート(例:kibana.alert.evaluation.threshold > 75)", @@ -27689,4 +27691,4 @@ "xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "フィールドを選択してください。", "xpack.watcher.watcherDescription": "アラートの作成、管理、監視によりデータへの変更を検知します。" } -} +} \ No newline at end of file diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 7804ac6f2340f..36febdb69d227 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -3467,8 +3467,6 @@ "kbnConfig.deprecations.replacedSettingMessage": "设置“{fullOldPath}”已替换为“{fullNewPath}”", "kbnConfig.deprecations.unusedSetting.manualStepOneMessage": "从 Kibana 配置文件、CLI 标志或环境变量中移除“{fullPath}”(仅适用于 Docker)。", "kbnConfig.deprecations.unusedSettingMessage": "您不再需要配置“{fullPath}”。", - "kibana_legacy.notify.toaster.errorStatusMessage": "错误 {errStatus} {errStatusText}:{errMessage}", - "kibana_legacy.notify.toaster.unavailableServerErrorMessage": "HTTP 请求无法连接。请检查 Kibana 服务器是否正在运行以及您的浏览器是否具有有效的连接,或请联系您的系统管理员。", "kibana_utils.history.savedObjectIsMissingNotificationMessage": "已保存对象缺失", "kibana_utils.stateManagement.stateHash.unableToRestoreUrlErrorMessage": "无法完全还原 URL,请确保使用共享功能。", "kibana_utils.stateManagement.stateHash.unableToStoreHistoryInSessionErrorMessage": "Kibana 无法将历史记录项存储在您的会话中,因为其已满,另外,似乎没有任何可安全删除的项目。\n\n通常,这可以通过移到全新的选项卡来解决,但这种情况可能是由更大的问题造成。如果您定期看到这个消息,请在 {gitHubIssuesUrl} 报告问题。", @@ -7581,6 +7579,8 @@ "xpack.canvas.workpadTemplates.table.descriptionColumnTitle": "描述", "xpack.canvas.workpadTemplates.table.nameColumnTitle": "模板名称", "xpack.canvas.workpadTemplates.table.tagsColumnTitle": "标签", + "xpack.canvas.formatMsg.toaster.errorStatusMessage": "错误 {errStatus} {errStatusText}:{errMessage}", + "xpack.canvas.formatMsg.toaster.unavailableServerErrorMessage": "HTTP 请求无法连接。请检查 Kibana 服务器是否正在运行以及您的浏览器是否具有有效的连接,或请联系您的系统管理员。", "xpack.cases.addConnector.title": "添加连接器", "xpack.cases.allCases.actions": "操作", "xpack.cases.allCases.comments": "注释", @@ -19561,6 +19561,8 @@ "xpack.monitoring.updateLicenseButtonLabel": "更新许可证", "xpack.monitoring.updateLicenseTitle": "更新您的许可证", "xpack.monitoring.useAvailableLicenseDescription": "如果您已经持有新的许可证,请立即上传。", + "xpack.monitoring.formatMsg.toaster.errorStatusMessage": "错误 {errStatus} {errStatusText}:{errMessage}", + "xpack.monitoring.formatMsg.toaster.unavailableServerErrorMessage": "HTTP 请求无法连接。请检查 Kibana 服务器是否正在运行以及您的浏览器是否具有有效的连接,或请联系您的系统管理员。", "xpack.observability..synthetics.addDataButtonLabel": "添加 Synthetics 数据", "xpack.observability.alerts.manageRulesButtonLabel": "管理规则", "xpack.observability.alerts.searchBarPlaceholder": "搜索告警(例如 kibana.alert.evaluation.threshold > 75)",