mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
* Move file upload to np. Some additional mods & removals * Consume file upload from NP in maps and pass to kibana services * Register telemetry mappings * Init indexPatternService in start method * Fix type check issues. Add missing prop to telemetry * Update i18n path * Review feedback
This commit is contained in:
parent
862a42fad7
commit
ce8df3b5cc
42 changed files with 77 additions and 70 deletions
|
@ -14,7 +14,7 @@
|
|||
"xpack.drilldowns": "plugins/drilldowns",
|
||||
"xpack.endpoint": "plugins/endpoint",
|
||||
"xpack.features": "plugins/features",
|
||||
"xpack.fileUpload": "legacy/plugins/file_upload",
|
||||
"xpack.fileUpload": "plugins/file_upload",
|
||||
"xpack.graph": ["legacy/plugins/graph", "plugins/graph"],
|
||||
"xpack.grokDebugger": "legacy/plugins/grokdebugger",
|
||||
"xpack.idxMgmt": "plugins/index_management",
|
||||
|
|
|
@ -30,7 +30,6 @@ import { remoteClusters } from './legacy/plugins/remote_clusters';
|
|||
import { crossClusterReplication } from './legacy/plugins/cross_cluster_replication';
|
||||
import { upgradeAssistant } from './legacy/plugins/upgrade_assistant';
|
||||
import { uptime } from './legacy/plugins/uptime';
|
||||
import { fileUpload } from './legacy/plugins/file_upload';
|
||||
import { encryptedSavedObjects } from './legacy/plugins/encrypted_saved_objects';
|
||||
import { snapshotRestore } from './legacy/plugins/snapshot_restore';
|
||||
import { transform } from './legacy/plugins/transform';
|
||||
|
@ -68,7 +67,6 @@ module.exports = function(kibana) {
|
|||
crossClusterReplication(kibana),
|
||||
upgradeAssistant(kibana),
|
||||
uptime(kibana),
|
||||
fileUpload(kibana),
|
||||
encryptedSavedObjects(kibana),
|
||||
lens(kibana),
|
||||
snapshotRestore(kibana),
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import { FileUploadPlugin } from './server/plugin';
|
||||
import { mappings } from './mappings';
|
||||
|
||||
export const fileUpload = kibana => {
|
||||
return new kibana.Plugin({
|
||||
require: ['elasticsearch'],
|
||||
name: 'file_upload',
|
||||
id: 'file_upload',
|
||||
// TODO: uiExports and savedObjectSchemas to be removed on migration
|
||||
uiExports: {
|
||||
mappings,
|
||||
},
|
||||
savedObjectSchemas: {
|
||||
'file-upload-telemetry': {
|
||||
isNamespaceAgnostic: true,
|
||||
},
|
||||
},
|
||||
|
||||
init(server) {
|
||||
const coreSetup = server.newPlatform.setup.core;
|
||||
const coreStart = server.newPlatform.start.core;
|
||||
const { usageCollection } = server.newPlatform.setup.plugins;
|
||||
const pluginsStart = {
|
||||
usageCollection,
|
||||
};
|
||||
const fileUploadPlugin = new FileUploadPlugin();
|
||||
fileUploadPlugin.setup(coreSetup);
|
||||
fileUploadPlugin.start(coreStart, pluginsStart);
|
||||
},
|
||||
});
|
||||
};
|
|
@ -28,6 +28,12 @@ export const getInspector = () => {
|
|||
return inspector;
|
||||
};
|
||||
|
||||
let fileUploadPlugin;
|
||||
export const setFileUpload = fileUpload => (fileUploadPlugin = fileUpload);
|
||||
export const getFileUploadComponent = () => {
|
||||
return fileUploadPlugin.JsonUploadAndParse;
|
||||
};
|
||||
|
||||
export async function fetchSearchSourceAndRecordWithInspector({
|
||||
searchSource,
|
||||
requestId,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { start as fileUpload } from '../../../../../file_upload/public/legacy';
|
||||
import { getFileUploadComponent } from '../../../kibana_services';
|
||||
|
||||
export function ClientFileCreateSourceEditor({
|
||||
previewGeojsonFile,
|
||||
|
@ -14,8 +14,9 @@ export function ClientFileCreateSourceEditor({
|
|||
onRemove,
|
||||
onIndexReady,
|
||||
}) {
|
||||
const FileUpload = getFileUploadComponent();
|
||||
return (
|
||||
<fileUpload.JsonUploadAndParse
|
||||
<FileUpload
|
||||
appName={'Maps'}
|
||||
isIndexingTriggered={isIndexingTriggered}
|
||||
onFileUpload={previewGeojsonFile}
|
||||
|
|
|
@ -10,7 +10,7 @@ import { wrapInI18nContext } from 'ui/i18n';
|
|||
// @ts-ignore
|
||||
import { MapListing } from './components/map_listing';
|
||||
// @ts-ignore
|
||||
import { setLicenseId, setInspector } from './kibana_services';
|
||||
import { setLicenseId, setInspector, setFileUpload } from './kibana_services';
|
||||
import { HomePublicPluginSetup } from '../../../../../src/plugins/home/public';
|
||||
import { LicensingPluginSetup } from '../../../../plugins/licensing/public';
|
||||
import { featureCatalogueEntry } from './feature_catalogue_entry';
|
||||
|
@ -52,5 +52,6 @@ export class MapsPlugin implements Plugin<MapsPluginSetup, MapsPluginStart> {
|
|||
|
||||
public start(core: CoreStart, plugins: any) {
|
||||
setInspector(plugins.np.inspector);
|
||||
setFileUpload(plugins.np.file_upload);
|
||||
}
|
||||
}
|
||||
|
|
9
x-pack/plugins/file_upload/kibana.json
Normal file
9
x-pack/plugins/file_upload/kibana.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"id": "file_upload",
|
||||
"version": "8.0.0",
|
||||
"kibanaVersion": "kibana",
|
||||
"configPath": ["xpack", "file_upload"],
|
||||
"server": true,
|
||||
"ui": true,
|
||||
"requiredPlugins": ["data", "usageCollection"]
|
||||
}
|
|
@ -4,19 +4,17 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { npStart } from 'ui/new_platform';
|
||||
import { DEFAULT_KBN_VERSION } from '../common/constants/file_import';
|
||||
|
||||
export const indexPatternService = npStart.plugins.data.indexPatterns;
|
||||
|
||||
export let indexPatternService;
|
||||
export let savedObjectsClient;
|
||||
export let basePath;
|
||||
export let kbnVersion;
|
||||
export let kbnFetch;
|
||||
|
||||
export const initServicesAndConstants = ({ savedObjects, http, injectedMetadata }) => {
|
||||
savedObjectsClient = savedObjects.client;
|
||||
export const setupInitServicesAndConstants = ({ http }) => {
|
||||
basePath = http.basePath.basePath;
|
||||
kbnVersion = injectedMetadata.getKibanaVersion(DEFAULT_KBN_VERSION);
|
||||
kbnFetch = http.fetch;
|
||||
};
|
||||
|
||||
export const startInitServicesAndConstants = ({ savedObjects }, { data }) => {
|
||||
indexPatternService = data.indexPatterns;
|
||||
savedObjectsClient = savedObjects.client;
|
||||
};
|
|
@ -4,26 +4,36 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { Plugin, CoreStart } from 'src/core/public';
|
||||
// @ts-ignore
|
||||
import { CoreSetup, CoreStart, Plugin } from 'kibana/server';
|
||||
// @ts-ignore
|
||||
import { JsonUploadAndParse } from './components/json_upload_and_parse';
|
||||
// @ts-ignore
|
||||
import { initServicesAndConstants } from './kibana_services';
|
||||
import { setupInitServicesAndConstants, startInitServicesAndConstants } from './kibana_services';
|
||||
import { IDataPluginServices } from '../../../../src/plugins/data/public';
|
||||
|
||||
/**
|
||||
* These are the interfaces with your public contracts. You should export these
|
||||
* for other plugins to use in _their_ `SetupDeps`/`StartDeps` interfaces.
|
||||
* @public
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface FileUploadPluginSetupDependencies {}
|
||||
export interface FileUploadPluginStartDependencies {
|
||||
data: IDataPluginServices;
|
||||
}
|
||||
|
||||
export type FileUploadPluginSetup = ReturnType<FileUploadPlugin['setup']>;
|
||||
export type FileUploadPluginStart = ReturnType<FileUploadPlugin['start']>;
|
||||
|
||||
/** @internal */
|
||||
export class FileUploadPlugin implements Plugin<FileUploadPluginSetup, FileUploadPluginStart> {
|
||||
public setup() {}
|
||||
public setup(core: CoreSetup, plugins: FileUploadPluginSetupDependencies) {
|
||||
setupInitServicesAndConstants(core);
|
||||
}
|
||||
|
||||
public start(core: CoreStart) {
|
||||
initServicesAndConstants(core);
|
||||
public start(core: CoreStart, plugins: FileUploadPluginStartDependencies) {
|
||||
startInitServicesAndConstants(core, plugins);
|
||||
return {
|
||||
JsonUploadAndParse,
|
||||
};
|
|
@ -3,10 +3,8 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import { FileUploadPlugin } from './plugin';
|
||||
|
||||
import { npStart } from 'ui/new_platform';
|
||||
import { plugin } from '.';
|
||||
export * from './plugin';
|
||||
|
||||
const pluginInstance = plugin();
|
||||
|
||||
export const start = pluginInstance.start(npStart.core);
|
||||
export const plugin = () => new FileUploadPlugin();
|
|
@ -6,22 +6,22 @@
|
|||
|
||||
import { initRoutes } from './routes/file_upload';
|
||||
import { setElasticsearchClientServices, setInternalRepository } from './kibana_server_services';
|
||||
import { registerFileUploadUsageCollector } from './telemetry';
|
||||
import { registerFileUploadUsageCollector, fileUploadTelemetryMappingsType } from './telemetry';
|
||||
|
||||
export class FileUploadPlugin {
|
||||
constructor() {
|
||||
this.router = null;
|
||||
}
|
||||
|
||||
setup(core) {
|
||||
setup(core, plugins) {
|
||||
core.savedObjects.registerType(fileUploadTelemetryMappingsType);
|
||||
setElasticsearchClientServices(core.elasticsearch);
|
||||
this.router = core.http.createRouter();
|
||||
}
|
||||
|
||||
start(core, plugins) {
|
||||
initRoutes(this.router, core.savedObjects.getSavedObjectsRepository);
|
||||
setInternalRepository(core.savedObjects.createInternalRepository);
|
||||
|
||||
registerFileUploadUsageCollector(plugins.usageCollection);
|
||||
}
|
||||
|
||||
start(core) {
|
||||
initRoutes(this.router, core.savedObjects.getSavedObjectsRepository);
|
||||
setInternalRepository(core.savedObjects.createInternalRepository);
|
||||
}
|
||||
}
|
|
@ -5,3 +5,4 @@
|
|||
*/
|
||||
|
||||
export { registerFileUploadUsageCollector } from './file_upload_usage_collector';
|
||||
export { fileUploadTelemetryMappingsType } from './mappings';
|
21
x-pack/plugins/file_upload/server/telemetry/mappings.ts
Normal file
21
x-pack/plugins/file_upload/server/telemetry/mappings.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { SavedObjectsType } from 'src/core/server';
|
||||
import { TELEMETRY_DOC_ID } from './telemetry';
|
||||
|
||||
export const fileUploadTelemetryMappingsType: SavedObjectsType = {
|
||||
name: TELEMETRY_DOC_ID,
|
||||
hidden: false,
|
||||
namespaceAgnostic: true,
|
||||
mappings: {
|
||||
properties: {
|
||||
filesUploadedTotalCount: {
|
||||
type: 'long',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue