From 8e0823e36b51650c75101f558ae40fa018d06fa2 Mon Sep 17 00:00:00 2001 From: Corey Robertson Date: Thu, 9 Jul 2020 11:45:56 -0400 Subject: [PATCH 1/2] Allow Canvas Workpad Template asset type to Integrations --- .../ingest_manager/common/services/package_to_config.test.ts | 1 + x-pack/plugins/ingest_manager/common/types/models/epm.ts | 1 + .../applications/ingest_manager/sections/epm/constants.tsx | 2 ++ 3 files changed, 4 insertions(+) diff --git a/x-pack/plugins/ingest_manager/common/services/package_to_config.test.ts b/x-pack/plugins/ingest_manager/common/services/package_to_config.test.ts index e0cd32df1535e..e7dee461fb945 100644 --- a/x-pack/plugins/ingest_manager/common/services/package_to_config.test.ts +++ b/x-pack/plugins/ingest_manager/common/services/package_to_config.test.ts @@ -26,6 +26,7 @@ describe('Ingest Manager - packageToConfig', () => { search: [], 'index-pattern': [], map: [], + 'canvas-workpad-template': [], }, }, status: InstallationStatus.notInstalled, diff --git a/x-pack/plugins/ingest_manager/common/types/models/epm.ts b/x-pack/plugins/ingest_manager/common/types/models/epm.ts index a34038d4fba04..095aaf92d386d 100644 --- a/x-pack/plugins/ingest_manager/common/types/models/epm.ts +++ b/x-pack/plugins/ingest_manager/common/types/models/epm.ts @@ -29,6 +29,7 @@ export enum KibanaAssetType { search = 'search', indexPattern = 'index-pattern', map = 'map', + 'canvas-workpad-template' = 'canvas-workpad-template', } export enum ElasticsearchAssetType { diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/constants.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/constants.tsx index 31c6d76446447..bae10f2e247c5 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/constants.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/constants.tsx @@ -22,6 +22,7 @@ export const AssetTitleMap: Record = { 'index-pattern': 'Index Pattern', index_template: 'Index Template', component_template: 'Component Template', + 'canvas-workpad-template': 'Canvas Template', search: 'Saved Search', visualization: 'Visualization', input: 'Agent input', @@ -39,6 +40,7 @@ export const AssetIcons: Record = { search: 'searchProfilerApp', visualization: 'visualizeApp', map: 'mapApp', + 'canvas-workpad-template': 'canvasApp', }; export const ServiceIcons: Record = { From 7dcb3ee67ca5765570bb9540bd027176f9e2427b Mon Sep 17 00:00:00 2001 From: Corey Robertson Date: Mon, 13 Jul 2020 16:23:37 -0400 Subject: [PATCH 2/2] Add test for pathsByService --- .../services/epm/registry/index.test.ts | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/ingest_manager/server/services/epm/registry/index.test.ts b/x-pack/plugins/ingest_manager/server/services/epm/registry/index.test.ts index eae84275a49b9..ba39c2e383682 100644 --- a/x-pack/plugins/ingest_manager/server/services/epm/registry/index.test.ts +++ b/x-pack/plugins/ingest_manager/server/services/epm/registry/index.test.ts @@ -5,7 +5,7 @@ */ import { AssetParts } from '../../../types'; -import { pathParts } from './index'; +import { pathParts, groupPathsByService } from './index'; const testPaths = [ { @@ -48,3 +48,34 @@ test('testPathParts', () => { expect(pathParts(value.path)).toStrictEqual(value.assetParts as AssetParts); } }); + +test('groupPathsByService', () => { + const dashboardPaths = [ + 'foo-1.1.0/kibana/dashboard/a.json', + 'foo-1.1.0/kibana/dashboard/b.json', + 'foo-1.1.0/kibana/dashboard/c.json', + ]; + + const visualizationPaths = [ + 'foo-1.1.0/kibana/visualization/a.json', + 'foo-1.1.0/kibana/visualization/b.json', + ]; + + const canvasTemplatePaths = ['foo-1.1.0/kibana/canvas-workpad-template/a.json']; + + const unknownAssetPaths = ['foo-1.1.0/kibana/unkown/a.json']; + + const pathsByService = groupPathsByService([ + ...dashboardPaths, + ...visualizationPaths, + ...canvasTemplatePaths, + ...unknownAssetPaths, + ]); + + expect(pathsByService.kibana.dashboard).toHaveLength(dashboardPaths.length); + expect(pathsByService.kibana.visualization).toHaveLength(visualizationPaths.length); + expect(pathsByService.kibana['canvas-workpad-template']).toHaveLength(canvasTemplatePaths.length); + // TS-Ingore to make sure this unkown value does not end up on the result + // @ts-ignore + expect(pathsByService.kibana.unknown).toBeUndefined(); +});