From f213bf569f48fba39dae55272251e3c3209e66d5 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Wed, 13 Oct 2021 20:14:40 -0400 Subject: [PATCH 1/6] boilerplate --- .../custom_integrations/common/index.ts | 1 + x-pack/plugins/data_visualizer/kibana.json | 3 ++- .../plugins/data_visualizer/server/plugin.ts | 26 +++++++++++++++++++ .../data_visualizer/server/types/deps.ts | 4 +++ x-pack/plugins/data_visualizer/tsconfig.json | 3 ++- 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/plugins/custom_integrations/common/index.ts b/src/plugins/custom_integrations/common/index.ts index de2a6592465a2..86d2401fba887 100755 --- a/src/plugins/custom_integrations/common/index.ts +++ b/src/plugins/custom_integrations/common/index.ts @@ -75,6 +75,7 @@ export const SHIPPER_DISPLAY = { sample_data: 'Sample data', tests: 'Tests', tutorial: 'Tutorials', + add_data: 'Add data', }; /** diff --git a/x-pack/plugins/data_visualizer/kibana.json b/x-pack/plugins/data_visualizer/kibana.json index e7f2d71313abf..e63a6b4fa2100 100644 --- a/x-pack/plugins/data_visualizer/kibana.json +++ b/x-pack/plugins/data_visualizer/kibana.json @@ -17,7 +17,8 @@ "maps", "home", "lens", - "indexPatternFieldEditor" + "indexPatternFieldEditor", + "customIntegrations" ], "requiredBundles": [ "home", diff --git a/x-pack/plugins/data_visualizer/server/plugin.ts b/x-pack/plugins/data_visualizer/server/plugin.ts index 9db580959b116..a8f141e9d09ab 100644 --- a/x-pack/plugins/data_visualizer/server/plugin.ts +++ b/x-pack/plugins/data_visualizer/server/plugin.ts @@ -6,14 +6,40 @@ */ import { CoreSetup, CoreStart, Plugin } from 'src/core/server'; +import { i18n } from '@kbn/i18n'; import { StartDeps, SetupDeps } from './types'; import { dataVisualizerRoutes } from './routes'; +const FILE_DATA_VIS_TAB_ID = 'fileDataViz'; + export class DataVisualizerPlugin implements Plugin { constructor() {} setup(coreSetup: CoreSetup, plugins: SetupDeps) { dataVisualizerRoutes(coreSetup); + + // home-plugin required + if (plugins.home && plugins.customIntegrations) { + plugins.customIntegrations.registerCustomIntegration({ + id: 'file_data_visualizer', + title: i18n.translate('xpack.dataVisualizer.title', { + defaultMessage: 'Upload a file', + }), + description: i18n.translate('xpack.dataVisualizer.description', { + defaultMessage: 'Import your own CSV, NDJSON, or log file.', + }), + uiInternalPath: `/app/home#/tutorial_directory/${FILE_DATA_VIS_TAB_ID}`, + isBeta: false, + icons: [ + { + type: 'eui', + src: 'addDataApp', + }, + ], + categories: ['upload_file'], + shipper: 'add_data', + }); + } } start(core: CoreStart) {} diff --git a/x-pack/plugins/data_visualizer/server/types/deps.ts b/x-pack/plugins/data_visualizer/server/types/deps.ts index fe982b1fa5e1a..1f6dba0592f6f 100644 --- a/x-pack/plugins/data_visualizer/server/types/deps.ts +++ b/x-pack/plugins/data_visualizer/server/types/deps.ts @@ -7,10 +7,14 @@ import type { SecurityPluginStart } from '../../../security/server'; import type { UsageCollectionSetup } from '../../../../../src/plugins/usage_collection/server'; +import { CustomIntegrationsPluginSetup } from '../../../../../src/plugins/custom_integrations/server'; +import { HomeServerPluginSetup } from '../../../../../src/plugins/home/server'; export interface StartDeps { security?: SecurityPluginStart; } export interface SetupDeps { usageCollection: UsageCollectionSetup; + customIntegrations?: CustomIntegrationsPluginSetup; + home?: HomeServerPluginSetup; } diff --git a/x-pack/plugins/data_visualizer/tsconfig.json b/x-pack/plugins/data_visualizer/tsconfig.json index ee5f894305d5a..2ff77e499f753 100644 --- a/x-pack/plugins/data_visualizer/tsconfig.json +++ b/x-pack/plugins/data_visualizer/tsconfig.json @@ -11,10 +11,11 @@ { "path": "../../../src/core/tsconfig.json" }, { "path": "../../../src/plugins/data/tsconfig.json" }, { "path": "../../../src/plugins/usage_collection/tsconfig.json" }, + { "path": "../../../src/plugins/custom_integrations/tsconfig.json" }, { "path": "../security/tsconfig.json" }, { "path": "../file_upload/tsconfig.json" }, { "path": "../lens/tsconfig.json" }, { "path": "../maps/tsconfig.json" }, - { "path": "../../../src/plugins/embeddable/tsconfig.json" } + { "path": "../../../src/plugins/embeddable/tsconfig.json" }, ] } From 10c51a698692b37682bdac7ba1c44f9eef4934b9 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Wed, 13 Oct 2021 20:16:54 -0400 Subject: [PATCH 2/6] increment test --- test/api_integration/apis/custom_integration/integrations.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/api_integration/apis/custom_integration/integrations.ts b/test/api_integration/apis/custom_integration/integrations.ts index 4b0745574b521..816e360c5a30b 100644 --- a/test/api_integration/apis/custom_integration/integrations.ts +++ b/test/api_integration/apis/custom_integration/integrations.ts @@ -23,7 +23,7 @@ export default function ({ getService }: FtrProviderContext) { expect(resp.body).to.be.an('array'); // sample data - expect(resp.body.length).to.be.above(13); // at least the language clients + tutorials + sample data + expect(resp.body.length).to.be.above(14); // at least the language clients + sample data + add data ['flights', 'logs', 'ecommerce'].forEach((sampleData) => { expect(resp.body.findIndex((c: { id: string }) => c.id === sampleData)).to.be.above(-1); From ca4f06917e690de6b01350515412de604dfae5f6 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Wed, 13 Oct 2021 20:26:01 -0400 Subject: [PATCH 3/6] remove dupe --- .../data_visualizer/common/constants.ts | 11 +++++ .../data_visualizer/public/register_home.ts | 21 +++++----- .../plugins/data_visualizer/server/plugin.ts | 41 +++++++++---------- 3 files changed, 42 insertions(+), 31 deletions(-) diff --git a/x-pack/plugins/data_visualizer/common/constants.ts b/x-pack/plugins/data_visualizer/common/constants.ts index f7bea807c3e61..5a3a1d8f2e5bf 100644 --- a/x-pack/plugins/data_visualizer/common/constants.ts +++ b/x-pack/plugins/data_visualizer/common/constants.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { i18n } from '@kbn/i18n'; import { KBN_FIELD_TYPES } from '../../../../src/plugins/data/common'; export const UI_SETTING_MAX_FILE_SIZE = 'fileUpload:maxFileSize'; @@ -39,3 +40,13 @@ export const NON_AGGREGATABLE_FIELD_TYPES = new Set([ KBN_FIELD_TYPES.GEO_SHAPE, KBN_FIELD_TYPES.HISTOGRAM, ]); + +export const FILE_DATA_VIS_TAB_ID = 'fileDataViz'; +export const applicationPath = `/app/home#/tutorial_directory/${FILE_DATA_VIS_TAB_ID}`; +export const featureTitle = i18n.translate('xpack.dataVisualizer.title', { + defaultMessage: 'Upload a file', +}); +export const featureDescription = i18n.translate('xpack.dataVisualizer.description', { + defaultMessage: 'Import your own CSV, NDJSON, or log file.', +}); +export const featureId = `file_data_visualizer`; diff --git a/x-pack/plugins/data_visualizer/public/register_home.ts b/x-pack/plugins/data_visualizer/public/register_home.ts index 3e8973784433c..4f4601ae76977 100644 --- a/x-pack/plugins/data_visualizer/public/register_home.ts +++ b/x-pack/plugins/data_visualizer/public/register_home.ts @@ -9,8 +9,13 @@ import { i18n } from '@kbn/i18n'; import type { HomePublicPluginSetup } from '../../../../src/plugins/home/public'; import { FeatureCatalogueCategory } from '../../../../src/plugins/home/public'; import { FileDataVisualizerWrapper } from './lazy_load_bundle/component_wrapper'; - -const FILE_DATA_VIS_TAB_ID = 'fileDataViz'; +import { + featureDescription, + featureTitle, + FILE_DATA_VIS_TAB_ID, + applicationPath, + featureId, +} from '../common'; export function registerHomeAddData(home: HomePublicPluginSetup) { home.addData.registerAddDataTab({ @@ -24,15 +29,11 @@ export function registerHomeAddData(home: HomePublicPluginSetup) { export function registerHomeFeatureCatalogue(home: HomePublicPluginSetup) { home.featureCatalogue.register({ - id: `file_data_visualizer`, - title: i18n.translate('xpack.dataVisualizer.title', { - defaultMessage: 'Upload a file', - }), - description: i18n.translate('xpack.dataVisualizer.description', { - defaultMessage: 'Import your own CSV, NDJSON, or log file.', - }), + id: featureId, + title: featureTitle, + description: featureDescription, icon: 'document', - path: `/app/home#/tutorial_directory/${FILE_DATA_VIS_TAB_ID}`, + path: applicationPath, showOnHomePage: true, category: FeatureCatalogueCategory.DATA, order: 520, diff --git a/x-pack/plugins/data_visualizer/server/plugin.ts b/x-pack/plugins/data_visualizer/server/plugin.ts index a8f141e9d09ab..d4e9c90cb8bc0 100644 --- a/x-pack/plugins/data_visualizer/server/plugin.ts +++ b/x-pack/plugins/data_visualizer/server/plugin.ts @@ -6,11 +6,28 @@ */ import { CoreSetup, CoreStart, Plugin } from 'src/core/server'; -import { i18n } from '@kbn/i18n'; import { StartDeps, SetupDeps } from './types'; import { dataVisualizerRoutes } from './routes'; +import { CustomIntegrationsPluginSetup } from '../../../../src/plugins/custom_integrations/server'; +import { applicationPath, featureDescription, featureId, featureTitle } from '../common'; -const FILE_DATA_VIS_TAB_ID = 'fileDataViz'; +function registerWithCustomIntegrations(customIntegrations: CustomIntegrationsPluginSetup) { + customIntegrations.registerCustomIntegration({ + id: featureId, + title: featureTitle, + description: featureDescription, + uiInternalPath: applicationPath, + isBeta: false, + icons: [ + { + type: 'eui', + src: 'addDataApp', + }, + ], + categories: ['upload_file'], + shipper: 'add_data', + }); +} export class DataVisualizerPlugin implements Plugin { constructor() {} @@ -20,25 +37,7 @@ export class DataVisualizerPlugin implements Plugin { // home-plugin required if (plugins.home && plugins.customIntegrations) { - plugins.customIntegrations.registerCustomIntegration({ - id: 'file_data_visualizer', - title: i18n.translate('xpack.dataVisualizer.title', { - defaultMessage: 'Upload a file', - }), - description: i18n.translate('xpack.dataVisualizer.description', { - defaultMessage: 'Import your own CSV, NDJSON, or log file.', - }), - uiInternalPath: `/app/home#/tutorial_directory/${FILE_DATA_VIS_TAB_ID}`, - isBeta: false, - icons: [ - { - type: 'eui', - src: 'addDataApp', - }, - ], - categories: ['upload_file'], - shipper: 'add_data', - }); + registerWithCustomIntegrations(plugins.customIntegrations); } } From 26675e2433295db6ecf118e08eb42e6af22cdfd9 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Wed, 13 Oct 2021 20:28:19 -0400 Subject: [PATCH 4/6] remove cruft --- x-pack/plugins/data_visualizer/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/data_visualizer/tsconfig.json b/x-pack/plugins/data_visualizer/tsconfig.json index 2ff77e499f753..3b424ef8b9f65 100644 --- a/x-pack/plugins/data_visualizer/tsconfig.json +++ b/x-pack/plugins/data_visualizer/tsconfig.json @@ -16,6 +16,6 @@ { "path": "../file_upload/tsconfig.json" }, { "path": "../lens/tsconfig.json" }, { "path": "../maps/tsconfig.json" }, - { "path": "../../../src/plugins/embeddable/tsconfig.json" }, + { "path": "../../../src/plugins/embeddable/tsconfig.json" } ] } From 82723ecf0a68dc448d197d1c8865c98075f96365 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Thu, 14 Oct 2021 09:25:53 -0400 Subject: [PATCH 5/6] use other --- src/plugins/custom_integrations/common/index.ts | 1 - x-pack/plugins/data_visualizer/server/plugin.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/custom_integrations/common/index.ts b/src/plugins/custom_integrations/common/index.ts index 86d2401fba887..de2a6592465a2 100755 --- a/src/plugins/custom_integrations/common/index.ts +++ b/src/plugins/custom_integrations/common/index.ts @@ -75,7 +75,6 @@ export const SHIPPER_DISPLAY = { sample_data: 'Sample data', tests: 'Tests', tutorial: 'Tutorials', - add_data: 'Add data', }; /** diff --git a/x-pack/plugins/data_visualizer/server/plugin.ts b/x-pack/plugins/data_visualizer/server/plugin.ts index d4e9c90cb8bc0..072d8895102e9 100644 --- a/x-pack/plugins/data_visualizer/server/plugin.ts +++ b/x-pack/plugins/data_visualizer/server/plugin.ts @@ -25,7 +25,7 @@ function registerWithCustomIntegrations(customIntegrations: CustomIntegrationsPl }, ], categories: ['upload_file'], - shipper: 'add_data', + shipper: 'other', }); } From 91751f53da57f75fa68959beb2ea3628ea50e801 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Thu, 14 Oct 2021 11:13:28 -0400 Subject: [PATCH 6/6] isolate in file --- .../plugins/data_visualizer/server/plugin.ts | 21 +-------------- .../server/register_custom_integration.ts | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 20 deletions(-) create mode 100644 x-pack/plugins/data_visualizer/server/register_custom_integration.ts diff --git a/x-pack/plugins/data_visualizer/server/plugin.ts b/x-pack/plugins/data_visualizer/server/plugin.ts index 072d8895102e9..e2e0637ef8f3f 100644 --- a/x-pack/plugins/data_visualizer/server/plugin.ts +++ b/x-pack/plugins/data_visualizer/server/plugin.ts @@ -8,26 +8,7 @@ import { CoreSetup, CoreStart, Plugin } from 'src/core/server'; import { StartDeps, SetupDeps } from './types'; import { dataVisualizerRoutes } from './routes'; -import { CustomIntegrationsPluginSetup } from '../../../../src/plugins/custom_integrations/server'; -import { applicationPath, featureDescription, featureId, featureTitle } from '../common'; - -function registerWithCustomIntegrations(customIntegrations: CustomIntegrationsPluginSetup) { - customIntegrations.registerCustomIntegration({ - id: featureId, - title: featureTitle, - description: featureDescription, - uiInternalPath: applicationPath, - isBeta: false, - icons: [ - { - type: 'eui', - src: 'addDataApp', - }, - ], - categories: ['upload_file'], - shipper: 'other', - }); -} +import { registerWithCustomIntegrations } from './register_custom_integration'; export class DataVisualizerPlugin implements Plugin { constructor() {} diff --git a/x-pack/plugins/data_visualizer/server/register_custom_integration.ts b/x-pack/plugins/data_visualizer/server/register_custom_integration.ts new file mode 100644 index 0000000000000..86aa3cd96d613 --- /dev/null +++ b/x-pack/plugins/data_visualizer/server/register_custom_integration.ts @@ -0,0 +1,27 @@ +/* + * 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 { CustomIntegrationsPluginSetup } from '../../../../src/plugins/custom_integrations/server'; +import { applicationPath, featureDescription, featureId, featureTitle } from '../common'; + +export function registerWithCustomIntegrations(customIntegrations: CustomIntegrationsPluginSetup) { + customIntegrations.registerCustomIntegration({ + id: featureId, + title: featureTitle, + description: featureDescription, + uiInternalPath: applicationPath, + isBeta: false, + icons: [ + { + type: 'eui', + src: 'addDataApp', + }, + ], + categories: ['upload_file'], + shipper: 'other', + }); +}