mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Fix missing parameters on Query Builder operations (#60677)
* add missing mandatory params * improve naming * change let to const
This commit is contained in:
@@ -51,9 +51,14 @@ import {
|
||||
makeError,
|
||||
replaceVariables,
|
||||
} from '../../prometheus/querybuilder/shared/parsingUtils';
|
||||
import { QueryBuilderLabelFilter, QueryBuilderOperation } from '../../prometheus/querybuilder/shared/types';
|
||||
import {
|
||||
QueryBuilderLabelFilter,
|
||||
QueryBuilderOperation,
|
||||
QueryBuilderOperationParamValue,
|
||||
} from '../../prometheus/querybuilder/shared/types';
|
||||
|
||||
import { binaryScalarDefs } from './binaryScalarOperations';
|
||||
import { checkParamsAreValid, getDefinitionById } from './operations';
|
||||
import { LokiOperationId, LokiVisualQuery, LokiVisualQueryBinary } from './types';
|
||||
|
||||
interface Context {
|
||||
@@ -256,7 +261,12 @@ function getLabelParser(expr: string, node: SyntaxNode): QueryBuilderOperation {
|
||||
const parser = getString(expr, parserNode);
|
||||
|
||||
const string = handleQuotes(getString(expr, node.getChild(String)));
|
||||
const params = !!string ? [string] : [];
|
||||
let params: QueryBuilderOperationParamValue[] = !!string ? [string] : [];
|
||||
const opDef = getDefinitionById(parser);
|
||||
if (opDef && !checkParamsAreValid(opDef, params)) {
|
||||
params = opDef?.defaultParams || [];
|
||||
}
|
||||
|
||||
return {
|
||||
id: parser,
|
||||
params,
|
||||
|
||||
Reference in New Issue
Block a user