mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: app specific query editors for Loki and Prometheus (#34365)
* 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.
This commit is contained in:
@@ -1,19 +1,14 @@
|
||||
// Libraries
|
||||
import React, { memo } from 'react';
|
||||
import React from 'react';
|
||||
|
||||
// Types
|
||||
import { QueryEditorProps } from '@grafana/data';
|
||||
import { InlineFormLabel } from '@grafana/ui';
|
||||
import { LokiDatasource } from '../datasource';
|
||||
import { LokiQuery, LokiOptions } from '../types';
|
||||
import { LokiQueryField } from './LokiQueryField';
|
||||
import { LokiOptionFields } from './LokiOptionFields';
|
||||
import { LokiQueryEditorProps } from './types';
|
||||
|
||||
type Props = QueryEditorProps<LokiDatasource, LokiQuery, LokiOptions>;
|
||||
|
||||
export function LokiQueryEditor(props: Props) {
|
||||
const { range, query, data, datasource, onChange, onRunQuery } = props;
|
||||
const absoluteTimeRange = { from: range!.from!.valueOf(), to: range!.to!.valueOf() }; // Range here is never optional
|
||||
export function LokiQueryEditor(props: LokiQueryEditorProps) {
|
||||
const { query, data, datasource, onChange, onRunQuery } = props;
|
||||
|
||||
const onLegendChange = (e: React.SyntheticEvent<HTMLInputElement>) => {
|
||||
const nextQuery = { ...query, legendFormat: e.currentTarget.value };
|
||||
@@ -51,7 +46,7 @@ export function LokiQueryEditor(props: Props) {
|
||||
onBlur={onRunQuery}
|
||||
history={[]}
|
||||
data={data}
|
||||
absoluteRange={absoluteTimeRange}
|
||||
data-testid={testIds.editor}
|
||||
ExtraFieldElement={
|
||||
<>
|
||||
<LokiOptionFields
|
||||
@@ -69,4 +64,6 @@ export function LokiQueryEditor(props: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
export default memo(LokiQueryEditor);
|
||||
export const testIds = {
|
||||
editor: 'loki-editor',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user