From 2c1bc1bb7c8b860687faa87c30f85a6b0b0619c9 Mon Sep 17 00:00:00 2001 From: Tom Ratcliffe Date: Thu, 13 Mar 2025 12:48:06 +0000 Subject: [PATCH] Alerting: Fix DataQuery and DataSourceRef deprecated imports in alerting code (#102095) Fix DataQuery and DataSourceRef deprecated imports in alerting code --- .../app/features/alerting/unified/GrafanaRuleQueryViewer.tsx | 3 ++- .../unified/components/rule-editor/ExpressionEditor.tsx | 3 ++- .../alerting/unified/components/rule-editor/QueryRows.tsx | 2 +- .../rule-editor/query-and-alert-condition/reducer.ts | 2 +- .../central-state-history/CentralHistoryRuntimeDataSource.ts | 3 ++- public/app/features/alerting/unified/utils/rule-form.ts | 4 +--- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/public/app/features/alerting/unified/GrafanaRuleQueryViewer.tsx b/public/app/features/alerting/unified/GrafanaRuleQueryViewer.tsx index 10126744321..b591ece380d 100644 --- a/public/app/features/alerting/unified/GrafanaRuleQueryViewer.tsx +++ b/public/app/features/alerting/unified/GrafanaRuleQueryViewer.tsx @@ -2,9 +2,10 @@ import { css, cx } from '@emotion/css'; import { keyBy, startCase, uniqueId } from 'lodash'; import * as React from 'react'; -import { DataSourceInstanceSettings, DataSourceRef, GrafanaTheme2, PanelData, urlUtil } from '@grafana/data'; +import { DataSourceInstanceSettings, GrafanaTheme2, PanelData, urlUtil } from '@grafana/data'; import { secondsToHms } from '@grafana/data/src/datetime/rangeutil'; import { config } from '@grafana/runtime'; +import { DataSourceRef } from '@grafana/schema'; import { Preview } from '@grafana/sql/src/components/visual-query-builder/Preview'; import { Alert, Badge, ErrorBoundaryAlert, LinkButton, Stack, Text, useStyles2 } from '@grafana/ui'; import { CombinedRule } from 'app/types/unified-alerting'; diff --git a/public/app/features/alerting/unified/components/rule-editor/ExpressionEditor.tsx b/public/app/features/alerting/unified/components/rule-editor/ExpressionEditor.tsx index 66d191dce5a..ab7f1f5f36c 100644 --- a/public/app/features/alerting/unified/components/rule-editor/ExpressionEditor.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/ExpressionEditor.tsx @@ -3,9 +3,10 @@ import { noop } from 'lodash'; import { useCallback, useMemo } from 'react'; import { useAsync } from 'react-use'; -import { CoreApp, DataQuery, DataSourcePluginContextProvider, GrafanaTheme2, LoadingState } from '@grafana/data'; +import { CoreApp, DataSourcePluginContextProvider, GrafanaTheme2, LoadingState } from '@grafana/data'; import { PromQuery } from '@grafana/prometheus'; import { getDataSourceSrv } from '@grafana/runtime'; +import { DataQuery } from '@grafana/schema'; import { Alert, Button, useStyles2 } from '@grafana/ui'; import { LokiQuery } from 'app/plugins/datasource/loki/types'; diff --git a/public/app/features/alerting/unified/components/rule-editor/QueryRows.tsx b/public/app/features/alerting/unified/components/rule-editor/QueryRows.tsx index 92f8bb020d5..08c67ebf3d2 100644 --- a/public/app/features/alerting/unified/components/rule-editor/QueryRows.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/QueryRows.tsx @@ -3,7 +3,6 @@ import { omit } from 'lodash'; import { PureComponent, useState } from 'react'; import { - DataQuery, DataSourceInstanceSettings, LoadingState, PanelData, @@ -12,6 +11,7 @@ import { rangeUtil, } from '@grafana/data'; import { getDataSourceSrv } from '@grafana/runtime'; +import { DataQuery } from '@grafana/schema'; import { Button, Card, Icon, Stack } from '@grafana/ui'; import { QueryOperationRow } from 'app/core/components/QueryOperationRow/QueryOperationRow'; import { getDatasourceSrv } from 'app/features/plugins/datasource_srv'; diff --git a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/reducer.ts b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/reducer.ts index e54506ebcc6..aab9e184a56 100644 --- a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/reducer.ts +++ b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/reducer.ts @@ -1,7 +1,6 @@ import { createAction, createReducer, original } from '@reduxjs/toolkit'; import { - DataQuery, ReducerID, RelativeTimeRange, getDataSourceRef, @@ -10,6 +9,7 @@ import { rangeUtil, } from '@grafana/data'; import { getDataSourceSrv } from '@grafana/runtime'; +import { DataQuery } from '@grafana/schema'; import { dataSource as expressionDatasource } from 'app/features/expressions/ExpressionDatasource'; import { isExpressionQuery } from 'app/features/expressions/guards'; import { ExpressionDatasourceUID, ExpressionQuery, ExpressionQueryType } from 'app/features/expressions/types'; diff --git a/public/app/features/alerting/unified/components/rules/central-state-history/CentralHistoryRuntimeDataSource.ts b/public/app/features/alerting/unified/components/rules/central-state-history/CentralHistoryRuntimeDataSource.ts index b6fef8062f4..3013b097e16 100644 --- a/public/app/features/alerting/unified/components/rules/central-state-history/CentralHistoryRuntimeDataSource.ts +++ b/public/app/features/alerting/unified/components/rules/central-state-history/CentralHistoryRuntimeDataSource.ts @@ -1,8 +1,9 @@ import { useEffect, useMemo } from 'react'; -import { DataQuery, DataQueryRequest, DataQueryResponse, TestDataSourceResponse } from '@grafana/data'; +import { DataQueryRequest, DataQueryResponse, TestDataSourceResponse } from '@grafana/data'; import { getTemplateSrv } from '@grafana/runtime'; import { RuntimeDataSource, sceneUtils } from '@grafana/scenes'; +import { DataQuery } from '@grafana/schema'; import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv'; import { dispatch } from 'app/store/store'; diff --git a/public/app/features/alerting/unified/utils/rule-form.ts b/public/app/features/alerting/unified/utils/rule-form.ts index 7a95be75c1a..194b7bec552 100644 --- a/public/app/features/alerting/unified/utils/rule-form.ts +++ b/public/app/features/alerting/unified/utils/rule-form.ts @@ -1,7 +1,5 @@ import { - DataQuery, DataSourceInstanceSettings, - DataSourceRef, IntervalValues, RelativeTimeRange, ScopedVars, @@ -14,7 +12,7 @@ import { PromQuery } from '@grafana/prometheus'; import { config, getDataSourceSrv } from '@grafana/runtime'; import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend'; import { VizPanel, sceneGraph } from '@grafana/scenes'; -import { DataSourceJsonData } from '@grafana/schema'; +import { DataQuery, DataSourceJsonData, DataSourceRef } from '@grafana/schema'; import { DashboardModel } from 'app/features/dashboard/state/DashboardModel'; import { PanelModel } from 'app/features/dashboard/state/PanelModel'; import {