-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Fleet] Register Sample Data #113200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
thomasneirynck
merged 14 commits into
elastic:master
from
thomasneirynck:fleet/register_sample_data
Sep 29, 2021
Merged
[Fleet] Register Sample Data #113200
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
35d38da
boilerplate
thomasneirynck 68e286f
tmp
thomasneirynck 69b5f1f
add integration test
thomasneirynck 1ec94cb
Revert "tmp"
thomasneirynck c35b445
remove cruft
thomasneirynck ab705f9
Merge branch 'master' of github.com:elastic/kibana into fleet/registe…
thomasneirynck 2421795
feedback
thomasneirynck 2ec5fc6
Update src/plugins/home/server/services/sample_data/sample_data_regis…
thomasneirynck 424b9b1
Merge branch 'master' of github.com:elastic/kibana into fleet/registe…
thomasneirynck 4c84644
feedback
thomasneirynck 063f881
regenerate docs
thomasneirynck d3a61d8
Revert "regenerate docs"
thomasneirynck 3bcaba9
improve mock
thomasneirynck 3ee0297
Merge branch 'master' of github.com:elastic/kibana into fleet/registe…
thomasneirynck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/plugins/home/public/assets/sample_data_resources/ecommerce/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions
4
src/plugins/home/public/assets/sample_data_resources/flights/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions
4
src/plugins/home/public/assets/sample_data_resources/logs/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/plugins/home/server/services/sample_data/lib/register_with_integrations.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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', | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/plugins/home/server/services/sample_data/sample_data_registry.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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']); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.