# Can i control the plugin enabled status in other plugin?

**URL:** <https://discuss.elastic.co/t/can-i-control-the-plugin-enabled-status-in-other-plugin/52681>\
**Category:** Kibana\
**Created:** [June 14, 2016, 2:25am UTC](https://discuss.elastic.co/t/can-i-control-the-plugin-enabled-status-in-other-plugin/52681 "2016-06-14T02:25:24Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![whoami](https://avatars.discourse-cdn.com/v4/letter/w/a9a28c/32.png) [@whoami](https://discuss.elastic.co/u/whoami)\
**Post date:** [June 14, 2016, 2:25am UTC](https://discuss.elastic.co/t/can-i-control-the-plugin-enabled-status-in-other-plugin/52681/1 "2016-06-14T02:25:25Z")

</div>

can i control the plugin enabled status in other plugin?

---

<div class="post-metadata">

**Author:** ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)\
**Post date:** [June 14, 2016, 8:21pm UTC](https://discuss.elastic.co/t/can-i-control-the-plugin-enabled-status-in-other-plugin/52681/2 "2016-06-14T20:21:35Z")

</div>

If the plugin you're trying to disable is an app with an icon in the sidebar, you can also simply remove the item from the `navLink`, like so:

```auto
module.exports = function (kibana) {
  var AppToDisable = 'myApp';

  return new kibana.Plugin({
    require: [AppToDisable],
    init: function (server, options) {
      kibana.uiExports.navLinks.inOrder.forEach((navLink) => {
        if (navLink.title === AppToDisable) {
          kibana.uiExports.navLinks.delete(navLink);
        }
      });
    }
  });
}

```

You should also be able to delete apps with `kibana.uiExports.apps.delete`, like so:

```auto
return new kibana.Plugin({
  require: ['myApp'],
  init: function (server, options) {
    kibana.uiExports.apps.delete('myApp');
  }
});

```

Note that I'm using the `require` property to make sure the app has been loaded in both cases.

I haven't actually tried to do this myself, but it looks like ought to work. Also, this is all true for Kibana 5, but it doesn't look like the `navLinks` stuff is in Kibana 4.

---

<div class="post-metadata">

**Author:** ![whoami](https://avatars.discourse-cdn.com/v4/letter/w/a9a28c/32.png) [@whoami](https://discuss.elastic.co/u/whoami)\
**Post date:** [June 22, 2016, 7:25am UTC](https://discuss.elastic.co/t/can-i-control-the-plugin-enabled-status-in-other-plugin/52681/3 "2016-06-22T07:25:28Z")

</div>

> [@Joe\_Fleming](#):
>
> forEach

thanks

---

<div class="post-metadata">

**Author:** ![wq\_Huang](https://avatars.discourse-cdn.com/v4/letter/w/858c86/32.png) [@wq\_Huang](https://discuss.elastic.co/u/wq_Huang)\
**Post date:** [June 23, 2016, 6:16am UTC](https://discuss.elastic.co/t/can-i-control-the-plugin-enabled-status-in-other-plugin/52681/4 "2016-06-23T06:16:53Z")

</div>

"kibana.uiExports.apps.delete" , this method dose not work.

---

<div class="post-metadata">

**Author:** ![whoami](https://avatars.discourse-cdn.com/v4/letter/w/a9a28c/32.png) [@whoami](https://discuss.elastic.co/u/whoami)\
**Post date:** [June 23, 2016, 6:32am UTC](https://discuss.elastic.co/t/can-i-control-the-plugin-enabled-status-in-other-plugin/52681/5 "2016-06-23T06:32:04Z")

</div>

first one works

---

<div class="post-metadata">

**Author:** ![wq\_Huang](https://avatars.discourse-cdn.com/v4/letter/w/858c86/32.png) [@wq\_Huang](https://discuss.elastic.co/u/wq_Huang)\
**Post date:** [June 23, 2016, 7:43am UTC](https://discuss.elastic.co/t/can-i-control-the-plugin-enabled-status-in-other-plugin/52681/6 "2016-06-23T07:43:15Z")

</div>

yeah,but you can still access the app by typing the url in browser manually.

---

<div class="post-metadata">

**Author:** ![whoami](https://avatars.discourse-cdn.com/v4/letter/w/a9a28c/32.png) [@whoami](https://discuss.elastic.co/u/whoami)\
**Post date:** [June 23, 2016, 9:56am UTC](https://discuss.elastic.co/t/can-i-control-the-plugin-enabled-status-in-other-plugin/52681/7 "2016-06-23T09:56:59Z")

</div>

make some workaround by intercepting the url.

---

<div class="post-metadata">

**Author:** ![wq\_Huang](https://avatars.discourse-cdn.com/v4/letter/w/858c86/32.png) [@wq\_Huang](https://discuss.elastic.co/u/wq_Huang)\
**Post date:** [June 23, 2016, 10:31am UTC](https://discuss.elastic.co/t/can-i-control-the-plugin-enabled-status-in-other-plugin/52681/8 "2016-06-23T10:31:46Z")

</div>

how did you do that?

---

<div class="post-metadata">

**Author:** ![whoami](https://avatars.discourse-cdn.com/v4/letter/w/a9a28c/32.png) [@whoami](https://discuss.elastic.co/u/whoami)\
**Post date:** [June 23, 2016, 12:03pm UTC](https://discuss.elastic.co/t/can-i-control-the-plugin-enabled-status-in-other-plugin/52681/9 "2016-06-23T12:03:27Z")

</div>

do you have email?

---

<div class="post-metadata">

**Author:** ![wq\_Huang](https://avatars.discourse-cdn.com/v4/letter/w/858c86/32.png) [@wq\_Huang](https://discuss.elastic.co/u/wq_Huang)\
**Post date:** [June 23, 2016, 12:12pm UTC](https://discuss.elastic.co/t/can-i-control-the-plugin-enabled-status-in-other-plugin/52681/10 "2016-06-23T12:12:11Z")

</div>

[weiqiuhuang@gmail.com](mailto:weiqiuhuang@gmail.com),thx!

---

<div class="post-metadata">

**Author:** ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)\
**Post date:** [June 23, 2016, 4:35pm UTC](https://discuss.elastic.co/t/can-i-control-the-plugin-enabled-status-in-other-plugin/52681/11 "2016-06-23T16:35:01Z")

</div>

> [@whoami](#):
>
> make some workaround by intercepting the url.

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.

```auto
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!

---

<div class="post-metadata">

**Author:** ![whoami](https://avatars.discourse-cdn.com/v4/letter/w/a9a28c/32.png) [@whoami](https://discuss.elastic.co/u/whoami)\
**Post date:** [June 24, 2016, 1:30am UTC](https://discuss.elastic.co/t/can-i-control-the-plugin-enabled-status-in-other-plugin/52681/12 "2016-06-24T01:30:55Z")

</div>

> [@Joe\_Fleming](#):
>
> 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.

YES, kibana is based on hapi , so we can use hapi's prehook to do this, and i have tried, it works;  
in kibana, plugin A's route is like /app/{A}/..., so we can prehook the url in node layer. and i use PostAuth finish this

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:49pm UTC](https://discuss.elastic.co/t/can-i-control-the-plugin-enabled-status-in-other-plugin/52681/13 "2017-07-06T13:49:24Z")

</div>


