mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 04:59:15 -06:00
0006765a40
* alertingqueryrunner first edition * added so we always set name and uid when changing datasource. * wip. * wip * added support for canceling requests. * util for getting time ranges for expression queries * remove logs, store data in state * added structure for marble testing. * change so the expression buttons doesnt submit form. * fixed run button. * replaced mocks with implementation that will set default query + expression. * fixed so we set a datasource name for the default expression rule. * improving expression guard. * Update public/app/features/alerting/components/AlertingQueryEditor.tsx Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com> * fixed some nits. * some refactoring after feedback. * use grafanthemev2 * rename grafanatheme * fixing so we convert to correct relative time range. * added some more tests. * fixing so duplicating query works. * added some more tests without marbles. * small refactoring to share code between runRequest and alerting query runner. Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com> Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
21 lines
580 B
TypeScript
21 lines
580 B
TypeScript
import { DataQuery } from '@grafana/data';
|
|
import { ExpressionDatasourceID } from './ExpressionDatasource';
|
|
import { ExpressionQuery, ExpressionQueryType } from './types';
|
|
|
|
export const isExpressionQuery = (dataQuery?: DataQuery): dataQuery is ExpressionQuery => {
|
|
if (!dataQuery) {
|
|
return false;
|
|
}
|
|
|
|
if (dataQuery.datasource === ExpressionDatasourceID) {
|
|
return true;
|
|
}
|
|
|
|
const expression = dataQuery as ExpressionQuery;
|
|
|
|
if (typeof expression.type !== 'string') {
|
|
return false;
|
|
}
|
|
return Object.values(ExpressionQueryType).includes(expression.type);
|
|
};
|