wip: panel-header: Add possibility to add custom actions to the menu by passing them in as props
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user