[Fleet] Add File upload (#114934)

This commit is contained in:
Thomas Neirynck 2021-10-14 13:16:28 -04:00 committed by GitHub
parent 57e3af77f0
commit dafd9d4e60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 63 additions and 12 deletions

View file

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

View file

@ -5,6 +5,7 @@
* 2.0.
*/
import { i18n } from '@kbn/i18n';
import { KBN_FIELD_TYPES } from '../../../../src/plugins/data/common';
export const UI_SETTING_MAX_FILE_SIZE = 'fileUpload:maxFileSize';
@ -39,3 +40,13 @@ export const NON_AGGREGATABLE_FIELD_TYPES = new Set<string>([
KBN_FIELD_TYPES.GEO_SHAPE,
KBN_FIELD_TYPES.HISTOGRAM,
]);
export const FILE_DATA_VIS_TAB_ID = 'fileDataViz';
export const applicationPath = `/app/home#/tutorial_directory/${FILE_DATA_VIS_TAB_ID}`;
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

@ -17,7 +17,8 @@
"maps",
"home",
"lens",
"indexPatternFieldEditor"
"indexPatternFieldEditor",
"customIntegrations"
],
"requiredBundles": [
"home",

View file

@ -9,8 +9,13 @@ 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';
const FILE_DATA_VIS_TAB_ID = 'fileDataViz';
import {
featureDescription,
featureTitle,
FILE_DATA_VIS_TAB_ID,
applicationPath,
featureId,
} from '../common';
export function registerHomeAddData(home: HomePublicPluginSetup) {
home.addData.registerAddDataTab({
@ -24,15 +29,11 @@ export function registerHomeAddData(home: HomePublicPluginSetup) {
export function registerHomeFeatureCatalogue(home: HomePublicPluginSetup) {
home.featureCatalogue.register({
id: `file_data_visualizer`,
title: i18n.translate('xpack.dataVisualizer.title', {
defaultMessage: 'Upload a file',
}),
description: i18n.translate('xpack.dataVisualizer.description', {
defaultMessage: 'Import your own CSV, NDJSON, or log file.',
}),
id: featureId,
title: featureTitle,
description: featureDescription,
icon: 'document',
path: `/app/home#/tutorial_directory/${FILE_DATA_VIS_TAB_ID}`,
path: applicationPath,
showOnHomePage: true,
category: FeatureCatalogueCategory.DATA,
order: 520,

View file

@ -8,12 +8,18 @@
import { CoreSetup, CoreStart, Plugin } from 'src/core/server';
import { StartDeps, SetupDeps } from './types';
import { dataVisualizerRoutes } from './routes';
import { registerWithCustomIntegrations } from './register_custom_integration';
export class DataVisualizerPlugin implements Plugin {
constructor() {}
setup(coreSetup: CoreSetup<StartDeps, unknown>, plugins: SetupDeps) {
dataVisualizerRoutes(coreSetup);
// home-plugin required
if (plugins.home && plugins.customIntegrations) {
registerWithCustomIntegrations(plugins.customIntegrations);
}
}
start(core: CoreStart) {}

View file

@ -0,0 +1,27 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { CustomIntegrationsPluginSetup } from '../../../../src/plugins/custom_integrations/server';
import { applicationPath, featureDescription, featureId, featureTitle } from '../common';
export function registerWithCustomIntegrations(customIntegrations: CustomIntegrationsPluginSetup) {
customIntegrations.registerCustomIntegration({
id: featureId,
title: featureTitle,
description: featureDescription,
uiInternalPath: applicationPath,
isBeta: false,
icons: [
{
type: 'eui',
src: 'addDataApp',
},
],
categories: ['upload_file'],
shipper: 'other',
});
}

View file

@ -7,10 +7,14 @@
import type { SecurityPluginStart } from '../../../security/server';
import type { UsageCollectionSetup } from '../../../../../src/plugins/usage_collection/server';
import { CustomIntegrationsPluginSetup } from '../../../../../src/plugins/custom_integrations/server';
import { HomeServerPluginSetup } from '../../../../../src/plugins/home/server';
export interface StartDeps {
security?: SecurityPluginStart;
}
export interface SetupDeps {
usageCollection: UsageCollectionSetup;
customIntegrations?: CustomIntegrationsPluginSetup;
home?: HomeServerPluginSetup;
}

View file

@ -11,6 +11,7 @@
{ "path": "../../../src/core/tsconfig.json" },
{ "path": "../../../src/plugins/data/tsconfig.json" },
{ "path": "../../../src/plugins/usage_collection/tsconfig.json" },
{ "path": "../../../src/plugins/custom_integrations/tsconfig.json" },
{ "path": "../security/tsconfig.json" },
{ "path": "../file_upload/tsconfig.json" },
{ "path": "../lens/tsconfig.json" },