From c134740b2d64671949a37deb4e8cdc35e15302cb Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 14 Jun 2021 17:43:12 -0500 Subject: [PATCH 1/7] move rollup config to index pattern management --- .../index_pattern_management/public/mocks.ts | 9 +------ .../index_pattern_management/public/plugin.ts | 5 +++- .../components/rollup_prompt/index.ts | 5 ++-- .../rollup_prompt/rollup_prompt.tsx | 5 ++-- .../public/service/creation/index.ts | 2 ++ .../creation/rollup_creation_config.js | 7 +++--- .../index_pattern_management_service.ts | 24 +++++++++++++++---- .../public/service/list/index.ts | 2 ++ .../public/service/list/rollup_list_config.js | 7 +++--- x-pack/plugins/rollup/kibana.json | 1 - x-pack/plugins/rollup/public/plugin.ts | 14 ++++------- x-pack/plugins/rollup/tsconfig.json | 1 - 12 files changed, 47 insertions(+), 35 deletions(-) rename x-pack/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/index.js => src/plugins/index_pattern_management/public/service/creation/components/rollup_prompt/index.ts (53%) rename x-pack/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/rollup_prompt.js => src/plugins/index_pattern_management/public/service/creation/components/rollup_prompt/rollup_prompt.tsx (88%) rename x-pack/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js => src/plugins/index_pattern_management/public/service/creation/rollup_creation_config.js (95%) rename x-pack/plugins/rollup/public/index_pattern_list/rollup_index_pattern_list_config.js => src/plugins/index_pattern_management/public/service/list/rollup_list_config.js (86%) diff --git a/src/plugins/index_pattern_management/public/mocks.ts b/src/plugins/index_pattern_management/public/mocks.ts index 6c709fb14f08d7..7671a532d1cb86 100644 --- a/src/plugins/index_pattern_management/public/mocks.ts +++ b/src/plugins/index_pattern_management/public/mocks.ts @@ -19,14 +19,7 @@ import { } from './plugin'; import { IndexPatternManagmentContext } from './types'; -const createSetupContract = (): IndexPatternManagementSetup => ({ - creation: { - addCreationConfig: jest.fn(), - } as any, - list: { - addListConfig: jest.fn(), - } as any, -}); +const createSetupContract = (): IndexPatternManagementSetup => {}; const createStartContract = (): IndexPatternManagementStart => ({ creation: { diff --git a/src/plugins/index_pattern_management/public/plugin.ts b/src/plugins/index_pattern_management/public/plugin.ts index e3c156927bface..610b3541620b00 100644 --- a/src/plugins/index_pattern_management/public/plugin.ts +++ b/src/plugins/index_pattern_management/public/plugin.ts @@ -81,7 +81,10 @@ export class IndexPatternManagementPlugin }, }); - return this.indexPatternManagementService.setup({ httpClient: core.http }); + return this.indexPatternManagementService.setup({ + httpClient: core.http, + uiSettings: core.uiSettings, + }); } public start(core: CoreStart, plugins: IndexPatternManagementStartDependencies) { diff --git a/x-pack/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/index.js b/src/plugins/index_pattern_management/public/service/creation/components/rollup_prompt/index.ts similarity index 53% rename from x-pack/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/index.js rename to src/plugins/index_pattern_management/public/service/creation/components/rollup_prompt/index.ts index 1d9eff8227c0ac..d1fc2fa242eb1b 100644 --- a/x-pack/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/index.js +++ b/src/plugins/index_pattern_management/public/service/creation/components/rollup_prompt/index.ts @@ -1,8 +1,9 @@ /* * 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. + * 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 { RollupPrompt } from './rollup_prompt'; diff --git a/x-pack/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/rollup_prompt.js b/src/plugins/index_pattern_management/public/service/creation/components/rollup_prompt/rollup_prompt.tsx similarity index 88% rename from x-pack/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/rollup_prompt.js rename to src/plugins/index_pattern_management/public/service/creation/components/rollup_prompt/rollup_prompt.tsx index 9306ab082dff49..750fa2a3844d20 100644 --- a/x-pack/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/rollup_prompt.js +++ b/src/plugins/index_pattern_management/public/service/creation/components/rollup_prompt/rollup_prompt.tsx @@ -1,8 +1,9 @@ /* * 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. + * 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 React from 'react'; diff --git a/src/plugins/index_pattern_management/public/service/creation/index.ts b/src/plugins/index_pattern_management/public/service/creation/index.ts index 51610bc83e371b..e1f464b01e5505 100644 --- a/src/plugins/index_pattern_management/public/service/creation/index.ts +++ b/src/plugins/index_pattern_management/public/service/creation/index.ts @@ -8,3 +8,5 @@ export { IndexPatternCreationConfig, IndexPatternCreationOption } from './config'; export { IndexPatternCreationManager } from './manager'; +// @ts-ignore +export { RollupIndexPatternCreationConfig } from './rollup_creation_config'; diff --git a/x-pack/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js b/src/plugins/index_pattern_management/public/service/creation/rollup_creation_config.js similarity index 95% rename from x-pack/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js rename to src/plugins/index_pattern_management/public/service/creation/rollup_creation_config.js index 8e5203fca90347..b516467bf73cc0 100644 --- a/x-pack/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js +++ b/src/plugins/index_pattern_management/public/service/creation/rollup_creation_config.js @@ -1,15 +1,16 @@ /* * 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. + * 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 React from 'react'; import { i18n } from '@kbn/i18n'; import { RollupPrompt } from './components/rollup_prompt'; -import { IndexPatternCreationConfig } from '../../../../../src/plugins/index_pattern_management/public'; +import { IndexPatternCreationConfig } from '../../types'; const rollupIndexPatternTypeName = i18n.translate( 'xpack.rollupJobs.editRollupIndexPattern.createIndex.defaultTypeName', diff --git a/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts b/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts index f30ccfcb9f3ed7..0edc99561b42b4 100644 --- a/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts +++ b/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts @@ -6,11 +6,20 @@ * Side Public License, v 1. */ -import { HttpSetup } from '../../../../core/public'; -import { IndexPatternCreationManager, IndexPatternCreationConfig } from './creation'; -import { IndexPatternListManager, IndexPatternListConfig } from './list'; +import { HttpSetup, CoreSetup } from '../../../../core/public'; +import { + IndexPatternCreationManager, + IndexPatternCreationConfig, + RollupIndexPatternCreationConfig, +} from './creation'; +import { + IndexPatternListManager, + IndexPatternListConfig, + RollupIndexPatternListConfig, +} from './list'; interface SetupDependencies { httpClient: HttpSetup; + uiSettings: CoreSetup['uiSettings']; } /** @@ -27,17 +36,24 @@ export class IndexPatternManagementService { this.indexPatternListConfig = new IndexPatternListManager(); } - public setup({ httpClient }: SetupDependencies) { + public setup({ httpClient, uiSettings }: SetupDependencies) { const creationManagerSetup = this.indexPatternCreationManager.setup(httpClient); creationManagerSetup.addCreationConfig(IndexPatternCreationConfig); const indexPatternListConfigSetup = this.indexPatternListConfig.setup(); indexPatternListConfigSetup.addListConfig(IndexPatternListConfig); + // todo move to shared plugin + if (uiSettings.get('rollups:enableIndexPatterns')) { + creationManagerSetup.addCreationConfig(RollupIndexPatternCreationConfig); + indexPatternListConfigSetup.addListConfig(RollupIndexPatternListConfig); + } + /* return { creation: creationManagerSetup, list: indexPatternListConfigSetup, }; + */ } public start() { diff --git a/src/plugins/index_pattern_management/public/service/list/index.ts b/src/plugins/index_pattern_management/public/service/list/index.ts index 620d4c7600733b..738b807ac76246 100644 --- a/src/plugins/index_pattern_management/public/service/list/index.ts +++ b/src/plugins/index_pattern_management/public/service/list/index.ts @@ -8,3 +8,5 @@ export { IndexPatternListConfig } from './config'; export { IndexPatternListManager } from './manager'; +// @ts-ignore +export { RollupIndexPatternListConfig } from './rollup_list_config'; diff --git a/x-pack/plugins/rollup/public/index_pattern_list/rollup_index_pattern_list_config.js b/src/plugins/index_pattern_management/public/service/list/rollup_list_config.js similarity index 86% rename from x-pack/plugins/rollup/public/index_pattern_list/rollup_index_pattern_list_config.js rename to src/plugins/index_pattern_management/public/service/list/rollup_list_config.js index 43eee6ca27f9a0..c4422bc4cbef5d 100644 --- a/x-pack/plugins/rollup/public/index_pattern_list/rollup_index_pattern_list_config.js +++ b/src/plugins/index_pattern_management/public/service/list/rollup_list_config.js @@ -1,11 +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; you may not use this file except in compliance with the Elastic License - * 2.0. + * 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 { IndexPatternListConfig } from '../../../../../src/plugins/index_pattern_management/public'; +import { IndexPatternListConfig } from '../../types'; function isRollup(indexPattern) { return ( diff --git a/x-pack/plugins/rollup/kibana.json b/x-pack/plugins/rollup/kibana.json index 725b563c3674f3..10541d9a4ebddc 100644 --- a/x-pack/plugins/rollup/kibana.json +++ b/x-pack/plugins/rollup/kibana.json @@ -5,7 +5,6 @@ "server": true, "ui": true, "requiredPlugins": [ - "indexPatternManagement", "management", "licensing", "features" diff --git a/x-pack/plugins/rollup/public/plugin.ts b/x-pack/plugins/rollup/public/plugin.ts index 17e352e1a44729..830fb63b6288e3 100644 --- a/x-pack/plugins/rollup/public/plugin.ts +++ b/x-pack/plugins/rollup/public/plugin.ts @@ -12,14 +12,13 @@ import { rollupBadgeExtension, rollupToggleExtension } from './extend_index_mana import { RollupIndexPatternCreationConfig } from './index_pattern_creation/rollup_index_pattern_creation_config'; // @ts-ignore import { RollupIndexPatternListConfig } from './index_pattern_list/rollup_index_pattern_list_config'; -import { CONFIG_ROLLUPS, UIM_APP_NAME } from '../common'; +import { UIM_APP_NAME } from '../common'; import { FeatureCatalogueCategory, HomePublicPluginSetup, } from '../../../../src/plugins/home/public'; import { ManagementSetup } from '../../../../src/plugins/management/public'; import { IndexManagementPluginSetup } from '../../index_management/public'; -import { IndexPatternManagementSetup } from '../../../../src/plugins/index_pattern_management/public'; // @ts-ignore import { setHttp, init as initDocumentation } from './crud_app/services/index'; import { setNotifications, setFatalErrors, setUiStatsReporter } from './kibana_services'; @@ -29,20 +28,13 @@ export interface RollupPluginSetupDependencies { home?: HomePublicPluginSetup; management: ManagementSetup; indexManagement?: IndexManagementPluginSetup; - indexPatternManagement: IndexPatternManagementSetup; usageCollection?: UsageCollectionSetup; } export class RollupPlugin implements Plugin { setup( core: CoreSetup, - { - home, - management, - indexManagement, - indexPatternManagement, - usageCollection, - }: RollupPluginSetupDependencies + { home, management, indexManagement, usageCollection }: RollupPluginSetupDependencies ) { setFatalErrors(core.fatalErrors); if (usageCollection) { @@ -54,12 +46,14 @@ export class RollupPlugin implements Plugin { indexManagement.extensionsService.addToggle(rollupToggleExtension); } + /* const isRollupIndexPatternsEnabled = core.uiSettings.get(CONFIG_ROLLUPS); if (isRollupIndexPatternsEnabled) { indexPatternManagement.creation.addCreationConfig(RollupIndexPatternCreationConfig); indexPatternManagement.list.addListConfig(RollupIndexPatternListConfig); } + */ if (home) { home.featureCatalogue.register({ diff --git a/x-pack/plugins/rollup/tsconfig.json b/x-pack/plugins/rollup/tsconfig.json index 9b994d1710ffc2..6885081ce4bdd1 100644 --- a/x-pack/plugins/rollup/tsconfig.json +++ b/x-pack/plugins/rollup/tsconfig.json @@ -16,7 +16,6 @@ "references": [ { "path": "../../../src/core/tsconfig.json" }, // required plugins - { "path": "../../../src/plugins/index_pattern_management/tsconfig.json" }, { "path": "../../../src/plugins/management/tsconfig.json" }, { "path": "../licensing/tsconfig.json" }, { "path": "../features/tsconfig.json" }, From 5cc9214f3a265296a9b9e12ff2a0e5a16ca13456 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 14 Jun 2021 20:04:53 -0500 Subject: [PATCH 2/7] fix imports --- .../public/service/creation/rollup_creation_config.js | 2 +- .../public/service/list/rollup_list_config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/index_pattern_management/public/service/creation/rollup_creation_config.js b/src/plugins/index_pattern_management/public/service/creation/rollup_creation_config.js index b516467bf73cc0..93af6c27a39572 100644 --- a/src/plugins/index_pattern_management/public/service/creation/rollup_creation_config.js +++ b/src/plugins/index_pattern_management/public/service/creation/rollup_creation_config.js @@ -10,7 +10,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { RollupPrompt } from './components/rollup_prompt'; -import { IndexPatternCreationConfig } from '../../types'; +import { IndexPatternCreationConfig } from '.'; const rollupIndexPatternTypeName = i18n.translate( 'xpack.rollupJobs.editRollupIndexPattern.createIndex.defaultTypeName', diff --git a/src/plugins/index_pattern_management/public/service/list/rollup_list_config.js b/src/plugins/index_pattern_management/public/service/list/rollup_list_config.js index c4422bc4cbef5d..9a80d5fd0d622b 100644 --- a/src/plugins/index_pattern_management/public/service/list/rollup_list_config.js +++ b/src/plugins/index_pattern_management/public/service/list/rollup_list_config.js @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { IndexPatternListConfig } from '../../types'; +import { IndexPatternListConfig } from '.'; function isRollup(indexPattern) { return ( From af507883522ad9c1d81a8bbba554a3b1f8ee3c9c Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 14 Jun 2021 21:40:32 -0500 Subject: [PATCH 3/7] fix localization, remove comments, cleanup --- .../public/constants.ts | 9 +++++++++ .../components/rollup_prompt/rollup_prompt.tsx | 4 ++-- .../service/creation/rollup_creation_config.js | 14 +++++++------- .../index_pattern_management_service.ts | 11 +++-------- x-pack/plugins/rollup/public/plugin.ts | 9 --------- .../translations/translations/ja-JP.json | 18 +++++++++--------- .../translations/translations/zh-CN.json | 18 +++++++++--------- 7 files changed, 39 insertions(+), 44 deletions(-) create mode 100644 src/plugins/index_pattern_management/public/constants.ts diff --git a/src/plugins/index_pattern_management/public/constants.ts b/src/plugins/index_pattern_management/public/constants.ts new file mode 100644 index 00000000000000..e5010d133f0f30 --- /dev/null +++ b/src/plugins/index_pattern_management/public/constants.ts @@ -0,0 +1,9 @@ +/* + * 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 const CONFIG_ROLLUPS = 'rollups:enableIndexPatterns'; diff --git a/src/plugins/index_pattern_management/public/service/creation/components/rollup_prompt/rollup_prompt.tsx b/src/plugins/index_pattern_management/public/service/creation/components/rollup_prompt/rollup_prompt.tsx index 750fa2a3844d20..81fcdaedb90c90 100644 --- a/src/plugins/index_pattern_management/public/service/creation/components/rollup_prompt/rollup_prompt.tsx +++ b/src/plugins/index_pattern_management/public/service/creation/components/rollup_prompt/rollup_prompt.tsx @@ -15,7 +15,7 @@ export const RollupPrompt = () => (

{i18n.translate( - 'xpack.rollupJobs.editRollupIndexPattern.rollupPrompt.betaCalloutParagraph1Text', + 'indexPatternManagement.editRollupIndexPattern.rollupPrompt.betaCalloutParagraph1Text', { defaultMessage: "Kibana's support for rollup index patterns is in beta. You might encounter issues using " + @@ -26,7 +26,7 @@ export const RollupPrompt = () => (

{i18n.translate( - 'xpack.rollupJobs.editRollupIndexPattern.rollupPrompt.betaCalloutParagraph2Text', + 'indexPatternManagement.editRollupIndexPattern.rollupPrompt.betaCalloutParagraph2Text', { defaultMessage: 'You can match a rollup index pattern against one rollup index and zero or more regular ' + diff --git a/src/plugins/index_pattern_management/public/service/creation/rollup_creation_config.js b/src/plugins/index_pattern_management/public/service/creation/rollup_creation_config.js index 93af6c27a39572..2a85dfa01143c7 100644 --- a/src/plugins/index_pattern_management/public/service/creation/rollup_creation_config.js +++ b/src/plugins/index_pattern_management/public/service/creation/rollup_creation_config.js @@ -13,32 +13,32 @@ import { RollupPrompt } from './components/rollup_prompt'; import { IndexPatternCreationConfig } from '.'; const rollupIndexPatternTypeName = i18n.translate( - 'xpack.rollupJobs.editRollupIndexPattern.createIndex.defaultTypeName', + 'indexPatternManagement.editRollupIndexPattern.createIndex.defaultTypeName', { defaultMessage: 'rollup index pattern' } ); const rollupIndexPatternButtonText = i18n.translate( - 'xpack.rollupJobs.editRollupIndexPattern.createIndex.defaultButtonText', + 'indexPatternManagement.editRollupIndexPattern.createIndex.defaultButtonText', { defaultMessage: 'Rollup index pattern' } ); const rollupIndexPatternButtonDescription = i18n.translate( - 'xpack.rollupJobs.editRollupIndexPattern.createIndex.defaultButtonDescription', + 'indexPatternManagement.editRollupIndexPattern.createIndex.defaultButtonDescription', { defaultMessage: 'Perform limited aggregations against summarized data' } ); const rollupIndexPatternNoMatchError = i18n.translate( - 'xpack.rollupJobs.editRollupIndexPattern.createIndex.noMatchError', + 'indexPatternManagement.editRollupIndexPattern.createIndex.noMatchError', { defaultMessage: 'Rollup index pattern error: must match one rollup index' } ); const rollupIndexPatternTooManyMatchesError = i18n.translate( - 'xpack.rollupJobs.editRollupIndexPattern.createIndex.tooManyMatchesError', + 'indexPatternManagement.editRollupIndexPattern.createIndex.tooManyMatchesError', { defaultMessage: 'Rollup index pattern error: can only match one rollup index' } ); const rollupIndexPatternIndexLabel = i18n.translate( - 'xpack.rollupJobs.editRollupIndexPattern.createIndex.indexLabel', + 'indexPatternManagement.editRollupIndexPattern.createIndex.indexLabel', { defaultMessage: 'Rollup' } ); @@ -128,7 +128,7 @@ export class RollupIndexPatternCreationConfig extends IndexPatternCreationConfig if (error) { const errorMessage = i18n.translate( - 'xpack.rollupJobs.editRollupIndexPattern.createIndex.uncaughtError', + 'indexPatternManagement.editRollupIndexPattern.createIndex.uncaughtError', { defaultMessage: 'Rollup index pattern error: {error}', values: { diff --git a/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts b/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts index 0edc99561b42b4..19346dbf31d185 100644 --- a/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts +++ b/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts @@ -17,6 +17,8 @@ import { IndexPatternListConfig, RollupIndexPatternListConfig, } from './list'; + +import { CONFIG_ROLLUPS } from '../constants'; interface SetupDependencies { httpClient: HttpSetup; uiSettings: CoreSetup['uiSettings']; @@ -43,17 +45,10 @@ export class IndexPatternManagementService { const indexPatternListConfigSetup = this.indexPatternListConfig.setup(); indexPatternListConfigSetup.addListConfig(IndexPatternListConfig); - // todo move to shared plugin - if (uiSettings.get('rollups:enableIndexPatterns')) { + if (uiSettings.get(CONFIG_ROLLUPS)) { creationManagerSetup.addCreationConfig(RollupIndexPatternCreationConfig); indexPatternListConfigSetup.addListConfig(RollupIndexPatternListConfig); } - /* - return { - creation: creationManagerSetup, - list: indexPatternListConfigSetup, - }; - */ } public start() { diff --git a/x-pack/plugins/rollup/public/plugin.ts b/x-pack/plugins/rollup/public/plugin.ts index 830fb63b6288e3..0d345e326193c7 100644 --- a/x-pack/plugins/rollup/public/plugin.ts +++ b/x-pack/plugins/rollup/public/plugin.ts @@ -46,15 +46,6 @@ export class RollupPlugin implements Plugin { indexManagement.extensionsService.addToggle(rollupToggleExtension); } - /* - const isRollupIndexPatternsEnabled = core.uiSettings.get(CONFIG_ROLLUPS); - - if (isRollupIndexPatternsEnabled) { - indexPatternManagement.creation.addCreationConfig(RollupIndexPatternCreationConfig); - indexPatternManagement.list.addListConfig(RollupIndexPatternListConfig); - } - */ - if (home) { home.featureCatalogue.register({ id: 'rollup_jobs', diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 9be5957cd4718a..510df729fd2777 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -18035,15 +18035,15 @@ "xpack.rollupJobs.detailPanel.jobActionMenu.buttonLabel": "管理", "xpack.rollupJobs.detailPanel.loadingLabel": "ロールアップジョブを読み込み中...", "xpack.rollupJobs.detailPanel.notFoundLabel": "ロールアップジョブが見つかりません", - "xpack.rollupJobs.editRollupIndexPattern.createIndex.defaultButtonDescription": "要約データに制限された集約を実行します。", - "xpack.rollupJobs.editRollupIndexPattern.createIndex.defaultButtonText": "ロールアップインデックスパターン", - "xpack.rollupJobs.editRollupIndexPattern.createIndex.defaultTypeName": "ロールアップインデックスパターン", - "xpack.rollupJobs.editRollupIndexPattern.createIndex.indexLabel": "ロールアップ", - "xpack.rollupJobs.editRollupIndexPattern.createIndex.noMatchError": "ロールアップインデックスパターンエラー:ロールアップインデックスの 1 つと一致している必要があります", - "xpack.rollupJobs.editRollupIndexPattern.createIndex.tooManyMatchesError": "ロールアップインデックスパターンエラー:一致できるロールアップインデックスは 1 つだけです", - "xpack.rollupJobs.editRollupIndexPattern.createIndex.uncaughtError": "ロールアップインデックスパターンエラー:{error}", - "xpack.rollupJobs.editRollupIndexPattern.rollupPrompt.betaCalloutParagraph1Text": "ロールアップインデックスパターンのKibanaのサポートはベータ版です。保存された検索、可視化、ダッシュボードでこれらのパターンを使用すると問題が発生する場合があります。Timelionや機械学習などの一部の高度な機能ではサポートされていません。", - "xpack.rollupJobs.editRollupIndexPattern.rollupPrompt.betaCalloutParagraph2Text": "ロールアップインデックスパターンは、1つのロールアップインデックスとゼロ以上の標準インデックスと一致させることができます。ロールアップインデックスパターンでは、メトリック、フィールド、間隔、アグリゲーションが制限されています。ロールアップインデックスは、1つのジョブ構成があるインデックス、または複数のジョブと互換する構成があるインデックスに制限されています。", + "indexPatternManagement.editRollupIndexPattern.createIndex.defaultButtonDescription": "要約データに制限された集約を実行します。", + "indexPatternManagement.editRollupIndexPattern.createIndex.defaultButtonText": "ロールアップインデックスパターン", + "indexPatternManagement.editRollupIndexPattern.createIndex.defaultTypeName": "ロールアップインデックスパターン", + "indexPatternManagement.editRollupIndexPattern.createIndex.indexLabel": "ロールアップ", + "indexPatternManagement.editRollupIndexPattern.createIndex.noMatchError": "ロールアップインデックスパターンエラー:ロールアップインデックスの 1 つと一致している必要があります", + "indexPatternManagement.editRollupIndexPattern.createIndex.tooManyMatchesError": "ロールアップインデックスパターンエラー:一致できるロールアップインデックスは 1 つだけです", + "indexPatternManagement.editRollupIndexPattern.createIndex.uncaughtError": "ロールアップインデックスパターンエラー:{error}", + "indexPatternManagement.editRollupIndexPattern.rollupPrompt.betaCalloutParagraph1Text": "ロールアップインデックスパターンのKibanaのサポートはベータ版です。保存された検索、可視化、ダッシュボードでこれらのパターンを使用すると問題が発生する場合があります。Timelionや機械学習などの一部の高度な機能ではサポートされていません。", + "indexPatternManagement.editRollupIndexPattern.rollupPrompt.betaCalloutParagraph2Text": "ロールアップインデックスパターンは、1つのロールアップインデックスとゼロ以上の標準インデックスと一致させることができます。ロールアップインデックスパターンでは、メトリック、フィールド、間隔、アグリゲーションが制限されています。ロールアップインデックスは、1つのジョブ構成があるインデックス、または複数のジョブと互換する構成があるインデックスに制限されています。", "xpack.rollupJobs.featureCatalogueDescription": "今後の分析用に履歴データを小さなインデックスに要約して格納します。", "xpack.rollupJobs.indexMgmtBadge.rollupLabel": "ロールアップ", "xpack.rollupJobs.indexMgmtToggle.toggleLabel": "ロールアップインデックスを含める", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index d6ebf8a32bcc4e..ff9bdb9c593bbb 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -18276,15 +18276,15 @@ "xpack.rollupJobs.detailPanel.jobActionMenu.buttonLabel": "管理", "xpack.rollupJobs.detailPanel.loadingLabel": "正在加载汇总/打包作业……", "xpack.rollupJobs.detailPanel.notFoundLabel": "未找到汇总/打包作业", - "xpack.rollupJobs.editRollupIndexPattern.createIndex.defaultButtonDescription": "针对汇总数据执行有限聚合", - "xpack.rollupJobs.editRollupIndexPattern.createIndex.defaultButtonText": "汇总/打包索引模式", - "xpack.rollupJobs.editRollupIndexPattern.createIndex.defaultTypeName": "汇总/打包索引模式", - "xpack.rollupJobs.editRollupIndexPattern.createIndex.indexLabel": "汇总/打包", - "xpack.rollupJobs.editRollupIndexPattern.createIndex.noMatchError": "汇总/打包索引模式错误:必须匹配一个汇总/打包索引", - "xpack.rollupJobs.editRollupIndexPattern.createIndex.tooManyMatchesError": "汇总/打包索引模式错误:只能匹配一个汇总/打包索引", - "xpack.rollupJobs.editRollupIndexPattern.createIndex.uncaughtError": "汇总索引模式错误:{error}", - "xpack.rollupJobs.editRollupIndexPattern.rollupPrompt.betaCalloutParagraph1Text": "Kibana 对汇总/打包索引模式的支持处于公测版状态。将这些模式用于已保存搜索、可视化以及仪表板可能会遇到问题。某些高级功能,如 Timelion 和 Machine Learning,不支持这些模式。", - "xpack.rollupJobs.editRollupIndexPattern.rollupPrompt.betaCalloutParagraph2Text": "可以根据一个汇总/打包索引和零个或更多常规索引匹配汇总/打包索引模式。汇总/打包索引模式的指标、字段、时间间隔和聚合有限。汇总/打包索引仅限于具有一个作业配置或多个作业配置兼容的索引。", + "indexPatternManagement.editRollupIndexPattern.createIndex.defaultButtonDescription": "针对汇总数据执行有限聚合", + "indexPatternManagement.editRollupIndexPattern.createIndex.defaultButtonText": "汇总/打包索引模式", + "indexPatternManagement.editRollupIndexPattern.createIndex.defaultTypeName": "汇总/打包索引模式", + "indexPatternManagement.editRollupIndexPattern.createIndex.indexLabel": "汇总/打包", + "indexPatternManagement.editRollupIndexPattern.createIndex.noMatchError": "汇总/打包索引模式错误:必须匹配一个汇总/打包索引", + "indexPatternManagement.editRollupIndexPattern.createIndex.tooManyMatchesError": "汇总/打包索引模式错误:只能匹配一个汇总/打包索引", + "indexPatternManagement.editRollupIndexPattern.createIndex.uncaughtError": "汇总索引模式错误:{error}", + "indexPatternManagement.editRollupIndexPattern.rollupPrompt.betaCalloutParagraph1Text": "Kibana 对汇总/打包索引模式的支持处于公测版状态。将这些模式用于已保存搜索、可视化以及仪表板可能会遇到问题。某些高级功能,如 Timelion 和 Machine Learning,不支持这些模式。", + "indexPatternManagement.editRollupIndexPattern.rollupPrompt.betaCalloutParagraph2Text": "可以根据一个汇总/打包索引和零个或更多常规索引匹配汇总/打包索引模式。汇总/打包索引模式的指标、字段、时间间隔和聚合有限。汇总/打包索引仅限于具有一个作业配置或多个作业配置兼容的索引。", "xpack.rollupJobs.featureCatalogueDescription": "汇总历史数据并将其存储在较小的索引中以供将来分析。", "xpack.rollupJobs.indexMgmtBadge.rollupLabel": "汇总/打包", "xpack.rollupJobs.indexMgmtToggle.toggleLabel": "包括汇总索引", From 452baf667a5a8102a4175e23579a312d35e3977b Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Tue, 15 Jun 2021 20:34:41 -0500 Subject: [PATCH 4/7] provide default for uiSettings lookup --- .../public/service/index_pattern_management_service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts b/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts index 19346dbf31d185..f1fa2b76b28882 100644 --- a/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts +++ b/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts @@ -45,7 +45,7 @@ export class IndexPatternManagementService { const indexPatternListConfigSetup = this.indexPatternListConfig.setup(); indexPatternListConfigSetup.addListConfig(IndexPatternListConfig); - if (uiSettings.get(CONFIG_ROLLUPS)) { + if (uiSettings.get(CONFIG_ROLLUPS, false)) { creationManagerSetup.addCreationConfig(RollupIndexPatternCreationConfig); indexPatternListConfigSetup.addListConfig(RollupIndexPatternListConfig); } From d74614ad68f07d9dad0b74d24356501950f73f1f Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Tue, 15 Jun 2021 22:55:36 -0500 Subject: [PATCH 5/7] refactor to only reference uiSettings after lifecycle functions have run --- .../index_pattern_management/public/plugin.ts | 8 ++-- .../public/service/creation/manager.ts | 41 +++++++++++-------- .../index_pattern_management_service.ts | 40 +++++------------- .../public/service/list/manager.ts | 38 +++++++++-------- 4 files changed, 57 insertions(+), 70 deletions(-) diff --git a/src/plugins/index_pattern_management/public/plugin.ts b/src/plugins/index_pattern_management/public/plugin.ts index 610b3541620b00..d254691a0270da 100644 --- a/src/plugins/index_pattern_management/public/plugin.ts +++ b/src/plugins/index_pattern_management/public/plugin.ts @@ -80,17 +80,15 @@ export class IndexPatternManagementPlugin return mountManagementSection(core.getStartServices, params); }, }); + } - return this.indexPatternManagementService.setup({ + public start(core: CoreStart, plugins: IndexPatternManagementStartDependencies) { + return this.indexPatternManagementService.start({ httpClient: core.http, uiSettings: core.uiSettings, }); } - public start(core: CoreStart, plugins: IndexPatternManagementStartDependencies) { - return this.indexPatternManagementService.start(); - } - public stop() { this.indexPatternManagementService.stop(); } diff --git a/src/plugins/index_pattern_management/public/service/creation/manager.ts b/src/plugins/index_pattern_management/public/service/creation/manager.ts index c139b10ebb1fe6..f1fdb68418a652 100644 --- a/src/plugins/index_pattern_management/public/service/creation/manager.ts +++ b/src/plugins/index_pattern_management/public/service/creation/manager.ts @@ -6,31 +6,36 @@ * Side Public License, v 1. */ -import { HttpSetup } from '../../../../../core/public'; +import { memoize } from 'lodash'; +import { HttpStart, CoreStart } from '../../../../../core/public'; import { IndexPatternCreationConfig, UrlHandler, IndexPatternCreationOption } from './config'; +import { CONFIG_ROLLUPS } from '../../constants'; +// @ts-ignore +import { RollupIndexPatternCreationConfig } from './rollup_creation_config'; -export class IndexPatternCreationManager { - private configs: IndexPatternCreationConfig[] = []; +interface IndexPatternCreationManagerStart { + httpClient: HttpStart; + uiSettings: CoreStart['uiSettings']; +} - setup(httpClient: HttpSetup) { - return { - addCreationConfig: (Config: typeof IndexPatternCreationConfig) => { - const config = new Config({ httpClient }); +export class IndexPatternCreationManager { + start({ httpClient, uiSettings }: IndexPatternCreationManagerStart) { + const getConfigs = memoize(() => { + const configs: IndexPatternCreationConfig[] = []; + configs.push(new IndexPatternCreationConfig({ httpClient })); - if (this.configs.findIndex((c) => c.key === config.key) !== -1) { - throw new Error(`${config.key} exists in IndexPatternCreationManager.`); - } + if (uiSettings.get(CONFIG_ROLLUPS, false)) { + configs.push(new RollupIndexPatternCreationConfig({ httpClient })); + } - this.configs.push(config); - }, - }; - } + return configs; + }); - start() { const getType = (key: string | undefined): IndexPatternCreationConfig => { + const configs = getConfigs(); if (key) { - const index = this.configs.findIndex((config) => config.key === key); - const config = this.configs[index]; + const index = configs.findIndex((config) => config.key === key); + const config = configs[index]; if (config) { return config; @@ -48,7 +53,7 @@ export class IndexPatternCreationManager { const options: IndexPatternCreationOption[] = []; await Promise.all( - this.configs.map(async (config) => { + getConfigs().map(async (config) => { const option = config.getIndexPatternCreationOption ? await config.getIndexPatternCreationOption(urlHandler) : null; diff --git a/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts b/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts index f1fa2b76b28882..25a36faa1c3e37 100644 --- a/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts +++ b/src/plugins/index_pattern_management/public/service/index_pattern_management_service.ts @@ -6,22 +6,13 @@ * Side Public License, v 1. */ -import { HttpSetup, CoreSetup } from '../../../../core/public'; -import { - IndexPatternCreationManager, - IndexPatternCreationConfig, - RollupIndexPatternCreationConfig, -} from './creation'; -import { - IndexPatternListManager, - IndexPatternListConfig, - RollupIndexPatternListConfig, -} from './list'; +import { HttpStart, CoreStart } from '../../../../core/public'; +import { IndexPatternCreationManager } from './creation'; +import { IndexPatternListManager } from './list'; -import { CONFIG_ROLLUPS } from '../constants'; -interface SetupDependencies { - httpClient: HttpSetup; - uiSettings: CoreSetup['uiSettings']; +interface StartDependencies { + httpClient: HttpStart; + uiSettings: CoreStart['uiSettings']; } /** @@ -38,23 +29,12 @@ export class IndexPatternManagementService { this.indexPatternListConfig = new IndexPatternListManager(); } - public setup({ httpClient, uiSettings }: SetupDependencies) { - const creationManagerSetup = this.indexPatternCreationManager.setup(httpClient); - creationManagerSetup.addCreationConfig(IndexPatternCreationConfig); + public setup() {} - const indexPatternListConfigSetup = this.indexPatternListConfig.setup(); - indexPatternListConfigSetup.addListConfig(IndexPatternListConfig); - - if (uiSettings.get(CONFIG_ROLLUPS, false)) { - creationManagerSetup.addCreationConfig(RollupIndexPatternCreationConfig); - indexPatternListConfigSetup.addListConfig(RollupIndexPatternListConfig); - } - } - - public start() { + public start({ httpClient, uiSettings }: StartDependencies) { return { - creation: this.indexPatternCreationManager.start(), - list: this.indexPatternListConfig.start(), + creation: this.indexPatternCreationManager.start({ httpClient, uiSettings }), + list: this.indexPatternListConfig.start({ uiSettings }), }; } diff --git a/src/plugins/index_pattern_management/public/service/list/manager.ts b/src/plugins/index_pattern_management/public/service/list/manager.ts index 22877f78d46fcd..2164d770069785 100644 --- a/src/plugins/index_pattern_management/public/service/list/manager.ts +++ b/src/plugins/index_pattern_management/public/service/list/manager.ts @@ -8,31 +8,35 @@ import { IIndexPattern, IFieldType } from 'src/plugins/data/public'; import { SimpleSavedObject } from 'src/core/public'; +import { memoize } from 'lodash'; +import { CoreStart } from '../../../../../core/public'; import { IndexPatternListConfig, IndexPatternTag } from './config'; +import { CONFIG_ROLLUPS } from '../../constants'; +// @ts-ignore +import { RollupIndexPatternListConfig } from './rollup_list_config'; -export class IndexPatternListManager { - private configs: IndexPatternListConfig[] = []; +interface IndexPatternListManagerStart { + uiSettings: CoreStart['uiSettings']; +} - setup() { - return { - addListConfig: (Config: typeof IndexPatternListConfig) => { - const config = new Config(); +export class IndexPatternListManager { + start({ uiSettings }: IndexPatternListManagerStart) { + const getConfigs = memoize(() => { + const configs: IndexPatternListConfig[] = []; + configs.push(new IndexPatternListConfig()); - if (this.configs.findIndex((c) => c.key === config.key) !== -1) { - throw new Error(`${config.key} exists in IndexPatternListManager.`); - } - this.configs.push(config); - }, - }; - } + if (uiSettings.get(CONFIG_ROLLUPS, false)) { + configs.push(new RollupIndexPatternListConfig()); + } - start() { + return configs; + }); return { getIndexPatternTags: ( indexPattern: IIndexPattern | SimpleSavedObject, isDefault: boolean ) => - this.configs.reduce( + getConfigs().reduce( (tags: IndexPatternTag[], config) => config.getIndexPatternTags ? tags.concat(config.getIndexPatternTags(indexPattern, isDefault)) @@ -41,14 +45,14 @@ export class IndexPatternListManager { ), getFieldInfo: (indexPattern: IIndexPattern, field: IFieldType): string[] => - this.configs.reduce( + getConfigs().reduce( (info: string[], config) => config.getFieldInfo ? info.concat(config.getFieldInfo(indexPattern, field)) : info, [] ), areScriptedFieldsEnabled: (indexPattern: IIndexPattern): boolean => - this.configs.every((config) => + getConfigs().every((config) => config.areScriptedFieldsEnabled ? config.areScriptedFieldsEnabled(indexPattern) : true ), }; From 217e30412bf14d457f99a789d34bc6d24b58ab3b Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Wed, 16 Jun 2021 10:00:40 -0500 Subject: [PATCH 6/7] check if uiSetting is declared before checking for value --- .../index_pattern_management/public/service/creation/manager.ts | 2 +- .../index_pattern_management/public/service/list/manager.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/index_pattern_management/public/service/creation/manager.ts b/src/plugins/index_pattern_management/public/service/creation/manager.ts index f1fdb68418a652..7a15b1869469d9 100644 --- a/src/plugins/index_pattern_management/public/service/creation/manager.ts +++ b/src/plugins/index_pattern_management/public/service/creation/manager.ts @@ -24,7 +24,7 @@ export class IndexPatternCreationManager { const configs: IndexPatternCreationConfig[] = []; configs.push(new IndexPatternCreationConfig({ httpClient })); - if (uiSettings.get(CONFIG_ROLLUPS, false)) { + if (uiSettings.isDeclared(CONFIG_ROLLUPS) && uiSettings.get(CONFIG_ROLLUPS)) { configs.push(new RollupIndexPatternCreationConfig({ httpClient })); } diff --git a/src/plugins/index_pattern_management/public/service/list/manager.ts b/src/plugins/index_pattern_management/public/service/list/manager.ts index 2164d770069785..7cd55988c6b5b3 100644 --- a/src/plugins/index_pattern_management/public/service/list/manager.ts +++ b/src/plugins/index_pattern_management/public/service/list/manager.ts @@ -25,7 +25,7 @@ export class IndexPatternListManager { const configs: IndexPatternListConfig[] = []; configs.push(new IndexPatternListConfig()); - if (uiSettings.get(CONFIG_ROLLUPS, false)) { + if (uiSettings.isDeclared(CONFIG_ROLLUPS) && uiSettings.get(CONFIG_ROLLUPS)) { configs.push(new RollupIndexPatternListConfig()); } From 4dd2931d1b8475a5463ba6ff24745690841cb07a Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Wed, 16 Jun 2021 18:08:54 -0500 Subject: [PATCH 7/7] memoize => once --- .../public/service/creation/manager.ts | 4 ++-- .../index_pattern_management/public/service/list/manager.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/index_pattern_management/public/service/creation/manager.ts b/src/plugins/index_pattern_management/public/service/creation/manager.ts index 7a15b1869469d9..cc2285bbfcafb3 100644 --- a/src/plugins/index_pattern_management/public/service/creation/manager.ts +++ b/src/plugins/index_pattern_management/public/service/creation/manager.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { memoize } from 'lodash'; +import { once } from 'lodash'; import { HttpStart, CoreStart } from '../../../../../core/public'; import { IndexPatternCreationConfig, UrlHandler, IndexPatternCreationOption } from './config'; import { CONFIG_ROLLUPS } from '../../constants'; @@ -20,7 +20,7 @@ interface IndexPatternCreationManagerStart { export class IndexPatternCreationManager { start({ httpClient, uiSettings }: IndexPatternCreationManagerStart) { - const getConfigs = memoize(() => { + const getConfigs = once(() => { const configs: IndexPatternCreationConfig[] = []; configs.push(new IndexPatternCreationConfig({ httpClient })); diff --git a/src/plugins/index_pattern_management/public/service/list/manager.ts b/src/plugins/index_pattern_management/public/service/list/manager.ts index 7cd55988c6b5b3..bdb2d47057f1f2 100644 --- a/src/plugins/index_pattern_management/public/service/list/manager.ts +++ b/src/plugins/index_pattern_management/public/service/list/manager.ts @@ -8,7 +8,7 @@ import { IIndexPattern, IFieldType } from 'src/plugins/data/public'; import { SimpleSavedObject } from 'src/core/public'; -import { memoize } from 'lodash'; +import { once } from 'lodash'; import { CoreStart } from '../../../../../core/public'; import { IndexPatternListConfig, IndexPatternTag } from './config'; import { CONFIG_ROLLUPS } from '../../constants'; @@ -21,7 +21,7 @@ interface IndexPatternListManagerStart { export class IndexPatternListManager { start({ uiSettings }: IndexPatternListManagerStart) { - const getConfigs = memoize(() => { + const getConfigs = once(() => { const configs: IndexPatternListConfig[] = []; configs.push(new IndexPatternListConfig());