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
This commit is contained in:
kay delaney 2021-01-18 13:34:45 +00:00 committed by GitHub
parent 717827725f
commit a246a26a2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 12 deletions

View File

@ -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;
}

View File

@ -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",
},
]
`);
});

View File

@ -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({

View File

@ -39,6 +39,7 @@ export const removePanel = (dashboard: DashboardModel, panel: PanelModel, ask: b
});
return;
}
dashboard.removePanel(panel);
};