mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Canvas] Move sample data and feature registration to canvas np plugin (#56564)
* Move sample data and feature registration to canvas np plugin * Prepare to move i18n to new platform and adjust paths Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
f304f88605
commit
0dd8129b0e
10 changed files with 44 additions and 37 deletions
|
@ -6,40 +6,9 @@
|
|||
|
||||
import { CoreSetup, PluginsSetup } from './shim';
|
||||
import { functions } from '../canvas_plugin_src/functions/server';
|
||||
import { loadSampleData } from './sample_data';
|
||||
|
||||
export class Plugin {
|
||||
public setup(core: CoreSetup, plugins: PluginsSetup) {
|
||||
plugins.interpreter.register({ serverFunctions: functions });
|
||||
|
||||
plugins.features.registerFeature({
|
||||
id: 'canvas',
|
||||
name: 'Canvas',
|
||||
icon: 'canvasApp',
|
||||
navLinkId: 'canvas',
|
||||
app: ['canvas', 'kibana'],
|
||||
catalogue: ['canvas'],
|
||||
privileges: {
|
||||
all: {
|
||||
savedObject: {
|
||||
all: ['canvas-workpad', 'canvas-element'],
|
||||
read: ['index-pattern'],
|
||||
},
|
||||
ui: ['save', 'show'],
|
||||
},
|
||||
read: {
|
||||
savedObject: {
|
||||
all: [],
|
||||
read: ['index-pattern', 'canvas-workpad', 'canvas-element'],
|
||||
},
|
||||
ui: ['show'],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
loadSampleData(
|
||||
plugins.home.sampleData.addSavedObjectsToSampleDataset,
|
||||
plugins.home.sampleData.addAppLinksToSampleDataset
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,10 +29,6 @@ export interface PluginsSetup {
|
|||
kibana: {
|
||||
injectedUiAppVars: ReturnType<Legacy.Server['getInjectedUiAppVars']>;
|
||||
};
|
||||
sampleData: {
|
||||
addSavedObjectsToSampleDataset: any;
|
||||
addAppLinksToSampleDataset: any;
|
||||
};
|
||||
usageCollection: UsageCollectionSetup;
|
||||
}
|
||||
|
||||
|
|
7
x-pack/plugins/canvas/i18n/index.ts
Normal file
7
x-pack/plugins/canvas/i18n/index.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export * from '../../../legacy/plugins/canvas/i18n';
|
|
@ -5,6 +5,6 @@
|
|||
"configPath": ["xpack", "canvas"],
|
||||
"server": true,
|
||||
"ui": false,
|
||||
"requiredPlugins": [],
|
||||
"requiredPlugins": ["features", "home"],
|
||||
"optionalPlugins": ["usageCollection"]
|
||||
}
|
||||
|
|
|
@ -7,11 +7,16 @@
|
|||
import { first } from 'rxjs/operators';
|
||||
import { CoreSetup, PluginInitializerContext, Plugin, Logger } from 'src/core/server';
|
||||
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
|
||||
import { HomeServerPluginSetup } from 'src/plugins/home/server';
|
||||
import { PluginSetupContract as FeaturesPluginSetup } from '../../features/server';
|
||||
import { initRoutes } from './routes';
|
||||
import { registerCanvasUsageCollector } from './collectors';
|
||||
import { loadSampleData } from './sample_data';
|
||||
|
||||
interface PluginsSetup {
|
||||
usageCollection?: UsageCollectionSetup;
|
||||
features: FeaturesPluginSetup;
|
||||
home: HomeServerPluginSetup;
|
||||
}
|
||||
|
||||
export class CanvasPlugin implements Plugin {
|
||||
|
@ -21,10 +26,40 @@ export class CanvasPlugin implements Plugin {
|
|||
}
|
||||
|
||||
public async setup(coreSetup: CoreSetup, plugins: PluginsSetup) {
|
||||
plugins.features.registerFeature({
|
||||
id: 'canvas',
|
||||
name: 'Canvas',
|
||||
icon: 'canvasApp',
|
||||
navLinkId: 'canvas',
|
||||
app: ['canvas', 'kibana'],
|
||||
catalogue: ['canvas'],
|
||||
privileges: {
|
||||
all: {
|
||||
savedObject: {
|
||||
all: ['canvas-workpad', 'canvas-element'],
|
||||
read: ['index-pattern'],
|
||||
},
|
||||
ui: ['save', 'show'],
|
||||
},
|
||||
read: {
|
||||
savedObject: {
|
||||
all: [],
|
||||
read: ['index-pattern', 'canvas-workpad', 'canvas-element'],
|
||||
},
|
||||
ui: ['show'],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const canvasRouter = coreSetup.http.createRouter();
|
||||
|
||||
initRoutes({ router: canvasRouter, logger: this.logger });
|
||||
|
||||
loadSampleData(
|
||||
plugins.home.sampleData.addSavedObjectsToSampleDataset,
|
||||
plugins.home.sampleData.addAppLinksToSampleDataset
|
||||
);
|
||||
|
||||
// we need the kibana index provided by global config for the Canvas usage collector
|
||||
const globalConfig = await this.initializerContext.config.legacy.globalConfig$
|
||||
.pipe(first())
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { SampleDataRegistrySetup } from 'src/plugins/home/server';
|
||||
import { CANVAS as label } from '../../i18n';
|
||||
// @ts-ignore Untyped local
|
||||
import { ecommerceSavedObjects, flightsSavedObjects, webLogsSavedObjects } from './index';
|
||||
import { SampleDataRegistrySetup } from '../../../../../../src/plugins/home/server';
|
||||
|
||||
export function loadSampleData(
|
||||
addSavedObjectsToSampleDataset: SampleDataRegistrySetup['addSavedObjectsToSampleDataset'],
|
Loading…
Add table
Add a link
Reference in a new issue