Dashboard scenes: Remove panel menu options that are dashboard editing activities when not in edit mode. (#84156)

* remove panel menu options that are dasbhoard editing activities when the dashboard is not in edit mode

* remove corresponding keybindings when not in edit mode

* add keyboard shortcuts but inactivate them when not in edit mode

* Add tests; fix tests
This commit is contained in:
Oscar Kilhed
2024-03-11 11:33:33 +01:00
committed by GitHub
parent e8ecbaffc2
commit 87d6bebb9e
3 changed files with 103 additions and 56 deletions

View File

@@ -120,7 +120,9 @@ export function setupKeyboardShortcuts(scene: DashboardScene) {
keybindings.addBinding({
key: 'p r',
onTrigger: withFocusedPanel(scene, (vizPanel: VizPanel) => {
onRemovePanel(scene, vizPanel);
if (scene.state.isEditing) {
onRemovePanel(scene, vizPanel);
}
}),
});
@@ -128,7 +130,9 @@ export function setupKeyboardShortcuts(scene: DashboardScene) {
keybindings.addBinding({
key: 'p d',
onTrigger: withFocusedPanel(scene, (vizPanel: VizPanel) => {
scene.duplicatePanel(vizPanel);
if (scene.state.isEditing) {
scene.duplicatePanel(vizPanel);
}
}),
});