mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 00:08:10 -05:00
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:
@@ -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: [
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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: [
|
||||
{
|
||||
|
||||
@@ -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: '',
|
||||
|
||||
Reference in New Issue
Block a user