[Fleet] Register Sample Data (#113200)

This commit is contained in:
Thomas Neirynck 2021-09-29 18:21:04 -04:00 committed by GitHub
parent 8a63be0acc
commit 1090a356f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 172 additions and 55 deletions

View file

@ -46,6 +46,11 @@ export const CATEGORY_DISPLAY = {
export type Category = keyof typeof CATEGORY_DISPLAY;
export interface CustomIntegrationIcon {
src: string;
type: 'eui' | 'svg';
}
export interface CustomIntegration {
id: string;
title: string;
@ -53,7 +58,7 @@ export interface CustomIntegration {
type: 'ui_link';
uiInternalPath: string;
isBeta: boolean;
icons: Array<{ src: string; type: string }>;
icons: CustomIntegrationIcon[];
categories: Category[];
shipper: string;
}

View file

@ -6,17 +6,15 @@
* Side Public License, v 1.
*/
import type { MockedKeys } from '@kbn/utility-types/jest';
import { CustomIntegrationsPluginSetup } from '../server';
function createCustomIntegrationsSetup(): MockedKeys<CustomIntegrationsPluginSetup> {
const mock = {
function createCustomIntegrationsSetup(): jest.Mocked<CustomIntegrationsPluginSetup> {
const mock: jest.Mocked<CustomIntegrationsPluginSetup> = {
registerCustomIntegration: jest.fn(),
getAppendCustomIntegrations: jest.fn(),
};
return mock as MockedKeys<CustomIntegrationsPluginSetup>;
return mock;
}
export const customIntegrationsMock = {

View file

@ -0,0 +1,6 @@
<svg width="34" height="32" viewBox="0 0 34 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.00024 22C2.47508 22.2862 3.49851 22.5776 4.42785 22.8421L4.64995 22.9054C7.06615 23.5957 10.4115 24 14 24C14.7424 24 15.4744 23.9827 16.1899 23.9491C16.3251 24.6338 16.5303 25.2934 16.7976 25.9201C15.8936 25.9725 14.9581 26 14 26C6.26801 26 0 24.2091 0 22V4C0 1.79086 6.26801 0 14 0C21.732 0 28 1.79086 28 4V12.2C27.3538 12.0689 26.6849 12 26 12C24.0582 12 22.2456 12.5535 20.7115 13.5113C18.7188 13.8229 16.4318 14 14 14C8.90735 14 4.44979 13.2231 2 12.0615V16C2.47483 16.2862 3.49851 16.5776 4.42785 16.8421L4.64995 16.9054C7.06615 17.5957 10.4115 18 14 18C14.9798 18 15.9415 17.9699 16.871 17.912C16.5813 18.558 16.3581 19.2404 16.2102 19.9504C15.4903 19.9831 14.7521 20 14 20C8.90735 20 4.44979 19.2231 2 18.0615L2.00024 22ZM2 6.06148V10C2.47483 10.2862 3.49853 10.5776 4.42787 10.8421L4.64995 10.9054C7.06615 11.5957 10.4115 12 14 12C17.5885 12 20.9338 11.5957 23.3501 10.9054L23.5863 10.8381C24.5124 10.5746 25.5311 10.2848 26.0035 10H26V6.06148C23.5502 7.2231 19.0927 8 14 8C8.90735 8 4.44979 7.2231 2 6.06148ZM23.3501 3.09462C20.9338 2.40428 17.5885 2 14 2C10.4115 2 7.06615 2.40428 4.64995 3.09462C3.6667 3.37555 2.89023 3.69073 2.37721 4C2.89023 4.30927 3.6667 4.62445 4.64995 4.90538C7.06615 5.59572 10.4115 6 14 6C17.5885 6 20.9338 5.59572 23.3501 4.90538C24.3333 4.62445 25.1098 4.30927 25.6228 4C25.1098 3.69073 24.3333 3.37555 23.3501 3.09462Z" fill="#343741"/>
<path d="M22 28.5C22 27.675 22.675 27 23.5 27C24.325 27 25 27.675 25 28.5C25 29.325 24.325 30 23.5 30C22.675 30 22 29.325 22 28.5Z" fill="#343741"/>
<path d="M19 16.5V15H21.475L22.15 16.5H33.25C33.7 16.5 34 16.8 34 17.25C34 17.4 34 17.475 33.85 17.625L31.15 22.5C30.925 22.95 30.475 23.25 29.875 23.25H24.325L23.65 24.525V24.6C23.65 24.675 23.725 24.75 23.8 24.75H32.5V26.25H23.5C22.675 26.25 22 25.575 22 24.75C22 24.525 22.075 24.225 22.15 24L23.2 22.2L20.5 16.5H19Z" fill="#343741"/>
<path d="M29.5 28.5C29.5 27.675 30.175 27 31 27C31.825 27 32.5 27.675 32.5 28.5C32.5 29.325 31.825 30 31 30C30.175 30 29.5 29.325 29.5 28.5Z" fill="#343741"/>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -0,0 +1,4 @@
<svg width="34" height="32" viewBox="0 0 34 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.00024 22C2.47508 22.2862 3.49851 22.5776 4.42785 22.8421L4.64995 22.9054C7.06615 23.5957 10.4115 24 14 24C14.7424 24 15.4744 23.9827 16.1899 23.9491C16.3251 24.6338 16.5303 25.2934 16.7976 25.9201C15.8936 25.9725 14.9581 26 14 26C6.26801 26 0 24.2091 0 22V4C0 1.79086 6.26801 0 14 0C21.732 0 28 1.79086 28 4V12.2C27.3538 12.0689 26.6849 12 26 12C24.0582 12 22.2456 12.5535 20.7115 13.5113C18.7188 13.8229 16.4318 14 14 14C8.90735 14 4.44979 13.2231 2 12.0615V16C2.47483 16.2862 3.49851 16.5776 4.42785 16.8421L4.64995 16.9054C7.06615 17.5957 10.4115 18 14 18C14.9798 18 15.9415 17.9699 16.871 17.912C16.5813 18.558 16.3581 19.2404 16.2102 19.9504C15.4903 19.9831 14.7521 20 14 20C8.90735 20 4.44979 19.2231 2 18.0615L2.00024 22ZM2 6.06148V10C2.47483 10.2862 3.49853 10.5776 4.42787 10.8421L4.64995 10.9054C7.06615 11.5957 10.4115 12 14 12C17.5885 12 20.9338 11.5957 23.3501 10.9054L23.5863 10.8381C24.5124 10.5746 25.5311 10.2848 26.0035 10H26V6.06148C23.5502 7.2231 19.0927 8 14 8C8.90735 8 4.44979 7.2231 2 6.06148ZM23.3501 3.09462C20.9338 2.40428 17.5885 2 14 2C10.4115 2 7.06615 2.40428 4.64995 3.09462C3.6667 3.37555 2.89023 3.69073 2.37721 4C2.89023 4.30927 3.6667 4.62445 4.64995 4.90538C7.06615 5.59572 10.4115 6 14 6C17.5885 6 20.9338 5.59572 23.3501 4.90538C24.3333 4.62445 25.1098 4.30927 25.6228 4C25.1098 3.69073 24.3333 3.37555 23.3501 3.09462Z" fill="#343741"/>
<path d="M30.2054 20.997C30.2054 20.997 31.4286 28.6726 31.4441 28.8802C31.4626 29.0909 31.4873 29.407 31.1771 29.7356C30.7986 30.1137 30.6435 30.0518 30.4885 29.7667C30.4885 29.7667 27.3666 24.1989 27.2457 23.9975C27.1247 23.7961 26.9821 23.7713 26.7556 23.9728C26.5291 24.1743 25.285 25.3863 25.1454 25.5258C25.0195 25.6515 25.0172 25.6841 25.0089 25.8028C25.008 25.8158 25.007 25.8298 25.0058 25.845L24.7322 28.101C24.726 28.2126 24.6763 28.3242 24.5895 28.411L24.2048 28.7953C24.0093 28.9906 23.8914 28.9349 23.7985 28.6932C23.7055 28.4515 23.3274 27.1438 23.3274 27.1438C23.315 27.1129 23.2437 26.9424 23.1879 26.8867L23.1819 26.8807C23.054 26.7528 22.9365 26.6353 22.7227 26.8062C22.3287 27.1193 21.9409 27.2837 21.8293 27.1721C21.7177 27.0606 21.8821 26.6732 22.1955 26.2796C22.3635 26.0629 22.2489 25.9484 22.121 25.8207L22.115 25.8147C22.0592 25.759 21.8886 25.6877 21.8576 25.6754C21.8576 25.6754 20.5488 25.2976 20.3069 25.2047C20.065 25.1118 20.0092 24.9941 20.2046 24.7988L20.5893 24.4144C20.6762 24.3277 20.7848 24.2811 20.8995 24.2718L23.1576 23.9985C23.1775 23.9969 23.1952 23.9958 23.2112 23.9949C23.3209 23.9882 23.3554 23.986 23.4771 23.859C23.5142 23.8204 23.6266 23.7051 23.7756 23.5523C24.1888 23.1287 24.8833 22.4166 25.0315 22.2503C25.2332 22.024 25.2084 21.8815 25.0068 21.7606C24.8052 21.6398 19.2323 18.5207 19.2323 18.5207C18.9501 18.3689 18.885 18.2109 19.2635 17.8328C19.5862 17.5104 19.9026 17.5351 20.1135 17.5536C20.3244 17.5722 28.0038 18.7911 28.0038 18.7911L28.0348 18.7911C28.3492 18.7882 28.4929 18.6562 28.7234 18.4445C28.7453 18.4243 28.768 18.4034 28.7918 18.3819C28.7918 18.3819 30.9604 16.271 31.7143 15.5983C32.4682 14.9257 33.3025 14.8294 33.7367 15.2631C34.1708 15.6968 34.0744 16.5367 33.4011 17.2899C32.7279 18.0431 30.6151 20.2097 30.6151 20.2097C30.5935 20.2335 30.5726 20.2562 30.5524 20.2781C30.3405 20.5083 30.2084 20.6519 30.2055 20.966L30.2054 20.997Z" fill="#343741"/>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

@ -0,0 +1,4 @@
<svg width="34" height="32" viewBox="0 0 34 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.00024 22C2.47508 22.2862 3.49851 22.5776 4.42785 22.8421L4.64995 22.9054C7.06615 23.5957 10.4115 24 14 24C14.7424 24 15.4744 23.9827 16.1899 23.9491C16.3251 24.6338 16.5303 25.2934 16.7976 25.9201C15.8936 25.9725 14.9581 26 14 26C6.26801 26 0 24.2091 0 22V4C0 1.79086 6.26801 0 14 0C21.732 0 28 1.79086 28 4V12.2C27.3538 12.0689 26.6849 12 26 12C24.0582 12 22.2456 12.5535 20.7115 13.5113C18.7188 13.8229 16.4318 14 14 14C8.90735 14 4.44979 13.2231 2 12.0615V16C2.47483 16.2862 3.49851 16.5776 4.42785 16.8421L4.64995 16.9054C7.06615 17.5957 10.4115 18 14 18C14.9798 18 15.9415 17.9699 16.871 17.912C16.5813 18.558 16.3581 19.2404 16.2102 19.9504C15.4903 19.9831 14.7521 20 14 20C8.90735 20 4.44979 19.2231 2 18.0615L2.00024 22ZM2 6.06148V10C2.47483 10.2862 3.49853 10.5776 4.42787 10.8421L4.64995 10.9054C7.06615 11.5957 10.4115 12 14 12C17.5885 12 20.9338 11.5957 23.3501 10.9054L23.5863 10.8381C24.5124 10.5746 25.5311 10.2848 26.0035 10H26V6.06148C23.5502 7.2231 19.0927 8 14 8C8.90735 8 4.44979 7.2231 2 6.06148ZM23.3501 3.09462C20.9338 2.40428 17.5885 2 14 2C10.4115 2 7.06615 2.40428 4.64995 3.09462C3.6667 3.37555 2.89023 3.69073 2.37721 4C2.89023 4.30927 3.6667 4.62445 4.64995 4.90538C7.06615 5.59572 10.4115 6 14 6C17.5885 6 20.9338 5.59572 23.3501 4.90538C24.3333 4.62445 25.1098 4.30927 25.6228 4C25.1098 3.69073 24.3333 3.37555 23.3501 3.09462Z" fill="#343741"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M18 22.5333H18.0175C18.2919 26.703 21.7609 30 26 30C30.2391 30 33.7081 26.703 33.9825 22.5333H34V21.4667H33.9825C33.7081 17.2971 30.2391 14 26 14C21.7609 14 18.2919 17.2971 18.0175 21.4667H18V22.5333ZM20.1566 25.7333C19.5567 24.7964 19.1761 23.7056 19.0869 22.5333H22.2748C22.3102 23.6833 22.4589 24.767 22.6973 25.7333H20.1566ZM22.2748 21.4667H19.0869C19.1761 20.2944 19.5567 19.2036 20.1566 18.2667H22.6973C22.4589 19.233 22.3102 20.3167 22.2748 21.4667ZM29.7252 22.5333H32.9131C32.824 23.7056 32.4433 24.7964 31.8434 25.7333H29.3027C29.5411 24.767 29.6898 23.6833 29.7252 22.5333ZM31.8434 18.2667C32.4433 19.2036 32.824 20.2944 32.9131 21.4667H29.7252C29.6898 20.3167 29.5411 19.233 29.3027 18.2667H31.8434ZM23.7991 25.7333C23.5494 24.802 23.3815 23.7139 23.3422 22.5333H28.6578C28.6185 23.7139 28.4506 24.802 28.2009 25.7333H23.7991ZM28.2009 18.2667C28.4506 19.198 28.6185 20.2861 28.6578 21.4667H23.3422C23.3815 20.2861 23.5494 19.198 23.7991 18.2667H28.2009ZM23.895 28.608C22.7802 28.2532 21.7877 27.6241 20.9969 26.8H23.0131C23.2587 27.5009 23.5569 28.1125 23.895 28.608ZM28.9869 26.8H31.0031C30.2123 27.6241 29.2198 28.2532 28.105 28.608C28.4431 28.1125 28.7413 27.5009 28.9869 26.8ZM26 28.9333C25.3532 28.9333 24.6624 28.1223 24.146 26.8H27.854C27.3376 28.1223 26.6468 28.9333 26 28.9333ZM23.0131 17.2H20.9969C21.7877 16.3759 22.7802 15.7468 23.895 15.392C23.5569 15.8875 23.2587 16.4991 23.0131 17.2ZM28.105 15.392C29.2198 15.7468 30.2123 16.3759 31.0031 17.2H28.9869C28.7413 16.4991 28.4431 15.8875 28.105 15.392ZM26 15.0667C26.6468 15.0667 27.3376 15.8777 27.854 17.2H24.146C24.6624 15.8777 25.3532 15.0667 26 15.0667Z" fill="#343741"/>
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

View file

@ -53,7 +53,6 @@ describe('HomeServerPlugin', () => {
homeServerPluginSetupDependenciesMock
);
expect(setup).toHaveProperty('sampleData');
expect(setup.sampleData).toHaveProperty('registerSampleDataset');
expect(setup.sampleData).toHaveProperty('getSampleDatasets');
expect(setup.sampleData).toHaveProperty('addSavedObjectsToSampleDataset');
expect(setup.sampleData).toHaveProperty('addAppLinksToSampleDataset');

View file

@ -40,7 +40,9 @@ export class HomeServerPlugin implements Plugin<HomeServerPluginSetup, HomeServe
return {
tutorials: { ...this.tutorialsRegistry.setup(core, plugins.customIntegrations) },
sampleData: { ...this.sampleDataRegistry.setup(core, plugins.usageCollection) },
sampleData: {
...this.sampleDataRegistry.setup(core, plugins.usageCollection, plugins.customIntegrations),
},
};
}

View file

@ -42,5 +42,6 @@ export const ecommerceSpecProvider = function (): SampleDatasetSchema {
},
],
status: 'not_installed',
iconPath: '/plugins/home/assets/sample_data_resources/ecommerce/icon.svg',
};
};

View file

@ -42,5 +42,6 @@ export const flightsSpecProvider = function (): SampleDatasetSchema {
},
],
status: 'not_installed',
iconPath: '/plugins/home/assets/sample_data_resources/flights/icon.svg',
};
};

View file

@ -42,5 +42,6 @@ export const logsSpecProvider = function (): SampleDatasetSchema {
},
],
status: 'not_installed',
iconPath: '/plugins/home/assets/sample_data_resources/logs/icon.svg',
};
};

View file

@ -0,0 +1,36 @@
/*
* 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.
*/
import { CoreSetup } from 'kibana/server';
import { CustomIntegrationsPluginSetup } from '../../../../../custom_integrations/server';
import { SampleDatasetSchema } from './sample_dataset_schema';
import { HOME_APP_BASE_PATH } from '../../../../common/constants';
export function registerSampleDatasetWithIntegration(
customIntegrations: CustomIntegrationsPluginSetup,
core: CoreSetup,
sampleDataset: SampleDatasetSchema
) {
customIntegrations.registerCustomIntegration({
id: sampleDataset.id,
title: sampleDataset.name,
description: sampleDataset.description,
uiInternalPath: `${HOME_APP_BASE_PATH}#/tutorial_directory/sampleData`,
isBeta: false,
icons: sampleDataset.iconPath
? [
{
type: 'svg',
src: core.http.basePath.prepend(sampleDataset.iconPath),
},
]
: [],
categories: ['sample_data'],
shipper: 'sample_data',
});
}

View file

@ -67,6 +67,7 @@ export const sampleDataSchema = schema.object({
description: schema.string(),
previewImagePath: schema.string(),
darkPreviewImagePath: schema.maybe(schema.string()),
iconPath: schema.maybe(schema.string()), // relative path to icon. Used for display in the Fleet-integrations app
// saved object id of main dashboard for sample data set
overviewDashboard: schema.string(),

View file

@ -15,7 +15,6 @@ import {
const createSetupMock = (): jest.Mocked<SampleDataRegistrySetup> => {
const setup = {
registerSampleDataset: jest.fn(),
getSampleDatasets: jest.fn(),
addSavedObjectsToSampleDataset: jest.fn(),
addAppLinksToSampleDataset: jest.fn(),

View file

@ -0,0 +1,47 @@
/*
* 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.
*/
import type { MockedKeys } from '@kbn/utility-types/jest';
import { CoreSetup } from '../../../../../core/server';
import { CustomIntegrationsPluginSetup } from '../../../../custom_integrations/server';
import { customIntegrationsMock } from '../../../../custom_integrations/server/mocks';
import { SampleDataRegistry } from './sample_data_registry';
import { usageCollectionPluginMock } from '../../../../usage_collection/server/mocks';
import { UsageCollectionSetup } from '../../../../usage_collection/server/plugin';
import { coreMock } from '../../../../../core/server/mocks';
describe('SampleDataRegistry', () => {
let mockCoreSetup: MockedKeys<CoreSetup>;
let mockCustomIntegrationsPluginSetup: jest.Mocked<CustomIntegrationsPluginSetup>;
let mockUsageCollectionPluginSetup: MockedKeys<UsageCollectionSetup>;
beforeEach(() => {
mockCoreSetup = coreMock.createSetup();
mockCustomIntegrationsPluginSetup = customIntegrationsMock.createSetup();
mockUsageCollectionPluginSetup = usageCollectionPluginMock.createSetupContract();
});
describe('setup', () => {
test('should register the three sample datasets', () => {
const initContext = coreMock.createPluginInitializerContext();
const plugin = new SampleDataRegistry(initContext);
plugin.setup(
mockCoreSetup,
mockUsageCollectionPluginSetup,
mockCustomIntegrationsPluginSetup
);
const ids: string[] =
mockCustomIntegrationsPluginSetup.registerCustomIntegration.mock.calls.map((args) => {
return args[0].id;
});
expect(ids).toEqual(['flights', 'logs', 'ecommerce']);
});
});
});

View file

@ -21,20 +21,54 @@ import { createListRoute, createInstallRoute } from './routes';
import { UsageCollectionSetup } from '../../../../usage_collection/server';
import { makeSampleDataUsageCollector, usage } from './usage';
import { createUninstallRoute } from './routes/uninstall';
const flightsSampleDataset = flightsSpecProvider();
const logsSampleDataset = logsSpecProvider();
const ecommerceSampleDataset = ecommerceSpecProvider();
import { CustomIntegrationsPluginSetup } from '../../../../custom_integrations/server';
import { registerSampleDatasetWithIntegration } from './lib/register_with_integrations';
export class SampleDataRegistry {
constructor(private readonly initContext: PluginInitializerContext) {}
private readonly sampleDatasets: SampleDatasetSchema[] = [
flightsSampleDataset,
logsSampleDataset,
ecommerceSampleDataset,
];
private readonly sampleDatasets: SampleDatasetSchema[] = [];
public setup(core: CoreSetup, usageCollections: UsageCollectionSetup | undefined) {
private registerSampleDataSet(
specProvider: SampleDatasetProvider,
core: CoreSetup,
customIntegrations?: CustomIntegrationsPluginSetup
) {
let value: SampleDatasetSchema;
try {
value = sampleDataSchema.validate(specProvider());
} catch (error) {
throw new Error(`Unable to register sample dataset spec because it's invalid. ${error}`);
}
if (customIntegrations && core) {
registerSampleDatasetWithIntegration(customIntegrations, core, value);
}
const defaultIndexSavedObjectJson = value.savedObjects.find((savedObjectJson: any) => {
return savedObjectJson.type === 'index-pattern' && savedObjectJson.id === value.defaultIndex;
});
if (!defaultIndexSavedObjectJson) {
throw new Error(
`Unable to register sample dataset spec, defaultIndex: "${value.defaultIndex}" does not exist in savedObjects list.`
);
}
const dashboardSavedObjectJson = value.savedObjects.find((savedObjectJson: any) => {
return savedObjectJson.type === 'dashboard' && savedObjectJson.id === value.overviewDashboard;
});
if (!dashboardSavedObjectJson) {
throw new Error(
`Unable to register sample dataset spec, overviewDashboard: "${value.overviewDashboard}" does not exist in savedObject list.`
);
}
this.sampleDatasets.push(value);
}
public setup(
core: CoreSetup,
usageCollections: UsageCollectionSetup | undefined,
customIntegrations?: CustomIntegrationsPluginSetup
) {
if (usageCollections) {
makeSampleDataUsageCollector(usageCollections, this.initContext);
}
@ -52,38 +86,11 @@ export class SampleDataRegistry {
);
createUninstallRoute(router, this.sampleDatasets, usageTracker);
this.registerSampleDataSet(flightsSpecProvider, core, customIntegrations);
this.registerSampleDataSet(logsSpecProvider, core, customIntegrations);
this.registerSampleDataSet(ecommerceSpecProvider, core, customIntegrations);
return {
registerSampleDataset: (specProvider: SampleDatasetProvider) => {
let value: SampleDatasetSchema;
try {
value = sampleDataSchema.validate(specProvider());
} catch (error) {
throw new Error(`Unable to register sample dataset spec because it's invalid. ${error}`);
}
const defaultIndexSavedObjectJson = value.savedObjects.find((savedObjectJson: any) => {
return (
savedObjectJson.type === 'index-pattern' && savedObjectJson.id === value.defaultIndex
);
});
if (!defaultIndexSavedObjectJson) {
throw new Error(
`Unable to register sample dataset spec, defaultIndex: "${value.defaultIndex}" does not exist in savedObjects list.`
);
}
const dashboardSavedObjectJson = value.savedObjects.find((savedObjectJson: any) => {
return (
savedObjectJson.type === 'dashboard' && savedObjectJson.id === value.overviewDashboard
);
});
if (!dashboardSavedObjectJson) {
throw new Error(
`Unable to register sample dataset spec, overviewDashboard: "${value.overviewDashboard}" does not exist in savedObject list.`
);
}
this.sampleDatasets.push(value);
},
getSampleDatasets: () => this.sampleDatasets,
addSavedObjectsToSampleDataset: (id: string, savedObjects: SavedObject[]) => {

View file

@ -71,7 +71,7 @@ describe('TutorialsRegistry', () => {
let mockCoreSetup: MockedKeys<CoreSetup>;
let testProvider: TutorialProvider;
let testScopedTutorialContextFactory: ScopedTutorialContextFactory;
let mockCustomIntegrationsPluginSetup: MockedKeys<CustomIntegrationsPluginSetup>;
let mockCustomIntegrationsPluginSetup: jest.Mocked<CustomIntegrationsPluginSetup>;
beforeEach(() => {
mockCustomIntegrationsPluginSetup = customIntegrationsMock.createSetup();
@ -107,8 +107,6 @@ describe('TutorialsRegistry', () => {
const setup = new TutorialsRegistry().setup(mockCoreSetup, mockCustomIntegrationsPluginSetup);
testProvider = ({}) => validTutorialProvider;
expect(() => setup.registerTutorial(testProvider)).not.toThrowError();
// @ts-expect-error
expect(mockCustomIntegrationsPluginSetup.registerCustomIntegration.mock.calls).toEqual([
[
{

View file

@ -20,7 +20,11 @@ export default function ({ getService }: FtrProviderContext) {
.expect(200);
expect(resp.body).to.be.an('array');
expect(resp.body.length).to.be.above(0);
expect(resp.body.length).to.be.above(2); // Should at least have registered the three sample data-sets
['flights', 'logs', 'ecommerce'].forEach((sampleData) => {
expect(resp.body.findIndex((c: { id: string }) => c.id === sampleData)).to.be.above(-1);
});
});
});
}

View file

@ -19,6 +19,8 @@ import type {
} from '../../constants';
import type { ValueOf } from '../../types';
import type { CustomIntegrationIcon } from '../../../../../../src/plugins/custom_integrations/common';
import type {
PackageSpecManifest,
PackageSpecIcon,
@ -368,7 +370,7 @@ export interface IntegrationCardItem {
name: string;
title: string;
version: string;
icons: PackageSpecIcon[];
icons: Array<PackageSpecIcon | CustomIntegrationIcon>;
integration: string;
id: string;
}

View file

@ -24,6 +24,8 @@ export const CardIcon: React.FunctionComponent<UsePackageIconType & Omit<EuiIcon
const { icons } = props;
if (icons && icons.length === 1 && icons[0].type === 'eui') {
return <EuiIcon size={'xl'} type={icons[0].src} />;
} else if (icons && icons.length === 1 && icons[0].type === 'svg') {
return <EuiIcon size={'xl'} type={icons[0].src} />;
} else {
return <PackageIcon {...props} />;
}