Change 'grafana-expression' to ExpressionDatasourceRef.type so isExpr… (#43379)

* Change 'grafana-expression' to ExpressionDatasourceRef.type so isExpressionReference works

* use constant ref in tests

* import from package
This commit is contained in:
Travis Patterson 2021-12-21 07:11:11 -07:00 committed by GitHub
parent b41c3124bb
commit d52a6e3d3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 15 deletions

View File

@ -25,6 +25,7 @@ import { PrometheusDatasource } from 'app/plugins/datasource/prometheus/datasour
import { DataSourceApi } from '@grafana/data';
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
import { PromOptions } from 'app/plugins/datasource/prometheus/types';
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
jest.mock('./api/prometheus');
jest.mock('./api/ruler');
@ -308,7 +309,7 @@ describe('PanelAlertTabContent', () => {
hide: false,
type: 'classic_conditions',
datasource: {
type: 'grafana-expression',
type: ExpressionDatasourceRef.type,
uid: '-100',
},
conditions: [

View File

@ -1,6 +1,7 @@
import { ClassicCondition, ExpressionQuery } from 'app/features/expressions/types';
import { AlertQuery } from 'app/types/unified-alerting-dto';
import { queriesWithUpdatedReferences, updateMathExpressionRefs } from './util';
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
describe('rule-editor', () => {
const dataSource: AlertQuery = {
@ -23,10 +24,7 @@ describe('rule-editor', () => {
model: {
refId: 'B',
type: 'classic_conditions',
datasource: {
uid: '-100',
type: 'grafana-expression',
},
datasource: ExpressionDatasourceRef,
conditions: [
{
type: 'query',
@ -56,10 +54,7 @@ describe('rule-editor', () => {
model: {
refId: 'B',
type: 'math',
datasource: {
uid: '-100',
type: 'grafana-expression',
},
datasource: ExpressionDatasourceRef,
conditions: [],
expression: 'abs($A) + $A',
},
@ -72,10 +67,7 @@ describe('rule-editor', () => {
model: {
refId: 'B',
type: 'reduce',
datasource: {
uid: '-100',
type: 'grafana-expression',
},
datasource: ExpressionDatasourceRef,
conditions: [],
reducer: 'mean',
expression: 'A',

View File

@ -30,6 +30,7 @@ import { isGrafanaRulesSource } from './datasource';
import { arrayToRecord, recordToArray } from './misc';
import { isAlertingRulerRule, isGrafanaRulerRule, isRecordingRulerRule } from './rules';
import { parseInterval } from './time';
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
export const getDefaultFormValues = (): RuleFormValues =>
Object.freeze({
@ -192,7 +193,7 @@ const getDefaultExpression = (refId: string): AlertQuery => {
type: ExpressionQueryType.classic,
datasource: {
uid: ExpressionDatasourceUID,
type: 'grafana-expression',
type: ExpressionDatasourceRef.type,
},
conditions: [
{

View File

@ -36,7 +36,7 @@ export const instanceSettings: DataSourceInstanceSettings = {
id: -100,
uid: ExpressionDatasourceUID,
name: ExpressionDatasourceRef.type,
type: 'grafana-expression',
type: ExpressionDatasourceRef.type,
access: 'proxy',
meta: {
baseUrl: '',