Commit a246a26a by kay delaney Committed by GitHub

Dashboards: Exit to dashboard when deleting panel from panel view / edit view (#29032)

* Dashboards: Exit to dashboard when deleting panel from panel view / edit view
Closes #11941

* Remove ability to delete panel when viewing/editing
parent 71782772
......@@ -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;
}
......
......@@ -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",
},
]
`);
});
......
......@@ -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({
......
......@@ -39,6 +39,7 @@ export const removePanel = (dashboard: DashboardModel, panel: PanelModel, ask: b
});
return;
}
dashboard.removePanel(panel);
};
......
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