Alerting: Fix changing datasource and creating new query not using defaults. (#63092)

* Set default query when changing data source or adding new alert query

* Set default query when creating new alert rule

* Set fefault query for cloud and recording rules

* Create hook for getting defaults in AlertRuleForm

* fixing tests

* Use conditionals with 'if' for more clarity and rename lazy to async

* Add loading indicator for default queries

* Fix tests

* Make newModel a sync method and fix tests error

* Use useAsync instead of useEffect for an async call
This commit is contained in:
Sonia Aguilar
2023-02-24 13:43:54 +01:00
committed by GitHub
parent 09fdbb69ec
commit b42f973a7a
14 changed files with 441 additions and 77 deletions
@@ -19,5 +19,12 @@ export function getDataSourceSrv() {
return {
getList: () => [ds1],
getInstanceSettings: () => ds1,
get: () =>
Promise.resolve({
filterQuery: () => true,
getDefaultQuery: () => ({
expr: 'vector(1)',
}),
}),
};
}