Add new button to visualizations' top navbar

I am creating a Kibana plugin, and I want to add a new plugin, so I need to add a button on the top navbar of the visualization pages. I have two questions:
1- how do I add the button?
2- how can I access the data/request in the visualzition using also my plugin (like when I click the new button)?

For the first question, I did this:

import { NavigationPublicPluginSetup } from '../../../src/plugins/navigation/public/types';

interface PluginSetupDeps {
  navigation: NavigationPublicPluginSetup;
}

export class MyPlugin implements Plugin<MyPluginSetup, MyPluginStart> {
  public setup(core: CoreSetup, { navigation }: PluginSetupDeps) {
    const customExtension = {
      id: 'plugin-prop',
      label: 'Click Me', // [optional] label to use, otherwise it uses whatever you put in 'key'
      run: () => {
        alert('hi');
      },
    };
    navigation.registerMenuItem(customExtension);
    return {};
  }

  public start(core: CoreStart) {
    return {};
  }

  public stop() {}
}


but the 'navigation' was undefined. Is 'NavigationPublicPluginSetup ' right? or what is the wrong?

Thanks.

Hi @aza-zil ,

I suggest using official plugin generator tool and you can get more information about external plugin development here

Make sure you follow development guide and build the plugins

Let me know if it works after you follow the guide.

Regards, Dzmitry

Thank you @Dzmitry , Sorry I did not update the question. I was using the provided code in the server side, while it was supposed to be in the public side.

Now the second part remains. I want to get the request (located in inspector) using my plugin, any idea on how to do it?

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