From 9ef29bb5c3d5926649a8cd2afb5d19c645d07567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 21 Jul 2022 20:55:24 +0200 Subject: [PATCH] TopNav: Keyboard shortcut to toggle topnav on or off (#52572) * TopNav: Keyboard shortcut to google topnav on off * gate it behind dev mode --- public/app/core/services/keybindingSrv.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/public/app/core/services/keybindingSrv.ts b/public/app/core/services/keybindingSrv.ts index a7c5d75f642..88d0e15a4ec 100644 --- a/public/app/core/services/keybindingSrv.ts +++ b/public/app/core/services/keybindingSrv.ts @@ -3,7 +3,7 @@ import Mousetrap from 'mousetrap'; import 'mousetrap-global-bind'; import 'mousetrap/plugins/global-bind/mousetrap-global-bind'; import { LegacyGraphHoverClearEvent, locationUtil } from '@grafana/data'; -import { locationService } from '@grafana/runtime'; +import { config, locationService } from '@grafana/runtime'; import appEvents from 'app/core/app_events'; import { getExploreUrl } from 'app/core/utils/explore'; import { SaveDashboardDrawer } from 'app/features/dashboard/components/SaveDashboard/SaveDashboardDrawer'; @@ -47,6 +47,10 @@ export class KeybindingSrv { this.bind('t t', () => toggleTheme(false)); this.bind('t r', () => toggleTheme(true)); + + if (process.env.NODE_ENV === 'development') { + this.bind('t n', () => this.toggleNav()); + } } globalEsc() { @@ -75,6 +79,12 @@ export class KeybindingSrv { this.exit(); } + toggleNav() { + window.location.href = locationUtil.getUrlForPartial(locationService.getLocation(), { + '__feature.topnav': (!config.featureToggles.topnav).toString(), + }); + } + private openSearch() { locationService.partial({ search: 'open' }); }