mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
azuremonitor: don't go back to dashboard if escape pressed in the editor
This commit is contained in:
parent
0c3657da7e
commit
df9ecc6816
@ -139,6 +139,10 @@ export class KeybindingSrv {
|
||||
);
|
||||
}
|
||||
|
||||
unbind(keyArg: string, keyType?: string) {
|
||||
Mousetrap.unbind(keyArg, keyType);
|
||||
}
|
||||
|
||||
showDashEditView() {
|
||||
const search = _.extend(this.$location.search(), { editview: 'settings' });
|
||||
this.$location.search(search);
|
||||
@ -293,3 +297,17 @@ export class KeybindingSrv {
|
||||
}
|
||||
|
||||
coreModule.service('keybindingSrv', KeybindingSrv);
|
||||
|
||||
/**
|
||||
* Code below exports the service to react components
|
||||
*/
|
||||
|
||||
let singletonInstance: KeybindingSrv;
|
||||
|
||||
export function setKeybindingSrv(instance: KeybindingSrv) {
|
||||
singletonInstance = instance;
|
||||
}
|
||||
|
||||
export function getKeybindingSrv(): KeybindingSrv {
|
||||
return singletonInstance;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ export default class KustoQueryField extends QueryField {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.updateMenu();
|
||||
super.componentDidMount();
|
||||
this.fetchSchema();
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import NewlinePlugin from './slate-plugins/newline';
|
||||
import RunnerPlugin from './slate-plugins/runner';
|
||||
|
||||
import Typeahead from './typeahead';
|
||||
import { getKeybindingSrv, KeybindingSrv } from 'app/core/services/keybindingSrv';
|
||||
|
||||
import { Block, Document, Text, Value } from 'slate';
|
||||
import { Editor } from 'slate-react';
|
||||
@ -61,6 +62,7 @@ class QueryField extends React.Component<any, any> {
|
||||
menuEl: any;
|
||||
plugins: any;
|
||||
resetTimer: any;
|
||||
keybindingSrv: KeybindingSrv = getKeybindingSrv();
|
||||
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
@ -90,6 +92,7 @@ class QueryField extends React.Component<any, any> {
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.restoreEscapeKeyBinding();
|
||||
clearTimeout(this.resetTimer);
|
||||
}
|
||||
|
||||
@ -218,6 +221,7 @@ class QueryField extends React.Component<any, any> {
|
||||
if (onBlur) {
|
||||
onBlur();
|
||||
}
|
||||
this.restoreEscapeKeyBinding();
|
||||
};
|
||||
|
||||
handleFocus = () => {
|
||||
@ -225,8 +229,18 @@ class QueryField extends React.Component<any, any> {
|
||||
if (onFocus) {
|
||||
onFocus();
|
||||
}
|
||||
// Don't go back to dashboard if Escape pressed inside the editor.
|
||||
this.removeEscapeKeyBinding();
|
||||
};
|
||||
|
||||
removeEscapeKeyBinding() {
|
||||
this.keybindingSrv.unbind('esc', 'keydown');
|
||||
}
|
||||
|
||||
restoreEscapeKeyBinding() {
|
||||
this.keybindingSrv.setupGlobal();
|
||||
}
|
||||
|
||||
onClickItem = item => {
|
||||
const { suggestions } = this.state;
|
||||
if (!suggestions || suggestions.length === 0) {
|
||||
|
@ -10,6 +10,7 @@ import appEvents from 'app/core/app_events';
|
||||
import { BackendSrv, setBackendSrv } from 'app/core/services/backend_srv';
|
||||
import { TimeSrv, setTimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||
import { DatasourceSrv, setDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||
import { KeybindingSrv, setKeybindingSrv } from 'app/core/services/keybindingSrv';
|
||||
import { AngularLoader, setAngularLoader } from 'app/core/services/AngularLoader';
|
||||
import { configureStore } from 'app/store/configureStore';
|
||||
|
||||
@ -25,6 +26,7 @@ export class GrafanaCtrl {
|
||||
backendSrv: BackendSrv,
|
||||
timeSrv: TimeSrv,
|
||||
datasourceSrv: DatasourceSrv,
|
||||
keybindingSrv: KeybindingSrv,
|
||||
angularLoader: AngularLoader
|
||||
) {
|
||||
// make angular loader service available to react components
|
||||
@ -32,6 +34,7 @@ export class GrafanaCtrl {
|
||||
setBackendSrv(backendSrv);
|
||||
setDatasourceSrv(datasourceSrv);
|
||||
setTimeSrv(timeSrv);
|
||||
setKeybindingSrv(keybindingSrv);
|
||||
configureStore();
|
||||
|
||||
$scope.init = () => {
|
||||
|
Loading…
Reference in New Issue
Block a user