uiCapabilities is undefined

Hi,

I am creating a custom plugin for Kibana, and I am running into an issue with the plugin registration feature in this documentation: https://www.elastic.co/guide/en/kibana/current/development-plugin-feature-registration.html

When I try to look at the plugin after I installed I get the error:
TypeError: Cannot read property 'myPlugin' of undefined

I have added to my code the registration code:

    init(server) {
      const xpackMainPlugin = server.plugins.xpack_main;
      xpackMainPlugin.registerFeature({
        id: 'myPlugin',
        name: 'My Plugin',
        icon: 'merge',
        navLinkId: 'myPlugin',
        app: ['myPlugin', 'kibana'],
        catalogue: ['myPlugin'],
        privileges: {
          all: {
            savedObject: {
              all: [],
              read: [],
            },
            ui: ['show'],
          },
          read: {
            savedObject: {
              all: [],
              read: [],
            },
            ui: ['show'],
          },
        },
      });
    }

and the code to utilize the boolean to show a feature or not:

    import { uiCapabilities } from 'ui/capabilities';

    const show = uiCapabilities.myPlugin.show;
    if (show) {
      // show feature
    }

Is there some setup or configuration that I am missing in order to use uiCapabilities and have it defined?

@npm_install Welcome to the forum!
We've been migrating the entire codebase and API's have changed. If you've created your plugin using the plugin generator, then following the guide given in the docs should get you to a basic plugin that you can further develop on. If you haven't, try that, it should work.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.