diff --git a/public/app/core/services/keybindingSrv.ts b/public/app/core/services/keybindingSrv.ts index 87f0daa29fb..56086599104 100644 --- a/public/app/core/services/keybindingSrv.ts +++ b/public/app/core/services/keybindingSrv.ts @@ -272,7 +272,7 @@ export class KeybindingSrv { this.bind('p r', () => { const panelId = dashboard.meta.focusPanelId; - if (panelId && dashboard.canEditPanelById(panelId)) { + if (panelId && dashboard.canEditPanelById(panelId) && !(dashboard.panelInView || dashboard.panelInEdit)) { appEvents.emit(CoreEvents.removePanel, panelId); dashboard.meta.focusPanelId = 0; } diff --git a/public/app/features/dashboard/utils/getPanelMenu.test.ts b/public/app/features/dashboard/utils/getPanelMenu.test.ts index 7ff92deba02..be663ee3160 100644 --- a/public/app/features/dashboard/utils/getPanelMenu.test.ts +++ b/public/app/features/dashboard/utils/getPanelMenu.test.ts @@ -151,16 +151,6 @@ describe('getPanelMenu', () => { "text": "More...", "type": "submenu", }, - Object { - "text": "", - "type": "divider", - }, - Object { - "iconClassName": "trash-alt", - "onClick": [Function], - "shortcut": "p r", - "text": "Remove", - }, ] `); }); diff --git a/public/app/features/dashboard/utils/getPanelMenu.ts b/public/app/features/dashboard/utils/getPanelMenu.ts index 3c8a8282ebc..b1b0f9fe275 100644 --- a/public/app/features/dashboard/utils/getPanelMenu.ts +++ b/public/app/features/dashboard/utils/getPanelMenu.ts @@ -197,7 +197,7 @@ export function getPanelMenu( }); } - if (dashboard.canEditPanel(panel) && !panel.isEditing) { + if (dashboard.canEditPanel(panel) && !panel.isEditing && !panel.isViewing) { menu.push({ type: 'divider', text: '' }); menu.push({ diff --git a/public/app/features/dashboard/utils/panel.ts b/public/app/features/dashboard/utils/panel.ts index 82364981d03..89f74f48859 100644 --- a/public/app/features/dashboard/utils/panel.ts +++ b/public/app/features/dashboard/utils/panel.ts @@ -39,6 +39,7 @@ export const removePanel = (dashboard: DashboardModel, panel: PanelModel, ask: b }); return; } + dashboard.removePanel(panel); };