mirror of
https://github.com/grafana/grafana.git
synced 2025-09-26 17:14:15 +08:00

* Adding simplified version of query editor based on app flag. * cleaned up the absolute time range. * changing placeholder text. * updated snapshot. * added some tests. * adding loki query editor tests. * updating snapshots.
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
// Libraries
|
|
import React, { memo } from 'react';
|
|
// Types
|
|
import { LokiQuery } from '../types';
|
|
import { LokiQueryField } from './LokiQueryField';
|
|
import { LokiOptionFields } from './LokiOptionFields';
|
|
import LokiDatasource from '../datasource';
|
|
|
|
interface Props {
|
|
expr: string;
|
|
maxLines?: number;
|
|
instant?: boolean;
|
|
datasource: LokiDatasource;
|
|
onChange: (query: LokiQuery) => void;
|
|
}
|
|
|
|
export const LokiAnnotationsQueryEditor = memo(function LokiAnnotationQueryEditor(props: Props) {
|
|
const { expr, maxLines, instant, datasource, onChange } = props;
|
|
|
|
const queryWithRefId: LokiQuery = {
|
|
refId: '',
|
|
expr,
|
|
maxLines,
|
|
instant,
|
|
};
|
|
return (
|
|
<div className="gf-form-group">
|
|
<LokiQueryField
|
|
datasource={datasource}
|
|
query={queryWithRefId}
|
|
onChange={onChange}
|
|
onRunQuery={() => {}}
|
|
onBlur={() => {}}
|
|
history={[]}
|
|
ExtraFieldElement={
|
|
<LokiOptionFields
|
|
queryType={queryWithRefId.instant ? 'instant' : 'range'}
|
|
lineLimitValue={queryWithRefId?.maxLines?.toString() || ''}
|
|
query={queryWithRefId}
|
|
onRunQuery={() => {}}
|
|
onChange={onChange}
|
|
/>
|
|
}
|
|
/>
|
|
</div>
|
|
);
|
|
});
|