mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
Add list of bindings for updating on change
This commit is contained in:
parent
92936d3a72
commit
092707371d
@ -29,9 +29,11 @@ import { withFocusedPanel } from './withFocusedPanelId';
|
||||
|
||||
export class KeybindingSrv {
|
||||
constructor(private locationService: LocationService, private chromeService: AppChromeService) {}
|
||||
bindings: string[] = [];
|
||||
|
||||
clearAndInitGlobalBindings() {
|
||||
Mousetrap.reset();
|
||||
this.bindings = [];
|
||||
|
||||
if (this.locationService.getLocation().pathname !== '/login') {
|
||||
this.bind(['?', 'h'], this.showHelpModal);
|
||||
@ -164,6 +166,9 @@ export class KeybindingSrv {
|
||||
}
|
||||
|
||||
bind(keyArg: string | string[], fn: () => void) {
|
||||
const keyArgArr = Array.isArray(keyArg) ? keyArg : [keyArg];
|
||||
this.bindings.push(...keyArgArr);
|
||||
|
||||
Mousetrap.bind(
|
||||
keyArg,
|
||||
(evt) => {
|
||||
@ -177,6 +182,8 @@ export class KeybindingSrv {
|
||||
}
|
||||
|
||||
bindGlobal(keyArg: string, fn: () => void) {
|
||||
this.bindings.push(keyArg);
|
||||
|
||||
Mousetrap.bindGlobal(
|
||||
keyArg,
|
||||
(evt) => {
|
||||
@ -190,6 +197,7 @@ export class KeybindingSrv {
|
||||
}
|
||||
|
||||
unbind(keyArg: string, keyType?: string) {
|
||||
this.bindings = this.bindings.filter((binding) => binding !== keyArg);
|
||||
Mousetrap.unbind(keyArg, keyType);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ export function ExplorePage(props: GrafanaRouteComponentProps<{}, ExploreQueryPa
|
||||
|
||||
useEffect(() => {
|
||||
keybindings.setupTimeRangeBindings(false);
|
||||
}, [keybindings]);
|
||||
}, [keybindings, keybindings.bindings]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!config.featureToggles.correlations) {
|
||||
|
Loading…
Reference in New Issue
Block a user