mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: rename type to make it obvious what part of the code base it belongs to. (#34714)
* renamed grafana query to grafana alert query. * renamed according to feedback in PR.
This commit is contained in:
@@ -19,14 +19,14 @@ import {
|
||||
import { getNextRefIdChar } from 'app/core/utils/query';
|
||||
import { defaultCondition } from 'app/features/expressions/utils/expressionTypes';
|
||||
import { ExpressionQueryType } from 'app/features/expressions/types';
|
||||
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
||||
import { AlertQuery } from 'app/types/unified-alerting-dto';
|
||||
import { AlertingQueryRunner } from '../../state/AlertingQueryRunner';
|
||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||
import { isExpressionQuery } from 'app/features/expressions/guards';
|
||||
|
||||
interface Props {
|
||||
value?: GrafanaQuery[];
|
||||
onChange: (queries: GrafanaQuery[]) => void;
|
||||
value?: AlertQuery[];
|
||||
onChange: (queries: AlertQuery[]) => void;
|
||||
}
|
||||
|
||||
interface State {
|
||||
@@ -34,7 +34,7 @@ interface State {
|
||||
}
|
||||
export class QueryEditor extends PureComponent<Props, State> {
|
||||
private runner: AlertingQueryRunner;
|
||||
private queries: GrafanaQuery[];
|
||||
private queries: AlertQuery[];
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
@@ -62,12 +62,12 @@ export class QueryEditor extends PureComponent<Props, State> {
|
||||
this.runner.cancel();
|
||||
};
|
||||
|
||||
onChangeQueries = (queries: GrafanaQuery[]) => {
|
||||
onChangeQueries = (queries: AlertQuery[]) => {
|
||||
this.queries = queries;
|
||||
this.props.onChange(queries);
|
||||
};
|
||||
|
||||
onDuplicateQuery = (query: GrafanaQuery) => {
|
||||
onDuplicateQuery = (query: AlertQuery) => {
|
||||
const { queries } = this;
|
||||
this.onChangeQueries(addQuery(queries, query));
|
||||
};
|
||||
@@ -184,13 +184,10 @@ export class QueryEditor extends PureComponent<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
const addQuery = (
|
||||
queries: GrafanaQuery[],
|
||||
queryToAdd: Pick<GrafanaQuery, 'model' | 'datasourceUid'>
|
||||
): GrafanaQuery[] => {
|
||||
const addQuery = (queries: AlertQuery[], queryToAdd: Pick<AlertQuery, 'model' | 'datasourceUid'>): AlertQuery[] => {
|
||||
const refId = getNextRefIdChar(queries);
|
||||
|
||||
const query: GrafanaQuery = {
|
||||
const query: AlertQuery = {
|
||||
...queryToAdd,
|
||||
refId,
|
||||
queryType: '',
|
||||
|
||||
@@ -3,16 +3,16 @@ import { DragDropContext, Droppable, DropResult } from 'react-beautiful-dnd';
|
||||
import { DataQuery, DataSourceInstanceSettings, PanelData, RelativeTimeRange } from '@grafana/data';
|
||||
import { getDataSourceSrv } from '@grafana/runtime';
|
||||
import { QueryWrapper } from './QueryWrapper';
|
||||
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
||||
import { AlertQuery } from 'app/types/unified-alerting-dto';
|
||||
|
||||
interface Props {
|
||||
// The query configuration
|
||||
queries: GrafanaQuery[];
|
||||
queries: AlertQuery[];
|
||||
data: Record<string, PanelData>;
|
||||
|
||||
// Query editing
|
||||
onQueriesChange: (queries: GrafanaQuery[]) => void;
|
||||
onDuplicateQuery: (query: GrafanaQuery) => void;
|
||||
onQueriesChange: (queries: AlertQuery[]) => void;
|
||||
onDuplicateQuery: (query: AlertQuery) => void;
|
||||
onRunQueries: () => void;
|
||||
}
|
||||
|
||||
@@ -119,14 +119,14 @@ export class QueryRows extends PureComponent<Props, State> {
|
||||
onQueriesChange(update);
|
||||
};
|
||||
|
||||
onDuplicateQuery = (query: DataQuery, source: GrafanaQuery): void => {
|
||||
onDuplicateQuery = (query: DataQuery, source: AlertQuery): void => {
|
||||
this.props.onDuplicateQuery({
|
||||
...source,
|
||||
model: query,
|
||||
});
|
||||
};
|
||||
|
||||
getDataSourceSettings = (query: GrafanaQuery): DataSourceInstanceSettings | undefined => {
|
||||
getDataSourceSettings = (query: AlertQuery): DataSourceInstanceSettings | undefined => {
|
||||
return getDataSourceSrv().getInstanceSettings(query.datasourceUid);
|
||||
};
|
||||
|
||||
|
||||
@@ -14,18 +14,18 @@ import { QueryEditorRow } from 'app/features/query/components/QueryEditorRow';
|
||||
import { VizWrapper } from './VizWrapper';
|
||||
import { isExpressionQuery } from 'app/features/expressions/guards';
|
||||
import { TABLE, TIMESERIES } from '../../utils/constants';
|
||||
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
||||
import { AlertQuery } from 'app/types/unified-alerting-dto';
|
||||
|
||||
interface Props {
|
||||
data: PanelData;
|
||||
query: GrafanaQuery;
|
||||
queries: GrafanaQuery[];
|
||||
query: AlertQuery;
|
||||
queries: AlertQuery[];
|
||||
dsSettings: DataSourceInstanceSettings;
|
||||
onChangeDataSource: (settings: DataSourceInstanceSettings, index: number) => void;
|
||||
onChangeQuery: (query: DataQuery, index: number) => void;
|
||||
onChangeTimeRange?: (timeRange: RelativeTimeRange, index: number) => void;
|
||||
onRemoveQuery: (query: DataQuery) => void;
|
||||
onDuplicateQuery: (query: GrafanaQuery) => void;
|
||||
onDuplicateQuery: (query: AlertQuery) => void;
|
||||
onRunQueries: () => void;
|
||||
index: number;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ export const QueryWrapper: FC<Props> = ({
|
||||
const isExpression = isExpressionQuery(query.model);
|
||||
const [pluginId, changePluginId] = useState<SupportedPanelPlugins>(isExpression ? TABLE : TIMESERIES);
|
||||
|
||||
const renderTimePicker = (query: GrafanaQuery, index: number): ReactNode => {
|
||||
const renderTimePicker = (query: AlertQuery, index: number): ReactNode => {
|
||||
if (isExpressionQuery(query.model) || !onChangeTimeRange) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user