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); 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/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/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 9db580959b116..e2e0637ef8f3f 100644 --- a/x-pack/plugins/data_visualizer/server/plugin.ts +++ b/x-pack/plugins/data_visualizer/server/plugin.ts @@ -8,12 +8,18 @@ import { CoreSetup, CoreStart, Plugin } from 'src/core/server'; import { StartDeps, SetupDeps } from './types'; import { dataVisualizerRoutes } from './routes'; +import { registerWithCustomIntegrations } from './register_custom_integration'; export class DataVisualizerPlugin implements Plugin { constructor() {} setup(coreSetup: CoreSetup, plugins: SetupDeps) { dataVisualizerRoutes(coreSetup); + + // home-plugin required + if (plugins.home && plugins.customIntegrations) { + registerWithCustomIntegrations(plugins.customIntegrations); + } } start(core: CoreStart) {} 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', + }); +} 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..3b424ef8b9f65 100644 --- a/x-pack/plugins/data_visualizer/tsconfig.json +++ b/x-pack/plugins/data_visualizer/tsconfig.json @@ -11,6 +11,7 @@ { "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" },