My plugin is working in 7.6.0. I am now using Kibana 7.9.3 and the plugin fails yarn start with
FATAL TypeError: xpackMainPlugin.registerFeature is not a function
The plugin was created with the script 'node scripts/generate_plugin my_plugin_kris_script' in a prior version to 7.9.3. Here's an example with 7.6.0 the script.
import { resolve } from 'path';
import { existsSync } from 'fs';
import { i18n } from '@kbn/i18n';
import exampleRoute from './server/routes/example';
export default function(kibana) {
return new kibana.Plugin({
require: ['elasticsearch'],
name: 'my_plugin_kris_script_7_6_0',
uiExports: {
app: {
title: 'My Plugin Kris Script 7 6 0',
description: 'An awesome Kibana plugin',
main: 'plugins/my_plugin_kris_script_7_6_0/app',
},
hacks: ['plugins/my_plugin_kris_script_7_6_0/hack'],
styleSheetPaths: [
resolve(__dirname, 'public/app.scss'),
resolve(__dirname, 'public/app.css'),
].find(p => existsSync(p)),
},
config(Joi) {
return Joi.object({
enabled: Joi.boolean().default(true),
}).default();
},
// eslint-disable-next-line no-unused-vars
init(server, options) {
const xpackMainPlugin = server.plugins.xpack_main;
if (xpackMainPlugin) {
const featureId = 'my_plugin_kris_script_7_6_0';
xpackMainPlugin.registerFeature({
id: featureId,
name: i18n.translate('myPluginKrisScript760.featureRegistry.featureName', {
defaultMessage: 'my_plugin_kris_script_7.6.0',
}),
navLinkId: featureId,
icon: 'questionInCircle',
app: [featureId, 'kibana'],
catalogue: [],
privileges: {
all: {
api: [],
savedObject: {
all: [],
read: [],
},
ui: ['show'],
},
read: {
api: [],
savedObject: {
all: [],
read: [],
},
ui: ['show'],
},
},
});
}
// Add server routes and initialize the plugin here
exampleRoute(server);
},
});
}
This was posted in another post where someone was having similar issues.
The `registerFeature` function has migrated to the `features` plugin. So, in the new
plugin system, you'll have to add the `features` plugin as a dependency and then you can
call `plugin.features.registerFeature` from your plugin's setup function.
Problem I am not certain how to add the "features" plugin dependency into my plugin as its coded above and I have not been able to find examples.
Thanks,
Kris