prometheus: monaco: handle in-dashboard and in-explore use cases (#40922)

* prometheus: monaco: handle in-dashboard and in-explore use cases

* refactor is-explore handling

* improved comment

* removed unnecessary comment

* reordered props

* simplify code

* refactor: better prop-name

* fixed test snapshot
This commit is contained in:
Gábor Farkas
2021-10-27 11:45:32 +02:00
committed by GitHub
parent a127e106db
commit 844d2c8621
6 changed files with 47 additions and 12 deletions

View File

@@ -19,10 +19,10 @@ import { LanguageMap, languages as prismLanguages } from 'prismjs';
import { PromQuery, PromOptions } from '../types';
import { roundMsToMin } from '../language_utils';
import { CancelablePromise, makePromiseCancelable } from 'app/core/utils/CancelablePromise';
import { QueryEditorProps, QueryHint, isDataFrame, toLegacyResponseData, TimeRange } from '@grafana/data';
import { QueryEditorProps, QueryHint, isDataFrame, toLegacyResponseData, TimeRange, CoreApp } from '@grafana/data';
import { PrometheusDatasource } from '../datasource';
import { PrometheusMetricsBrowser } from './PrometheusMetricsBrowser';
import { MonacoQueryFieldLazy } from './monaco-query-field/MonacoQueryFieldLazy';
import { MonacoQueryFieldWrapper } from './monaco-query-field/MonacoQueryFieldWrapper';
import { LocalStorageValueProvider } from 'app/core/components/LocalStorageValueProvider';
export const RECORDING_RULES_GROUP = '__recording_rules__';
@@ -298,7 +298,8 @@ class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryF
<div className="gf-form gf-form--grow flex-shrink-1 min-width-15">
{isMonacoEditorEnabled ? (
<MonacoQueryFieldLazy
<MonacoQueryFieldWrapper
runQueryOnBlur={this.props.app !== CoreApp.Explore}
languageProvider={languageProvider}
history={history}
onChange={this.onChangeQuery}