Expressions: Fixes the issue showing expressions editor (#62510)

* Use suggested value for uid

* update the snapshot

* use __expr__

* replace all -100 with __expr__

* update snapshot

* more changes

* revert redundant change

* Use expr.DatasourceUID where it's possible

* generate files
This commit is contained in:
ismail simsek
2023-01-31 18:50:10 +01:00
committed by GitHub
parent fdb1a47ca2
commit 91221bc436
54 changed files with 259 additions and 242 deletions
+1 -1
View File
@@ -88,7 +88,7 @@ type AlertQuery struct {
// RelativeTimeRange is the relative Start and End of the query as sent by the frontend.
RelativeTimeRange RelativeTimeRange `json:"relativeTimeRange"`
// Grafana data source unique identifier; it should be '-100' for a Server Side Expression operation.
// Grafana data source unique identifier; it should be '__expr__' for a Server Side Expression operation.
DatasourceUID string `json:"datasourceUid"`
// JSON is the raw JSON query and includes the above properties as well as custom properties.
@@ -7,6 +7,7 @@ import (
"testing"
"time"
"github.com/grafana/grafana/pkg/expr"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -29,7 +30,7 @@ func TestAlertQuery(t *testing.T) {
"queryType": "metricQuery",
"extraParam": "some text"
}`),
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
},
expectedIsExpression: true,
expectedMaxPoints: int64(defaultMaxDataPoints),
+2 -2
View File
@@ -300,7 +300,7 @@ func CreateClassicConditionExpression(refID string, inputRefID string, reducer s
return AlertQuery{
RefID: refID,
QueryType: expr.DatasourceType,
DatasourceUID: expr.OldDatasourceUID,
DatasourceUID: expr.DatasourceUID,
// the format corresponds to model `ClassicConditionJSON` in /pkg/expr/classic/classic.go
Model: json.RawMessage(fmt.Sprintf(`
{
@@ -334,7 +334,7 @@ func CreateClassicConditionExpression(refID string, inputRefID string, reducer s
}
}
]
}`, refID, inputRefID, operation, threshold, reducer, expr.OldDatasourceUID, expr.DatasourceType)),
}`, refID, inputRefID, operation, threshold, reducer, expr.DatasourceUID, expr.DatasourceType)),
}
}