diff --git a/docs/development/core/public/kibana-plugin-core-public.appmountparameters.onappleave.md b/docs/development/core/public/kibana-plugin-core-public.appmountparameters.onappleave.md index 7f72d6a52fc2..e898126a553e 100644 --- a/docs/development/core/public/kibana-plugin-core-public.appmountparameters.onappleave.md +++ b/docs/development/core/public/kibana-plugin-core-public.appmountparameters.onappleave.md @@ -23,10 +23,10 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { BrowserRouter, Route } from 'react-router-dom'; -import { CoreStart, AppMountParams } from 'src/core/public'; +import { CoreStart, AppMountParameters } from 'src/core/public'; import { MyPluginDepsStart } from './plugin'; -export renderApp = ({ element, history, onAppLeave }: AppMountParams) => { +export renderApp = ({ element, history, onAppLeave }: AppMountParameters) => { const { renderApp, hasUnsavedChanges } = await import('./application'); onAppLeave(actions => { if(hasUnsavedChanges()) { diff --git a/package.json b/package.json index cc1f7eb6c1dd..1201a1773e6c 100644 --- a/package.json +++ b/package.json @@ -130,7 +130,7 @@ "@elastic/eui": "23.3.1", "@elastic/filesaver": "1.1.2", "@elastic/good": "8.1.1-kibana2", - "@elastic/numeral": "2.4.0", + "@elastic/numeral": "^2.5.0", "@elastic/request-crypto": "1.1.4", "@elastic/ui-ace": "0.2.3", "@hapi/good-squeeze": "5.2.1", @@ -365,7 +365,6 @@ "@types/node": ">=10.17.17 <10.20.0", "@types/node-forge": "^0.9.0", "@types/normalize-path": "^3.0.0", - "@types/numeral": "^0.0.26", "@types/opn": "^5.1.0", "@types/pegjs": "^0.10.1", "@types/pngjs": "^3.3.2", diff --git a/packages/eslint-config-kibana/.eslintrc.js b/packages/eslint-config-kibana/.eslintrc.js index 624ee4679a3b..747c2c14ab25 100644 --- a/packages/eslint-config-kibana/.eslintrc.js +++ b/packages/eslint-config-kibana/.eslintrc.js @@ -39,6 +39,10 @@ module.exports = { to: false, disallowedMessage: `Don't use 'mkdirp', use the new { recursive: true } option of Fs.mkdir instead` }, + { + from: 'numeral', + to: '@elastic/numeral', + }, { from: '@kbn/elastic-idx', to: false, diff --git a/packages/kbn-ui-shared-deps/entry.js b/packages/kbn-ui-shared-deps/entry.js index 26efd174f4e3..ab044a6723da 100644 --- a/packages/kbn-ui-shared-deps/entry.js +++ b/packages/kbn-ui-shared-deps/entry.js @@ -44,6 +44,7 @@ Moment.tz.load(require('moment-timezone/data/packed/latest.json')); // big deps which are locked to a single version export const Rxjs = require('rxjs'); export const RxjsOperators = require('rxjs/operators'); +export const ElasticNumeral = require('@elastic/numeral'); export const ElasticCharts = require('@elastic/charts'); export const ElasticEui = require('@elastic/eui'); export const ElasticEuiLibServices = require('@elastic/eui/lib/services'); diff --git a/packages/kbn-ui-shared-deps/index.js b/packages/kbn-ui-shared-deps/index.js index 9aec3ab35992..eb3add68e286 100644 --- a/packages/kbn-ui-shared-deps/index.js +++ b/packages/kbn-ui-shared-deps/index.js @@ -51,6 +51,8 @@ exports.externals = { */ rxjs: '__kbnSharedDeps__.Rxjs', 'rxjs/operators': '__kbnSharedDeps__.RxjsOperators', + numeral: '__kbnSharedDeps__.ElasticNumeral', + '@elastic/numeral': '__kbnSharedDeps__.ElasticNumeral', '@elastic/charts': '__kbnSharedDeps__.ElasticCharts', '@elastic/eui': '__kbnSharedDeps__.ElasticEui', '@elastic/eui/lib/services': '__kbnSharedDeps__.ElasticEuiLibServices', diff --git a/packages/kbn-ui-shared-deps/package.json b/packages/kbn-ui-shared-deps/package.json index 4e6bec92a65e..93afa303c8ca 100644 --- a/packages/kbn-ui-shared-deps/package.json +++ b/packages/kbn-ui-shared-deps/package.json @@ -11,6 +11,7 @@ "dependencies": { "@elastic/charts": "19.2.0", "@elastic/eui": "23.3.1", + "@elastic/numeral": "^2.5.0", "@kbn/i18n": "1.0.0", "abortcontroller-polyfill": "^1.4.0", "angular": "^1.7.9", diff --git a/renovate.json5 b/renovate.json5 index 9a2ac20f91f0..674c4e0df790 100644 --- a/renovate.json5 +++ b/renovate.json5 @@ -715,14 +715,6 @@ '@types/normalize-path', ], }, - { - groupSlug: 'numeral', - groupName: 'numeral related packages', - packageNames: [ - 'numeral', - '@types/numeral', - ], - }, { groupSlug: 'object-hash', groupName: 'object-hash related packages', diff --git a/src/core/CONVENTIONS.md b/src/core/CONVENTIONS.md index 447c6f396945..798977354f27 100644 --- a/src/core/CONVENTIONS.md +++ b/src/core/CONVENTIONS.md @@ -167,17 +167,21 @@ leverage this pattern. import React from 'react'; import ReactDOM from 'react-dom'; -import { CoreStart, AppMountParams } from '../../src/core/public'; +import { CoreStart, AppMountParameters } from 'src/core/public'; import { MyAppRoot } from './components/app.ts'; /** * This module will be loaded asynchronously to reduce the bundle size of your plugin's main bundle. */ -export const renderApp = (core: CoreStart, deps: MyPluginDepsStart, { element, history }: AppMountParams) => { +export const renderApp = ( + core: CoreStart, + deps: MyPluginDepsStart, + { element, history }: AppMountParameters +) => { ReactDOM.render(, element); return () => ReactDOM.unmountComponentAtNode(element); -} +}; ``` ```ts diff --git a/src/core/TESTING.md b/src/core/TESTING.md index cb38dac0e20c..bed41ab58349 100644 --- a/src/core/TESTING.md +++ b/src/core/TESTING.md @@ -475,10 +475,14 @@ The more interesting logic is in `renderApp`: import React from 'react'; import ReactDOM from 'react-dom'; -import { AppMountParams, CoreStart } from 'src/core/public'; +import { AppMountParameters, CoreStart } from 'src/core/public'; import { AppRoot } from './components/app_root'; -export const renderApp = ({ element, history }: AppMountParams, core: CoreStart, plugins: MyPluginDepsStart) => { +export const renderApp = ( + { element, history }: AppMountParameters, + core: CoreStart, + plugins: MyPluginDepsStart +) => { // Hide the chrome while this app is mounted for a full screen experience core.chrome.setIsVisible(false); diff --git a/src/core/public/application/scoped_history.ts b/src/core/public/application/scoped_history.ts index 1a7fafa5d85c..4392cf4eca8d 100644 --- a/src/core/public/application/scoped_history.ts +++ b/src/core/public/application/scoped_history.ts @@ -197,7 +197,7 @@ export class ScopedHistory prompt?: boolean | string | TransitionPromptHook ): UnregisterCallback => { throw new Error( - `history.block is not supported. Please use the AppMountParams.onAppLeave API.` + `history.block is not supported. Please use the AppMountParameters.onAppLeave API.` ); }; diff --git a/src/core/public/application/types.ts b/src/core/public/application/types.ts index 2269fd0a4ca4..8006ec846138 100644 --- a/src/core/public/application/types.ts +++ b/src/core/public/application/types.ts @@ -453,10 +453,10 @@ export interface AppMountParameters { * import ReactDOM from 'react-dom'; * import { BrowserRouter, Route } from 'react-router-dom'; * - * import { CoreStart, AppMountParams } from 'src/core/public'; + * import { CoreStart, AppMountParameters } from 'src/core/public'; * import { MyPluginDepsStart } from './plugin'; * - * export renderApp = ({ element, history, onAppLeave }: AppMountParams) => { + * export renderApp = ({ element, history, onAppLeave }: AppMountParameters) => { * const { renderApp, hasUnsavedChanges } = await import('./application'); * onAppLeave(actions => { * if(hasUnsavedChanges()) { diff --git a/src/legacy/core_plugins/status_page/public/components/__snapshots__/metric_tiles.test.js.snap b/src/legacy/core_plugins/status_page/public/components/__snapshots__/metric_tiles.test.js.snap index b88210758a00..7d4b245021c4 100644 --- a/src/legacy/core_plugins/status_page/public/components/__snapshots__/metric_tiles.test.js.snap +++ b/src/legacy/core_plugins/status_page/public/components/__snapshots__/metric_tiles.test.js.snap @@ -4,7 +4,7 @@ exports[`byte metric 1`] = ` `; diff --git a/src/legacy/core_plugins/status_page/public/components/metric_tiles.test.js b/src/legacy/core_plugins/status_page/public/components/metric_tiles.test.js index 74dfbd4119f1..13d0a61bbc96 100644 --- a/src/legacy/core_plugins/status_page/public/components/metric_tiles.test.js +++ b/src/legacy/core_plugins/status_page/public/components/metric_tiles.test.js @@ -47,20 +47,20 @@ const MS_METRIC = { test('general metric', () => { const component = shallow(); - expect(component).toMatchSnapshot(); // eslint-disable-line + expect(component).toMatchSnapshot(); }); test('byte metric', () => { const component = shallow(); - expect(component).toMatchSnapshot(); // eslint-disable-line + expect(component).toMatchSnapshot(); }); test('float metric', () => { const component = shallow(); - expect(component).toMatchSnapshot(); // eslint-disable-line + expect(component).toMatchSnapshot(); }); test('millisecond metric', () => { const component = shallow(); - expect(component).toMatchSnapshot(); // eslint-disable-line + expect(component).toMatchSnapshot(); }); diff --git a/src/legacy/core_plugins/status_page/public/lib/format_number.js b/src/legacy/core_plugins/status_page/public/lib/format_number.js index c5f23a9a9ef6..4a8be4fc48a1 100644 --- a/src/legacy/core_plugins/status_page/public/lib/format_number.js +++ b/src/legacy/core_plugins/status_page/public/lib/format_number.js @@ -17,7 +17,7 @@ * under the License. */ -import numeral from 'numeral'; +import numeral from '@elastic/numeral'; export default function formatNumber(num, which) { let format = '0.00'; diff --git a/src/legacy/core_plugins/status_page/public/lib/format_number.test.js b/src/legacy/core_plugins/status_page/public/lib/format_number.test.js index 78f17ffa76f3..f70377dcba24 100644 --- a/src/legacy/core_plugins/status_page/public/lib/format_number.test.js +++ b/src/legacy/core_plugins/status_page/public/lib/format_number.test.js @@ -21,42 +21,42 @@ import formatNumber from './format_number'; describe('format byte', () => { test('zero', () => { - expect(formatNumber(0, 'byte')).toEqual('0.00 B'); + expect(formatNumber(0, 'byte')).toMatchInlineSnapshot(`"0.00 B"`); }); test('mb', () => { - expect(formatNumber(181142512, 'byte')).toEqual('181.14 MB'); + expect(formatNumber(181142512, 'byte')).toMatchInlineSnapshot(`"172.75 MB"`); }); test('gb', () => { - expect(formatNumber(273727485000, 'byte')).toEqual('273.73 GB'); + expect(formatNumber(273727485000, 'byte')).toMatchInlineSnapshot(`"254.93 GB"`); }); }); describe('format ms', () => { test('zero', () => { - expect(formatNumber(0, 'ms')).toEqual('0.00 ms'); + expect(formatNumber(0, 'ms')).toMatchInlineSnapshot(`"0.00 ms"`); }); test('sub ms', () => { - expect(formatNumber(0.128, 'ms')).toEqual('0.13 ms'); + expect(formatNumber(0.128, 'ms')).toMatchInlineSnapshot(`"0.13 ms"`); }); test('many ms', () => { - expect(formatNumber(3030.284, 'ms')).toEqual('3030.28 ms'); + expect(formatNumber(3030.284, 'ms')).toMatchInlineSnapshot(`"3030.28 ms"`); }); }); describe('format integer', () => { test('zero', () => { - expect(formatNumber(0, 'integer')).toEqual('0'); + expect(formatNumber(0, 'integer')).toMatchInlineSnapshot(`"0"`); }); test('sub integer', () => { - expect(formatNumber(0.728, 'integer')).toEqual('1'); + expect(formatNumber(0.728, 'integer')).toMatchInlineSnapshot(`"1"`); }); test('many integer', () => { - expect(formatNumber(3030.284, 'integer')).toEqual('3030'); + expect(formatNumber(3030.284, 'integer')).toMatchInlineSnapshot(`"3030"`); }); }); diff --git a/src/plugins/advanced_settings/public/management_app/lib/get_category_name.ts b/src/plugins/advanced_settings/public/management_app/lib/get_category_name.ts index 567613e713de..31df6875c97d 100644 --- a/src/plugins/advanced_settings/public/management_app/lib/get_category_name.ts +++ b/src/plugins/advanced_settings/public/management_app/lib/get_category_name.ts @@ -47,7 +47,7 @@ const names: Record = { defaultMessage: 'Search', }), securitySolution: i18n.translate('advancedSettings.categoryNames.securitySolutionLabel', { - defaultMessage: 'Security solution', + defaultMessage: 'Security Solution', }), }; diff --git a/src/plugins/vis_type_vislib/public/vislib/components/tooltip/_hierarchical_tooltip_formatter.js b/src/plugins/vis_type_vislib/public/vislib/components/tooltip/_hierarchical_tooltip_formatter.js index 9d8f9dccb1f0..d2cf81a1410c 100644 --- a/src/plugins/vis_type_vislib/public/vislib/components/tooltip/_hierarchical_tooltip_formatter.js +++ b/src/plugins/vis_type_vislib/public/vislib/components/tooltip/_hierarchical_tooltip_formatter.js @@ -19,7 +19,7 @@ import React from 'react'; import _ from 'lodash'; -import numeral from 'numeral'; +import numeral from '@elastic/numeral'; import { renderToStaticMarkup } from 'react-dom/server'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; diff --git a/src/plugins/vis_type_vislib/public/vislib/visualizations/pie_chart.js b/src/plugins/vis_type_vislib/public/vislib/visualizations/pie_chart.js index 8e3429a39c95..938d3d0ec6d7 100644 --- a/src/plugins/vis_type_vislib/public/vislib/visualizations/pie_chart.js +++ b/src/plugins/vis_type_vislib/public/vislib/visualizations/pie_chart.js @@ -20,7 +20,7 @@ import d3 from 'd3'; import _ from 'lodash'; import $ from 'jquery'; -import numeral from 'numeral'; +import numeral from '@elastic/numeral'; import { PieContainsAllZeros, ContainerTooSmall } from '../errors'; import { Chart } from './_chart'; import { truncateLabel } from '../components/labels/truncate_labels'; diff --git a/webpackShims/numeral.js b/webpackShims/numeral.js deleted file mode 100644 index d9551e05aa6d..000000000000 --- a/webpackShims/numeral.js +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -module.exports = require('@elastic/numeral'); diff --git a/x-pack/package.json b/x-pack/package.json index 9f69cbc40bf3..c46d364e0ac4 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -194,7 +194,7 @@ "@elastic/filesaver": "1.1.2", "@elastic/maki": "6.3.0", "@elastic/node-crypto": "1.1.1", - "@elastic/numeral": "2.4.0", + "@elastic/numeral": "^2.5.0", "@kbn/babel-preset": "1.0.0", "@kbn/config-schema": "1.0.0", "@kbn/i18n": "1.0.0", diff --git a/x-pack/plugins/apm/typings/numeral.d.ts b/x-pack/plugins/apm/typings/numeral.d.ts deleted file mode 100644 index 2616639cdeff..000000000000 --- a/x-pack/plugins/apm/typings/numeral.d.ts +++ /dev/null @@ -1,20 +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; - * you may not use this file except in compliance with the Elastic License. - */ - -interface Numeral { - (value?: unknown): Numeral; - format: (pattern: string) => string; - unformat: (pattern: string) => number; - language: (key?: any, values?: any) => Numeral; - set: (value?: any) => Numeral; -} - -// eslint-disable-next-line no-var -declare var numeral: Numeral; - -declare module '@elastic/numeral' { - export = numeral; -} diff --git a/x-pack/plugins/security_solution/server/ui_settings.ts b/x-pack/plugins/security_solution/server/ui_settings.ts index eb6243c6128d..4b5261edcdfd 100644 --- a/x-pack/plugins/security_solution/server/ui_settings.ts +++ b/x-pack/plugins/security_solution/server/ui_settings.ts @@ -40,10 +40,10 @@ export const initUiSettings = (uiSettings: CoreSetup['uiSettings']) => { 'xpack.securitySolution.uiSettings.defaultRefreshIntervalDescription', { defaultMessage: - '

Default refresh interval for the SIEM time filter, in milliseconds.

', + '

Default refresh interval for the Security time filter, in milliseconds.

', } ), - category: ['siem'], + category: ['securitySolution'], requiresPageReload: true, schema: schema.object({ value: schema.number(), @@ -60,9 +60,9 @@ export const initUiSettings = (uiSettings: CoreSetup['uiSettings']) => { "to": "${DEFAULT_TO}" }`, description: i18n.translate('xpack.securitySolution.uiSettings.defaultTimeRangeDescription', { - defaultMessage: '

Default period of time in the SIEM time filter.

', + defaultMessage: '

Default period of time in the Security time filter.

', }), - category: ['siem'], + category: ['securitySolution'], requiresPageReload: true, schema: schema.object({ from: schema.string(), @@ -76,9 +76,9 @@ export const initUiSettings = (uiSettings: CoreSetup['uiSettings']) => { value: DEFAULT_INDEX_PATTERN, description: i18n.translate('xpack.securitySolution.uiSettings.defaultIndexDescription', { defaultMessage: - '

Comma-delimited list of Elasticsearch indices from which the SIEM app collects events.

', + '

Comma-delimited list of Elasticsearch indices from which the Security app collects events.

', }), - category: ['siem'], + category: ['securitySolution'], requiresPageReload: true, schema: schema.arrayOf(schema.string()), }, @@ -92,10 +92,10 @@ export const initUiSettings = (uiSettings: CoreSetup['uiSettings']) => { 'xpack.securitySolution.uiSettings.defaultAnomalyScoreDescription', { defaultMessage: - '

Value above which Machine Learning job anomalies are displayed in the SIEM app.

Valid values: 0 to 100.

', + '

Value above which Machine Learning job anomalies are displayed in the Security app.

Valid values: 0 to 100.

', } ), - category: ['siem'], + category: ['securitySolution'], requiresPageReload: true, schema: schema.number(), }, @@ -108,7 +108,7 @@ export const initUiSettings = (uiSettings: CoreSetup['uiSettings']) => { defaultMessage: '

Enables the News feed

', }), type: 'boolean', - category: ['siem'], + category: ['securitySolution'], requiresPageReload: true, schema: schema.boolean(), }, @@ -120,7 +120,7 @@ export const initUiSettings = (uiSettings: CoreSetup['uiSettings']) => { description: i18n.translate('xpack.securitySolution.uiSettings.newsFeedUrlDescription', { defaultMessage: '

News feed content will be retrieved from this URL

', }), - category: ['siem'], + category: ['securitySolution'], requiresPageReload: true, schema: schema.string(), }, @@ -137,7 +137,7 @@ export const initUiSettings = (uiSettings: CoreSetup['uiSettings']) => { 'Array of URL templates to build the list of reputation URLs to be displayed on the IP Details page.', } ), - category: ['siem'], + category: ['securitySolution'], requiresPageReload: true, schema: schema.arrayOf( schema.object({ diff --git a/x-pack/plugins/snapshot_restore/public/application/mount_management_section.ts b/x-pack/plugins/snapshot_restore/public/application/mount_management_section.ts index 3f28e78c6028..b06a60a5c830 100644 --- a/x-pack/plugins/snapshot_restore/public/application/mount_management_section.ts +++ b/x-pack/plugins/snapshot_restore/public/application/mount_management_section.ts @@ -45,5 +45,11 @@ export async function mountManagementSection( }, }; - return renderApp(element, appDependencies); + const unmountAppCallback = renderApp(element, appDependencies); + + return () => { + // Change tab label back to Kibana. + docTitle.reset(); + unmountAppCallback(); + }; } diff --git a/yarn.lock b/yarn.lock index 5506165da2d3..892fa1b5aa56 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1413,10 +1413,10 @@ resolved "https://registry.yarnpkg.com/@elastic/node-crypto/-/node-crypto-1.1.1.tgz#619b70322c9cce4a7ee5fbf8f678b1baa7f06095" integrity sha512-F6tIk8Txdqjg8Siv60iAvXzO9ZdQI87K3sS/fh5xd2XaWK+T5ZfqeTvsT7srwG6fr6uCBfuQEJV1KBBl+JpLZA== -"@elastic/numeral@2.4.0": - version "2.4.0" - resolved "https://registry.yarnpkg.com/@elastic/numeral/-/numeral-2.4.0.tgz#883197b7f4bf3c2dd994f53b274769ddfa2bf79a" - integrity sha512-uGBKGCNghTgUZPHClji/00v+AKt5nidPTGOIbcT+lbTPVxNB6QPpPLGWtXyrg3QZAxobPM/LAZB1mAqtJeq44Q== +"@elastic/numeral@^2.5.0": + version "2.5.0" + resolved "https://registry.yarnpkg.com/@elastic/numeral/-/numeral-2.5.0.tgz#8da714827fc278f17546601fdfe55f5c920e2bc5" + integrity sha512-NVTuy9Wzblp6nOH86CXjWXTajHgJGn5Tk2l59/Z5cWFU14KlE+8/zqPTgZdxYABzBJFE3L7S07kJDMN8sDvTmA== "@elastic/request-crypto@1.1.4": version "1.1.4" @@ -4546,11 +4546,6 @@ resolved "https://registry.yarnpkg.com/@types/numeral/-/numeral-0.0.25.tgz#b6f55062827a4787fe4ab151cf3412a468e65271" integrity sha512-ShHzHkYD+Ldw3eyttptCpUhF1/mkInWwasQkCNXZHOsJMJ/UMa8wXrxSrTJaVk0r4pLK/VnESVM0wFsfQzNEKQ== -"@types/numeral@^0.0.26": - version "0.0.26" - resolved "https://registry.yarnpkg.com/@types/numeral/-/numeral-0.0.26.tgz#cfab9842ef9349ce714b06722940ca7ebf8a6298" - integrity sha512-DwCsRqeOWopdEsm5KLTxKVKDSDoj+pzZD1vlwu1GQJ6IF3RhjuleYlRwyRH6MJLGaf3v8wFTnC6wo3yYfz0bnA== - "@types/object-hash@^1.3.0": version "1.3.0" resolved "https://registry.yarnpkg.com/@types/object-hash/-/object-hash-1.3.0.tgz#b20db2074129f71829d61ff404e618c4ac3d73cf"