Alerting: Move query components to unified folder (#34587)
This commit is contained in:
+10
-7
@@ -11,13 +11,16 @@ import {
|
|||||||
import { selectors } from '@grafana/e2e-selectors';
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
import { Button, HorizontalGroup, Icon, stylesFactory, Tooltip } from '@grafana/ui';
|
import { Button, HorizontalGroup, Icon, stylesFactory, Tooltip } from '@grafana/ui';
|
||||||
import { config } from '@grafana/runtime';
|
import { config } from '@grafana/runtime';
|
||||||
import { AlertingQueryRows } from './AlertingQueryRows';
|
import { QueryRows } from './QueryRows';
|
||||||
import { dataSource as expressionDatasource, ExpressionDatasourceUID } from '../../expressions/ExpressionDatasource';
|
import {
|
||||||
|
dataSource as expressionDatasource,
|
||||||
|
ExpressionDatasourceUID,
|
||||||
|
} from 'app/features/expressions/ExpressionDatasource';
|
||||||
import { getNextRefIdChar } from 'app/core/utils/query';
|
import { getNextRefIdChar } from 'app/core/utils/query';
|
||||||
import { defaultCondition } from '../../expressions/utils/expressionTypes';
|
import { defaultCondition } from 'app/features/expressions/utils/expressionTypes';
|
||||||
import { ExpressionQueryType } from '../../expressions/types';
|
import { ExpressionQueryType } from 'app/features/expressions/types';
|
||||||
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
||||||
import { AlertingQueryRunner } from '../state/AlertingQueryRunner';
|
import { AlertingQueryRunner } from '../../state/AlertingQueryRunner';
|
||||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||||
import { isExpressionQuery } from 'app/features/expressions/guards';
|
import { isExpressionQuery } from 'app/features/expressions/guards';
|
||||||
|
|
||||||
@@ -29,7 +32,7 @@ interface Props {
|
|||||||
interface State {
|
interface State {
|
||||||
panelDataByRefId: Record<string, PanelData>;
|
panelDataByRefId: Record<string, PanelData>;
|
||||||
}
|
}
|
||||||
export class AlertingQueryEditor extends PureComponent<Props, State> {
|
export class QueryEditor extends PureComponent<Props, State> {
|
||||||
private runner: AlertingQueryRunner;
|
private runner: AlertingQueryRunner;
|
||||||
|
|
||||||
constructor(props: Props) {
|
constructor(props: Props) {
|
||||||
@@ -160,7 +163,7 @@ export class AlertingQueryEditor extends PureComponent<Props, State> {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<AlertingQueryRows
|
<QueryRows
|
||||||
data={panelDataByRefId}
|
data={panelDataByRefId}
|
||||||
queries={value}
|
queries={value}
|
||||||
onQueriesChange={this.props.onChange}
|
onQueriesChange={this.props.onChange}
|
||||||
+3
-3
@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
|
|||||||
import { DragDropContext, Droppable, DropResult } from 'react-beautiful-dnd';
|
import { DragDropContext, Droppable, DropResult } from 'react-beautiful-dnd';
|
||||||
import { DataQuery, DataSourceInstanceSettings, PanelData, RelativeTimeRange } from '@grafana/data';
|
import { DataQuery, DataSourceInstanceSettings, PanelData, RelativeTimeRange } from '@grafana/data';
|
||||||
import { getDataSourceSrv } from '@grafana/runtime';
|
import { getDataSourceSrv } from '@grafana/runtime';
|
||||||
import { AlertingQueryWrapper } from './AlertingQueryWrapper';
|
import { QueryWrapper } from './QueryWrapper';
|
||||||
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -20,7 +20,7 @@ interface State {
|
|||||||
dataPerQuery: Record<string, PanelData>;
|
dataPerQuery: Record<string, PanelData>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class AlertingQueryRows extends PureComponent<Props, State> {
|
export class QueryRows extends PureComponent<Props, State> {
|
||||||
constructor(props: Props) {
|
constructor(props: Props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ export class AlertingQueryRows extends PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AlertingQueryWrapper
|
<QueryWrapper
|
||||||
index={index}
|
index={index}
|
||||||
key={`${query.refId}-${index}`}
|
key={`${query.refId}-${index}`}
|
||||||
dsSettings={dsSettings}
|
dsSettings={dsSettings}
|
||||||
@@ -4,7 +4,7 @@ import { Field, InputControl } from '@grafana/ui';
|
|||||||
import { ExpressionEditor } from './ExpressionEditor';
|
import { ExpressionEditor } from './ExpressionEditor';
|
||||||
import { RuleEditorSection } from './RuleEditorSection';
|
import { RuleEditorSection } from './RuleEditorSection';
|
||||||
import { RuleFormType, RuleFormValues } from '../../types/rule-form';
|
import { RuleFormType, RuleFormValues } from '../../types/rule-form';
|
||||||
import { AlertingQueryEditor } from '../../../components/AlertingQueryEditor';
|
import { QueryEditor } from './QueryEditor';
|
||||||
|
|
||||||
export const QueryStep: FC = () => {
|
export const QueryStep: FC = () => {
|
||||||
const {
|
const {
|
||||||
@@ -35,7 +35,7 @@ export const QueryStep: FC = () => {
|
|||||||
>
|
>
|
||||||
<InputControl
|
<InputControl
|
||||||
name="queries"
|
name="queries"
|
||||||
render={({ field: { ref, ...field } }) => <AlertingQueryEditor {...field} />}
|
render={({ field: { ref, ...field } }) => <QueryEditor {...field} />}
|
||||||
control={control}
|
control={control}
|
||||||
rules={{
|
rules={{
|
||||||
validate: (queries) => Array.isArray(queries) && !!queries.length,
|
validate: (queries) => Array.isArray(queries) && !!queries.length,
|
||||||
|
|||||||
+4
-4
@@ -9,9 +9,9 @@ import {
|
|||||||
getDefaultRelativeTimeRange,
|
getDefaultRelativeTimeRange,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { useStyles2, RelativeTimeRangePicker } from '@grafana/ui';
|
import { useStyles2, RelativeTimeRangePicker } from '@grafana/ui';
|
||||||
import { QueryEditorRow } from '../../query/components/QueryEditorRow';
|
import { QueryEditorRow } from '../../../../query/components/QueryEditorRow';
|
||||||
import { VizWrapper } from '../unified/components/rule-editor/VizWrapper';
|
import { VizWrapper } from './VizWrapper';
|
||||||
import { isExpressionQuery } from '../../expressions/guards';
|
import { isExpressionQuery } from '../../../../expressions/guards';
|
||||||
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
||||||
import { cloneDeep } from 'lodash';
|
import { cloneDeep } from 'lodash';
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ interface Props {
|
|||||||
index: number;
|
index: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AlertingQueryWrapper: FC<Props> = ({
|
export const QueryWrapper: FC<Props> = ({
|
||||||
data,
|
data,
|
||||||
dsSettings,
|
dsSettings,
|
||||||
index,
|
index,
|
||||||
+1
-1
@@ -14,7 +14,7 @@ import { FetchResponse, toDataQueryError } from '@grafana/runtime';
|
|||||||
import { BackendSrv, getBackendSrv } from 'app/core/services/backend_srv';
|
import { BackendSrv, getBackendSrv } from 'app/core/services/backend_srv';
|
||||||
import { preProcessPanelData } from 'app/features/query/state/runRequest';
|
import { preProcessPanelData } from 'app/features/query/state/runRequest';
|
||||||
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
||||||
import { getTimeRangeForExpression } from '../unified/utils/timeRange';
|
import { getTimeRangeForExpression } from '../utils/timeRange';
|
||||||
import { isExpressionQuery } from 'app/features/expressions/guards';
|
import { isExpressionQuery } from 'app/features/expressions/guards';
|
||||||
import { setStructureRevision } from 'app/features/query/state/processing/revision';
|
import { setStructureRevision } from 'app/features/query/state/processing/revision';
|
||||||
import { cancelNetworkRequestsOnUnsubscribe } from 'app/features/query/state/processing/canceler';
|
import { cancelNetworkRequestsOnUnsubscribe } from 'app/features/query/state/processing/canceler';
|
||||||
Reference in New Issue
Block a user