Skip to content

Commit

Permalink
Merge branch 'master' into pjhampton/bug-policy-responses
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Sep 30, 2021
2 parents eb447cc + a9d80ac commit 51cc184
Show file tree
Hide file tree
Showing 112 changed files with 3,434 additions and 1,938 deletions.
7 changes: 6 additions & 1 deletion src/plugins/custom_integrations/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,19 @@ 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;
description: string;
type: 'ui_link';
uiInternalPath: string;
isBeta: boolean;
icons: Array<{ src: string; type: string }>;
icons: CustomIntegrationIcon[];
categories: Category[];
shipper: string;
}
Expand Down
8 changes: 3 additions & 5 deletions src/plugins/custom_integrations/server/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
1 change: 0 additions & 1 deletion src/plugins/dashboard/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"data",
"embeddable",
"inspector",
"kibanaLegacy",
"navigation",
"savedObjects",
"share",
Expand Down
3 changes: 0 additions & 3 deletions src/plugins/dashboard/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { createKbnUrlTracker } from './services/kibana_utils';
import { UsageCollectionSetup } from './services/usage_collection';
import { UiActionsSetup, UiActionsStart } from './services/ui_actions';
import { PresentationUtilPluginStart } from './services/presentation_util';
import { KibanaLegacySetup, KibanaLegacyStart } from './services/kibana_legacy';
import { FeatureCatalogueCategory, HomePublicPluginSetup } from './services/home';
import { NavigationPublicPluginStart as NavigationStart } from './services/navigation';
import { DataPublicPluginSetup, DataPublicPluginStart, esFilters } from './services/data';
Expand Down Expand Up @@ -98,7 +97,6 @@ export interface DashboardSetupDependencies {
data: DataPublicPluginSetup;
embeddable: EmbeddableSetup;
home?: HomePublicPluginSetup;
kibanaLegacy: KibanaLegacySetup;
urlForwarding: UrlForwardingSetup;
share?: SharePluginSetup;
uiActions: UiActionsSetup;
Expand All @@ -107,7 +105,6 @@ export interface DashboardSetupDependencies {

export interface DashboardStartDependencies {
data: DataPublicPluginStart;
kibanaLegacy: KibanaLegacyStart;
urlForwarding: UrlForwardingStart;
embeddable: EmbeddableStart;
inspector: InspectorStartContract;
Expand Down
9 changes: 0 additions & 9 deletions src/plugins/dashboard/public/services/kibana_legacy.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/plugins/dashboard/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"references": [
{ "path": "../../core/tsconfig.json" },
{ "path": "../inspector/tsconfig.json" },
{ "path": "../kibana_legacy/tsconfig.json" },
{ "path": "../kibana_react/tsconfig.json" },
{ "path": "../kibana_utils/tsconfig.json" },
{ "path": "../share/tsconfig.json" },
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/plugins/home/server/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/home/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ export const ecommerceSpecProvider = function (): SampleDatasetSchema {
},
],
status: 'not_installed',
iconPath: '/plugins/home/assets/sample_data_resources/ecommerce/icon.svg',
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ export const flightsSpecProvider = function (): SampleDatasetSchema {
},
],
status: 'not_installed',
iconPath: '/plugins/home/assets/sample_data_resources/flights/icon.svg',
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ export const logsSpecProvider = function (): SampleDatasetSchema {
},
],
status: 'not_installed',
iconPath: '/plugins/home/assets/sample_data_resources/logs/icon.svg',
};
};
Original file line number Diff line number Diff line change
@@ -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',
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {

const createSetupMock = (): jest.Mocked<SampleDataRegistrySetup> => {
const setup = {
registerSampleDataset: jest.fn(),
getSampleDatasets: jest.fn(),
addSavedObjectsToSampleDataset: jest.fn(),
addAppLinksToSampleDataset: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
@@ -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']);
});
});
});
Loading

0 comments on commit 51cc184

Please sign in to comment.