From dcef87fd792764833aa8b8c8d3d1264de98d1f4e Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Tue, 25 May 2021 11:34:19 +0200 Subject: [PATCH] Alerting: Move query components to unified folder (#34587) --- .../components/rule-editor/QueryEditor.tsx} | 17 ++++++++++------- .../components/rule-editor/QueryRows.tsx} | 6 +++--- .../components/rule-editor/QueryStep.tsx | 4 ++-- .../components/rule-editor/QueryWrapper.tsx} | 8 ++++---- .../state/AlertingQueryRunner.test.ts | 0 .../{ => unified}/state/AlertingQueryRunner.ts | 2 +- 6 files changed, 20 insertions(+), 17 deletions(-) rename public/app/features/alerting/{components/AlertingQueryEditor.tsx => unified/components/rule-editor/QueryEditor.tsx} (91%) rename public/app/features/alerting/{components/AlertingQueryRows.tsx => unified/components/rule-editor/QueryRows.tsx} (96%) rename public/app/features/alerting/{components/AlertingQueryWrapper.tsx => unified/components/rule-editor/QueryWrapper.tsx} (90%) rename public/app/features/alerting/{ => unified}/state/AlertingQueryRunner.test.ts (100%) rename public/app/features/alerting/{ => unified}/state/AlertingQueryRunner.ts (98%) diff --git a/public/app/features/alerting/components/AlertingQueryEditor.tsx b/public/app/features/alerting/unified/components/rule-editor/QueryEditor.tsx similarity index 91% rename from public/app/features/alerting/components/AlertingQueryEditor.tsx rename to public/app/features/alerting/unified/components/rule-editor/QueryEditor.tsx index 15d4fcaa343..bd480ca8f74 100644 --- a/public/app/features/alerting/components/AlertingQueryEditor.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/QueryEditor.tsx @@ -11,13 +11,16 @@ import { import { selectors } from '@grafana/e2e-selectors'; import { Button, HorizontalGroup, Icon, stylesFactory, Tooltip } from '@grafana/ui'; import { config } from '@grafana/runtime'; -import { AlertingQueryRows } from './AlertingQueryRows'; -import { dataSource as expressionDatasource, ExpressionDatasourceUID } from '../../expressions/ExpressionDatasource'; +import { QueryRows } from './QueryRows'; +import { + dataSource as expressionDatasource, + ExpressionDatasourceUID, +} from 'app/features/expressions/ExpressionDatasource'; import { getNextRefIdChar } from 'app/core/utils/query'; -import { defaultCondition } from '../../expressions/utils/expressionTypes'; -import { ExpressionQueryType } from '../../expressions/types'; +import { defaultCondition } from 'app/features/expressions/utils/expressionTypes'; +import { ExpressionQueryType } from 'app/features/expressions/types'; 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 { isExpressionQuery } from 'app/features/expressions/guards'; @@ -29,7 +32,7 @@ interface Props { interface State { panelDataByRefId: Record; } -export class AlertingQueryEditor extends PureComponent { +export class QueryEditor extends PureComponent { private runner: AlertingQueryRunner; constructor(props: Props) { @@ -160,7 +163,7 @@ export class AlertingQueryEditor extends PureComponent { return (
- ; } -export class AlertingQueryRows extends PureComponent { +export class QueryRows extends PureComponent { constructor(props: Props) { super(props); @@ -148,7 +148,7 @@ export class AlertingQueryRows extends PureComponent { } return ( - { const { @@ -35,7 +35,7 @@ export const QueryStep: FC = () => { > } + render={({ field: { ref, ...field } }) => } control={control} rules={{ validate: (queries) => Array.isArray(queries) && !!queries.length, diff --git a/public/app/features/alerting/components/AlertingQueryWrapper.tsx b/public/app/features/alerting/unified/components/rule-editor/QueryWrapper.tsx similarity index 90% rename from public/app/features/alerting/components/AlertingQueryWrapper.tsx rename to public/app/features/alerting/unified/components/rule-editor/QueryWrapper.tsx index 9add49978b6..f8f4a22048b 100644 --- a/public/app/features/alerting/components/AlertingQueryWrapper.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/QueryWrapper.tsx @@ -9,9 +9,9 @@ import { getDefaultRelativeTimeRange, } from '@grafana/data'; import { useStyles2, RelativeTimeRangePicker } from '@grafana/ui'; -import { QueryEditorRow } from '../../query/components/QueryEditorRow'; -import { VizWrapper } from '../unified/components/rule-editor/VizWrapper'; -import { isExpressionQuery } from '../../expressions/guards'; +import { QueryEditorRow } from '../../../../query/components/QueryEditorRow'; +import { VizWrapper } from './VizWrapper'; +import { isExpressionQuery } from '../../../../expressions/guards'; import { GrafanaQuery } from 'app/types/unified-alerting-dto'; import { cloneDeep } from 'lodash'; @@ -29,7 +29,7 @@ interface Props { index: number; } -export const AlertingQueryWrapper: FC = ({ +export const QueryWrapper: FC = ({ data, dsSettings, index, diff --git a/public/app/features/alerting/state/AlertingQueryRunner.test.ts b/public/app/features/alerting/unified/state/AlertingQueryRunner.test.ts similarity index 100% rename from public/app/features/alerting/state/AlertingQueryRunner.test.ts rename to public/app/features/alerting/unified/state/AlertingQueryRunner.test.ts diff --git a/public/app/features/alerting/state/AlertingQueryRunner.ts b/public/app/features/alerting/unified/state/AlertingQueryRunner.ts similarity index 98% rename from public/app/features/alerting/state/AlertingQueryRunner.ts rename to public/app/features/alerting/unified/state/AlertingQueryRunner.ts index 145fec28736..c69bffd41b0 100644 --- a/public/app/features/alerting/state/AlertingQueryRunner.ts +++ b/public/app/features/alerting/unified/state/AlertingQueryRunner.ts @@ -14,7 +14,7 @@ import { FetchResponse, toDataQueryError } from '@grafana/runtime'; import { BackendSrv, getBackendSrv } from 'app/core/services/backend_srv'; import { preProcessPanelData } from 'app/features/query/state/runRequest'; 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 { setStructureRevision } from 'app/features/query/state/processing/revision'; import { cancelNetworkRequestsOnUnsubscribe } from 'app/features/query/state/processing/canceler';