Skip to content

Commit

Permalink
[Fleet] Add File upload (#114934)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck authored Oct 14, 2021
1 parent 57e3af7 commit dafd9d4
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions x-pack/plugins/data_visualizer/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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`;
3 changes: 2 additions & 1 deletion x-pack/plugins/data_visualizer/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"maps",
"home",
"lens",
"indexPatternFieldEditor"
"indexPatternFieldEditor",
"customIntegrations"
],
"requiredBundles": [
"home",
Expand Down
21 changes: 11 additions & 10 deletions x-pack/plugins/data_visualizer/public/register_home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions x-pack/plugins/data_visualizer/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
});
}
4 changes: 4 additions & 0 deletions x-pack/plugins/data_visualizer/server/types/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions x-pack/plugins/data_visualizer/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down

0 comments on commit dafd9d4

Please sign in to comment.