Commit 443d381d by Johannes Schill

wip: panel-header: Add possibility to add custom actions to the menu by passing them in as props

parent f124b9de
......@@ -5,7 +5,12 @@ import { PanelModel } from 'app/features/dashboard/panel_model';
import { DashboardModel } from 'app/features/dashboard/dashboard_model';
import { removePanel, duplicatePanel, copyPanel, editPanelJson, sharePanel } from 'app/features/dashboard/utils/panel';
export const getPanelMenu = (dashboard: DashboardModel, panel: PanelModel) => {
export const getPanelMenu = (
dashboard: DashboardModel,
panel: PanelModel,
extraMenuItems: PanelHeaderMenuItemProps[] = [],
extraSubMenuItems: PanelHeaderMenuItemProps[] = []
) => {
const onViewPanel = () => {
store.dispatch(
updateLocation({
......@@ -77,6 +82,9 @@ export const getPanelMenu = (dashboard: DashboardModel, panel: PanelModel) => {
// TODO: Handle this somehow
// this.events.emit('init-panel-actions', menu);
extraSubMenuItems.forEach(item => {
menu.push(item);
});
return menu;
};
......@@ -109,6 +117,10 @@ export const getPanelMenu = (dashboard: DashboardModel, panel: PanelModel) => {
shortcut: 'p s',
});
extraMenuItems.forEach(item => {
menu.push(item);
});
const subMenu: PanelHeaderMenuItemProps[] = getSubMenu();
menu.push({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment