Loki: Fix input history (#57344)

This commit is contained in:
Ivana Huckova 2022-10-24 16:27:56 +02:00 committed by GitHub
parent 7ecbc98b3e
commit 3d7439d97d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 6 deletions

View File

@ -18,7 +18,7 @@ type Props = LokiQueryEditorProps & {
};
export const LokiAnnotationsQueryEditor = memo(function LokiAnnotationQueryEditor(props: Props) {
const { annotation, onAnnotationChange } = props;
const { annotation, onAnnotationChange, history } = props;
// this should never happen, but we want to keep typescript happy
if (annotation === undefined || onAnnotationChange === undefined) {
@ -56,7 +56,7 @@ export const LokiAnnotationsQueryEditor = memo(function LokiAnnotationQueryEdito
onChange={onChangeQuery}
onRunQuery={() => {}}
onBlur={() => {}}
history={[]}
history={history}
ExtraFieldElement={
<LokiOptionFields
lineLimitValue={queryWithRefId?.maxLines?.toString() || ''}

View File

@ -4,7 +4,7 @@ import { LokiQueryField } from './LokiQueryField';
import { LokiQueryEditorProps } from './types';
export function LokiQueryEditorForAlerting(props: LokiQueryEditorProps) {
const { query, data, datasource, onChange, onRunQuery } = props;
const { query, data, datasource, onChange, onRunQuery, history } = props;
return (
<LokiQueryField
@ -13,7 +13,7 @@ export function LokiQueryEditorForAlerting(props: LokiQueryEditorProps) {
onChange={onChange}
onRunQuery={onRunQuery}
onBlur={onRunQuery}
history={[]}
history={history}
data={data}
placeholder="Enter a Loki query"
data-testid={testIds.editor}

View File

@ -14,7 +14,17 @@ type Props = LokiQueryEditorProps & {
showExplain: boolean;
};
export function LokiQueryCodeEditor({ query, datasource, range, onRunQuery, onChange, data, app, showExplain }: Props) {
export function LokiQueryCodeEditor({
query,
datasource,
range,
onRunQuery,
onChange,
data,
app,
showExplain,
history,
}: Props) {
const styles = useStyles2(getStyles);
// the inner QueryField works like this when a blur event happens:
@ -35,7 +45,7 @@ export function LokiQueryCodeEditor({ query, datasource, range, onRunQuery, onCh
onRunQuery={onRunQuery}
onChange={onChange}
onBlur={onBlur}
history={[]}
history={history}
data={data}
app={app}
data-testid={testIds.editor}