One of the things we've done internally is to add some kind of validation in the plugin init step, which will set a variable (usually exposed on the server
instance) that we can just check when we go to set up the routes.
module.exports = function (kibana) {
var AppToDisable = 'myApp';
return new kibana.Plugin({
require: [AppToDisable],
init: function (server, options) {
server.expose('isDisabled', true);
kibana.uiExports.navLinks.inOrder.forEach((navLink) => {
if (navLink.title === AppToDisable) {
kibana.uiExports.navLinks.delete(navLink);
}
});
}
});
}
Then in your route handler, just add a conditional based on server.plugins.<myplugin>.isDisabled
, and don't set up the routes if it's true.
This, of course, works if you are trying to make the plugin disable itself, not so much if you are trying to make one plugin disable another, unless you start coupling plugins to other plugs (we've done this as well - using some universal setup plugin that controls which other plugins are disabled). You might be able to use hapi's preRoute hook (or whatever it's actually called) to abort early too, but I haven't tried this personally.
@whoami if you could share your solution here, even in summary, it would be helpful for others searching for a solution. Cheers!