mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
* Prometheus: Run query explicitly instead of onblur in panel edit, and highlight Run qqueries when query changed * Update loki to do the same * Cleanup unused prop * Remove test
28 lines
802 B
TypeScript
28 lines
802 B
TypeScript
import React, { useRef } from 'react';
|
|
|
|
import { MonacoQueryFieldLazy } from './MonacoQueryFieldLazy';
|
|
import { Props as MonacoProps } from './MonacoQueryFieldProps';
|
|
|
|
export type Props = Omit<MonacoProps, 'onRunQuery' | 'onBlur'> & {
|
|
onChange: (query: string) => void;
|
|
onRunQuery: () => void;
|
|
onQueryType?: (query: string) => void;
|
|
};
|
|
|
|
export const MonacoQueryFieldWrapper = (props: Props) => {
|
|
const lastRunValueRef = useRef<string | null>(null);
|
|
const { onRunQuery, onChange, ...rest } = props;
|
|
|
|
const handleRunQuery = (value: string) => {
|
|
lastRunValueRef.current = value;
|
|
onChange(value);
|
|
onRunQuery();
|
|
};
|
|
|
|
const handleBlur = (value: string) => {
|
|
onChange(value);
|
|
};
|
|
|
|
return <MonacoQueryFieldLazy onRunQuery={handleRunQuery} onBlur={handleBlur} {...rest} />;
|
|
};
|