TopNav: Keyboard shortcut to toggle topnav on or off (#52572)

* TopNav: Keyboard shortcut to google topnav on off

* gate it behind dev mode
pull/52627/head
Torkel Ödegaard 3 years ago committed by GitHub
parent 1974f166e0
commit 9ef29bb5c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      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' });
}

Loading…
Cancel
Save