From 443d381dd91444d81fbf614828fd0c6b06f52b7c Mon Sep 17 00:00:00 2001 From: Johannes Schill Date: Wed, 31 Oct 2018 16:19:11 +0100 Subject: [PATCH] wip: panel-header: Add possibility to add custom actions to the menu by passing them in as props --- public/app/features/dashboard/utils/panel_menu.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/public/app/features/dashboard/utils/panel_menu.ts b/public/app/features/dashboard/utils/panel_menu.ts index de2ba852d13..c86595953b5 100644 --- a/public/app/features/dashboard/utils/panel_menu.ts +++ b/public/app/features/dashboard/utils/panel_menu.ts @@ -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({