[Fleet] Sample data and copy tweaks (#115078)

This commit is contained in:
Thomas Neirynck 2021-10-18 10:33:42 -04:00 committed by GitHub
parent d93afe82e5
commit 0928197ad6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 82 additions and 119 deletions

View file

@ -23,18 +23,6 @@ interface LanguageIntegration {
const ELASTIC_WEBSITE_URL = 'https://www.elastic.co';
const ELASTICSEARCH_CLIENT_URL = `${ELASTIC_WEBSITE_URL}/guide/en/elasticsearch/client`;
export const integrations: LanguageIntegration[] = [
{
id: 'all',
title: i18n.translate('customIntegrations.languageclients.AllTitle', {
defaultMessage: 'Elasticsearch Clients',
}),
euiIconName: 'logoElasticsearch',
description: i18n.translate('customIntegrations.languageclients.AllDescription', {
defaultMessage:
'Start building your custom application on top of Elasticsearch with the official language clients.',
}),
docUrlTemplate: `${ELASTICSEARCH_CLIENT_URL}/index.html`,
},
{
id: 'javascript',
title: i18n.translate('customIntegrations.languageclients.JavascriptTitle', {
@ -42,8 +30,7 @@ export const integrations: LanguageIntegration[] = [
}),
icon: 'nodejs.svg',
description: i18n.translate('customIntegrations.languageclients.JavascriptDescription', {
defaultMessage:
'Start building your custom application on top of Elasticsearch with the official Node.js client.',
defaultMessage: 'Index data to Elasticsearch with the JavaScript client.',
}),
docUrlTemplate: `${ELASTICSEARCH_CLIENT_URL}/javascript-api/{branch}/introduction.html`,
},
@ -54,8 +41,7 @@ export const integrations: LanguageIntegration[] = [
}),
icon: 'ruby.svg',
description: i18n.translate('customIntegrations.languageclients.RubyDescription', {
defaultMessage:
'Start building your custom application on top of Elasticsearch with the official Ruby client.',
defaultMessage: 'Index data to Elasticsearch with the Ruby client.',
}),
docUrlTemplate: `${ELASTICSEARCH_CLIENT_URL}/ruby-api/{branch}/ruby_client.html`,
},
@ -66,8 +52,7 @@ export const integrations: LanguageIntegration[] = [
}),
icon: 'go.svg',
description: i18n.translate('customIntegrations.languageclients.GoDescription', {
defaultMessage:
'Start building your custom application on top of Elasticsearch with the official Go client.',
defaultMessage: 'Index data to Elasticsearch with the Go client.',
}),
docUrlTemplate: `${ELASTICSEARCH_CLIENT_URL}/go-api/{branch}/overview.html`,
},
@ -78,8 +63,7 @@ export const integrations: LanguageIntegration[] = [
}),
icon: 'dotnet.svg',
description: i18n.translate('customIntegrations.languageclients.DotNetDescription', {
defaultMessage:
'Start building your custom application on top of Elasticsearch with the official .NET client.',
defaultMessage: 'Index data to Elasticsearch with the .NET client.',
}),
docUrlTemplate: `${ELASTICSEARCH_CLIENT_URL}/net-api/{branch}/index.html`,
},
@ -90,8 +74,7 @@ export const integrations: LanguageIntegration[] = [
}),
icon: 'php.svg',
description: i18n.translate('customIntegrations.languageclients.PhpDescription', {
defaultMessage:
'Start building your custom application on top of Elasticsearch with the official .PHP client.',
defaultMessage: 'Index data to Elasticsearch with the PHP client.',
}),
docUrlTemplate: `${ELASTICSEARCH_CLIENT_URL}/php-api/{branch}/index.html`,
},
@ -102,8 +85,7 @@ export const integrations: LanguageIntegration[] = [
}),
icon: 'perl.svg',
description: i18n.translate('customIntegrations.languageclients.PerlDescription', {
defaultMessage:
'Start building your custom application on top of Elasticsearch with the official Perl client.',
defaultMessage: 'Index data to Elasticsearch with the Perl client.',
}),
docUrlTemplate: `${ELASTICSEARCH_CLIENT_URL}/perl-api/{branch}/index.html`,
},
@ -114,8 +96,7 @@ export const integrations: LanguageIntegration[] = [
}),
icon: 'python.svg',
description: i18n.translate('customIntegrations.languageclients.PythonDescription', {
defaultMessage:
'Start building your custom application on top of Elasticsearch with the official Python client.',
defaultMessage: 'Index data to Elasticsearch with the Python client.',
}),
docUrlTemplate: `${ELASTICSEARCH_CLIENT_URL}/python-api/{branch}/index.html`,
},
@ -126,8 +107,7 @@ export const integrations: LanguageIntegration[] = [
}),
icon: 'rust.svg',
description: i18n.translate('customIntegrations.languageclients.RustDescription', {
defaultMessage:
'Start building your custom application on top of Elasticsearch with the official Rust client.',
defaultMessage: 'Index data to Elasticsearch with the Rust client.',
}),
docUrlTemplate: `${ELASTICSEARCH_CLIENT_URL}/rust-api/{branch}/index.html`,
},
@ -138,8 +118,7 @@ export const integrations: LanguageIntegration[] = [
}),
icon: 'java.svg',
description: i18n.translate('customIntegrations.languageclients.JavaDescription', {
defaultMessage:
'Start building your custom application on top of Elasticsearch with the official Java client.',
defaultMessage: 'Index data to Elasticsearch with the Java client.',
}),
docUrlTemplate: `${ELASTICSEARCH_CLIENT_URL}/java-api-client/{branch}/index.html`,
},

View file

@ -31,23 +31,10 @@ describe('CustomIntegrationsPlugin', () => {
test('should register language clients', () => {
const setup = new CustomIntegrationsPlugin(initContext).setup(mockCoreSetup);
expect(setup.getAppendCustomIntegrations()).toEqual([
{
id: 'language_client.all',
title: 'Elasticsearch Clients',
description:
'Start building your custom application on top of Elasticsearch with the official language clients.',
type: 'ui_link',
shipper: 'language_clients',
uiInternalPath: 'https://www.elastic.co/guide/en/elasticsearch/client/index.html',
isBeta: false,
icons: [{ type: 'eui', src: 'logoElasticsearch' }],
categories: ['elastic_stack', 'custom', 'language_client'],
},
{
id: 'language_client.javascript',
title: 'Elasticsearch JavaScript Client',
description:
'Start building your custom application on top of Elasticsearch with the official Node.js client.',
description: 'Index data to Elasticsearch with the JavaScript client.',
type: 'ui_link',
shipper: 'language_clients',
uiInternalPath:
@ -59,8 +46,7 @@ describe('CustomIntegrationsPlugin', () => {
{
id: 'language_client.ruby',
title: 'Elasticsearch Ruby Client',
description:
'Start building your custom application on top of Elasticsearch with the official Ruby client.',
description: 'Index data to Elasticsearch with the Ruby client.',
type: 'ui_link',
shipper: 'language_clients',
uiInternalPath:
@ -72,8 +58,7 @@ describe('CustomIntegrationsPlugin', () => {
{
id: 'language_client.go',
title: 'Elasticsearch Go Client',
description:
'Start building your custom application on top of Elasticsearch with the official Go client.',
description: 'Index data to Elasticsearch with the Go client.',
type: 'ui_link',
shipper: 'language_clients',
uiInternalPath:
@ -85,8 +70,7 @@ describe('CustomIntegrationsPlugin', () => {
{
id: 'language_client.dotnet',
title: 'Elasticsearch .NET Client',
description:
'Start building your custom application on top of Elasticsearch with the official .NET client.',
description: 'Index data to Elasticsearch with the .NET client.',
type: 'ui_link',
shipper: 'language_clients',
uiInternalPath:
@ -98,8 +82,7 @@ describe('CustomIntegrationsPlugin', () => {
{
id: 'language_client.php',
title: 'Elasticsearch PHP Client',
description:
'Start building your custom application on top of Elasticsearch with the official .PHP client.',
description: 'Index data to Elasticsearch with the PHP client.',
type: 'ui_link',
shipper: 'language_clients',
uiInternalPath:
@ -111,8 +94,7 @@ describe('CustomIntegrationsPlugin', () => {
{
id: 'language_client.perl',
title: 'Elasticsearch Perl Client',
description:
'Start building your custom application on top of Elasticsearch with the official Perl client.',
description: 'Index data to Elasticsearch with the Perl client.',
type: 'ui_link',
shipper: 'language_clients',
uiInternalPath:
@ -124,8 +106,7 @@ describe('CustomIntegrationsPlugin', () => {
{
id: 'language_client.python',
title: 'Elasticsearch Python Client',
description:
'Start building your custom application on top of Elasticsearch with the official Python client.',
description: 'Index data to Elasticsearch with the Python client.',
type: 'ui_link',
shipper: 'language_clients',
uiInternalPath:
@ -137,8 +118,7 @@ describe('CustomIntegrationsPlugin', () => {
{
id: 'language_client.rust',
title: 'Elasticsearch Rust Client',
description:
'Start building your custom application on top of Elasticsearch with the official Rust client.',
description: 'Index data to Elasticsearch with the Rust client.',
type: 'ui_link',
shipper: 'language_clients',
uiInternalPath:
@ -150,8 +130,7 @@ describe('CustomIntegrationsPlugin', () => {
{
id: 'language_client.java',
title: 'Elasticsearch Java Client',
description:
'Start building your custom application on top of Elasticsearch with the official Java client.',
description: 'Index data to Elasticsearch with the Java client.',
type: 'ui_link',
shipper: 'language_clients',
uiInternalPath:

View file

@ -20,6 +20,7 @@ const logsDescription = i18n.translate('home.sampleData.logsSpecDescription', {
});
const initialAppLinks = [] as AppLinkSchema[];
export const GLOBE_ICON_PATH = '/plugins/home/assets/sample_data_resources/logs/icon.svg';
export const logsSpecProvider = function (): SampleDatasetSchema {
return {
id: 'logs',
@ -42,6 +43,6 @@ export const logsSpecProvider = function (): SampleDatasetSchema {
},
],
status: 'not_installed',
iconPath: '/plugins/home/assets/sample_data_resources/logs/icon.svg',
iconPath: GLOBE_ICON_PATH,
};
};

View file

@ -7,29 +7,26 @@
*/
import { CoreSetup } from 'kibana/server';
import { i18n } from '@kbn/i18n';
import { CustomIntegrationsPluginSetup } from '../../../../../custom_integrations/server';
import { SampleDatasetSchema } from './sample_dataset_schema';
import { HOME_APP_BASE_PATH } from '../../../../common/constants';
import { GLOBE_ICON_PATH } from '../data_sets/logs';
export function registerSampleDatasetWithIntegration(
customIntegrations: CustomIntegrationsPluginSetup,
core: CoreSetup,
sampleDataset: SampleDatasetSchema
core: CoreSetup
) {
customIntegrations.registerCustomIntegration({
id: sampleDataset.id,
title: sampleDataset.name,
description: sampleDataset.description,
id: 'sample_data_all',
title: i18n.translate('home.sampleData.customIntegrationsTitle', {
defaultMessage: 'Sample Data',
}),
description: i18n.translate('home.sampleData.customIntegrationsDescription', {
defaultMessage: 'Add sample data and assets to Elasticsearch and Kibana.',
}),
uiInternalPath: `${HOME_APP_BASE_PATH}#/tutorial_directory/sampleData`,
isBeta: false,
icons: sampleDataset.iconPath
? [
{
type: 'svg',
src: core.http.basePath.prepend(sampleDataset.iconPath),
},
]
: [],
icons: [{ type: 'svg', src: core.http.basePath.prepend(GLOBE_ICON_PATH) }],
categories: ['sample_data'],
shipper: 'sample_data',
});

View file

@ -28,20 +28,36 @@ describe('SampleDataRegistry', () => {
});
describe('setup', () => {
test('should register the three sample datasets', () => {
let sampleDataRegistry: SampleDataRegistry;
beforeEach(() => {
const initContext = coreMock.createPluginInitializerContext();
const plugin = new SampleDataRegistry(initContext);
plugin.setup(
sampleDataRegistry = new SampleDataRegistry(initContext);
});
test('should register the three sample datasets', () => {
const setup = sampleDataRegistry.setup(
mockCoreSetup,
mockUsageCollectionPluginSetup,
mockCustomIntegrationsPluginSetup
);
const datasets = setup.getSampleDatasets();
expect(datasets[0].id).toEqual('flights');
expect(datasets[2].id).toEqual('ecommerce');
expect(datasets[1].id).toEqual('logs');
});
test('should register the three sample datasets as single card', () => {
sampleDataRegistry.setup(
mockCoreSetup,
mockUsageCollectionPluginSetup,
mockCustomIntegrationsPluginSetup
);
const ids: string[] =
mockCustomIntegrationsPluginSetup.registerCustomIntegration.mock.calls.map((args) => {
return args[0].id;
});
expect(ids).toEqual(['flights', 'logs', 'ecommerce']);
expect(ids).toEqual(['sample_data_all']);
});
});
});

View file

@ -28,22 +28,13 @@ export class SampleDataRegistry {
constructor(private readonly initContext: PluginInitializerContext) {}
private readonly sampleDatasets: SampleDatasetSchema[] = [];
private registerSampleDataSet(
specProvider: SampleDatasetProvider,
core: CoreSetup,
customIntegrations?: CustomIntegrationsPluginSetup
) {
private 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}`);
}
if (customIntegrations && core) {
registerSampleDatasetWithIntegration(customIntegrations, core, value);
}
const defaultIndexSavedObjectJson = value.savedObjects.find((savedObjectJson: any) => {
return savedObjectJson.type === 'index-pattern' && savedObjectJson.id === value.defaultIndex;
});
@ -86,9 +77,12 @@ export class SampleDataRegistry {
);
createUninstallRoute(router, this.sampleDatasets, usageTracker);
this.registerSampleDataSet(flightsSpecProvider, core, customIntegrations);
this.registerSampleDataSet(logsSpecProvider, core, customIntegrations);
this.registerSampleDataSet(ecommerceSpecProvider, core, customIntegrations);
this.registerSampleDataSet(flightsSpecProvider);
this.registerSampleDataSet(logsSpecProvider);
this.registerSampleDataSet(ecommerceSpecProvider);
if (customIntegrations && core) {
registerSampleDatasetWithIntegration(customIntegrations, core);
}
return {
getSampleDatasets: () => this.sampleDatasets,

View file

@ -22,12 +22,12 @@ export default function ({ getService }: FtrProviderContext) {
expect(resp.body).to.be.an('array');
// sample data
expect(resp.body.length).to.be.above(14); // at least the language clients + sample data + add data
expect(resp.body.length).to.be(12);
['flights', 'logs', 'ecommerce'].forEach((sampleData) => {
expect(resp.body.findIndex((c: { id: string }) => c.id === sampleData)).to.be.above(-1);
});
// Test for sample data card
expect(resp.body.findIndex((c: { id: string }) => c.id === 'sample_data_all')).to.be.above(
-1
);
});
});

View file

@ -46,7 +46,4 @@ export const applicationPath = `/app/home#/tutorial_directory/${FILE_DATA_VIS_TA
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`;

View file

@ -9,13 +9,7 @@ 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';
import {
featureDescription,
featureTitle,
FILE_DATA_VIS_TAB_ID,
applicationPath,
featureId,
} from '../common';
import { featureTitle, FILE_DATA_VIS_TAB_ID, applicationPath, featureId } from '../common';
export function registerHomeAddData(home: HomePublicPluginSetup) {
home.addData.registerAddDataTab({
@ -31,7 +25,9 @@ export function registerHomeFeatureCatalogue(home: HomePublicPluginSetup) {
home.featureCatalogue.register({
id: featureId,
title: featureTitle,
description: featureDescription,
description: i18n.translate('xpack.dataVisualizer.description', {
defaultMessage: 'Import your own CSV, NDJSON, or log file.',
}),
icon: 'document',
path: applicationPath,
showOnHomePage: true,

View file

@ -5,14 +5,18 @@
* 2.0.
*/
import { i18n } from '@kbn/i18n';
import { CustomIntegrationsPluginSetup } from '../../../../src/plugins/custom_integrations/server';
import { applicationPath, featureDescription, featureId, featureTitle } from '../common';
import { applicationPath, featureId, featureTitle } from '../common';
export function registerWithCustomIntegrations(customIntegrations: CustomIntegrationsPluginSetup) {
customIntegrations.registerCustomIntegration({
id: featureId,
title: featureTitle,
description: featureDescription,
description: i18n.translate('xpack.dataVisualizer.customIntegrationsDescription', {
defaultMessage:
'Upload data from a CSV, TSV, JSON or other log file to Elasticsearch for analysis.',
}),
uiInternalPath: applicationPath,
isBeta: false,
icons: [

View file

@ -41,7 +41,7 @@ export const DefaultLayout: React.FunctionComponent<Props> = memo(({ section, ch
<p>
<FormattedMessage
id="xpack.fleet.epm.pageSubtitle"
defaultMessage="Choose an integration to start collecting and analyzing your data"
defaultMessage="Choose an integration to start collecting and analyzing your data."
/>
</p>
</EuiText>

View file

@ -54,7 +54,7 @@ const title = (
const recommendedTooltip = (
<FormattedMessage
id="xpack.fleet.epm.integrationPreference.recommendedTooltip"
defaultMessage="Generally available (GA) integrations are recommended over beta and experimental."
defaultMessage="We recommend Elastic Agent integrations when they are generally available."
/>
);

View file

@ -181,7 +181,7 @@ export const AvailablePackages: React.FC = memo(() => {
let controls = [
<EuiFlexItem grow={false}>
<EuiHorizontalRule margin="m" />
<IntegrationPreference initialType={preference} onChange={setPreference} />,
<IntegrationPreference initialType={preference} onChange={setPreference} />
</EuiFlexItem>,
];

View file

@ -32,7 +32,7 @@ exports[`should render EMS UI when left source is BOUNDARIES_SOURCE.EMS 1`] = `
Array [
Object {
"id": "EMS",
"label": "Administrative boundaries from Elastic Maps Service",
"label": "Administrative boundaries from the Elastic Maps Service",
},
Object {
"id": "ELASTICSEARCH",
@ -85,7 +85,7 @@ exports[`should render elasticsearch UI when left source is BOUNDARIES_SOURCE.EL
Array [
Object {
"id": "EMS",
"label": "Administrative boundaries from Elastic Maps Service",
"label": "Administrative boundaries from the Elastic Maps Service",
},
Object {
"id": "ELASTICSEARCH",

View file

@ -40,7 +40,7 @@ const BOUNDARIES_OPTIONS = [
{
id: BOUNDARIES_SOURCE.EMS,
label: i18n.translate('xpack.maps.choropleth.boundaries.ems', {
defaultMessage: 'Administrative boundaries from Elastic Maps Service',
defaultMessage: 'Administrative boundaries from the Elastic Maps Service',
}),
},
{

View file

@ -61,11 +61,11 @@ export function emsBoundariesSpecProvider({
return () => ({
id: 'emsBoundaries',
name: i18n.translate('xpack.maps.tutorials.ems.nameTitle', {
defaultMessage: 'EMS Boundaries',
defaultMessage: 'Elastic Maps Service',
}),
category: TutorialsCategory.OTHER,
shortDescription: i18n.translate('xpack.maps.tutorials.ems.shortDescription', {
defaultMessage: 'Administrative boundaries from Elastic Maps Service.',
defaultMessage: 'Administrative boundaries from the Elastic Maps Service.',
}),
longDescription: i18n.translate('xpack.maps.tutorials.ems.longDescription', {
defaultMessage:

View file

@ -521,7 +521,7 @@ export class GisPageObject extends FtrService {
}
async selectEMSBoundariesSource() {
this.log.debug(`Select EMS boundaries source`);
this.log.debug(`Select Elastic Maps Service boundaries source`);
await this.testSubjects.click('emsBoundaries');
}