mirror of
https://github.com/grafana/grafana.git
synced 2026-09-05 04:40:13 -05:00
Alerting: Run queries (#33423)
* 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>
This commit is contained in:
co-authored by
Hugo Häggmark
Marcus Andersson
parent
9510c4f112
commit
0006765a40
@@ -76,7 +76,7 @@ export const ClassicConditions: FC<Props> = ({ onChange, query, refIds }) => {
|
||||
</div>
|
||||
</InlineField>
|
||||
</InlineFieldRow>
|
||||
<Button variant="secondary" onClick={onAddCondition}>
|
||||
<Button variant="secondary" type="button" onClick={onAddCondition}>
|
||||
<Icon name="plus-circle" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -122,7 +122,7 @@ export const Condition: FC<Props> = ({ condition, index, onChange, onRemoveCondi
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<Button variant="secondary" onClick={() => onRemoveCondition(index)}>
|
||||
<Button variant="secondary" type="button" onClick={() => onRemoveCondition(index)}>
|
||||
<Icon name="trash-alt" />
|
||||
</Button>
|
||||
</InlineFieldRow>
|
||||
|
||||
@@ -1,7 +1,20 @@
|
||||
import { DataQuery } from '@grafana/data';
|
||||
import { ExpressionDatasourceID } from './ExpressionDatasource';
|
||||
import { ExpressionQuery } from './types';
|
||||
import { ExpressionQuery, ExpressionQueryType } from './types';
|
||||
|
||||
export const isExpressionQuery = (dataQuery?: DataQuery): dataQuery is ExpressionQuery => {
|
||||
return dataQuery?.datasource === ExpressionDatasourceID;
|
||||
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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user