mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
Variables: Fixes error with: cannot read property length of undefined (#31458)
* Variables: Fixes error with: cannot read property length of undefined * A different fix
This commit is contained in:
parent
aeabaee2da
commit
e9d2592481
@ -9,6 +9,7 @@ import { DataSourceApi, FieldType, getFieldDisplayName, isDataFrame, MetricFindV
|
||||
import { updateVariableOptions, updateVariableTags } from './reducer';
|
||||
import { getTimeSrv, TimeSrv } from '../../dashboard/services/TimeSrv';
|
||||
import { getLegacyQueryOptions, getTemplatedRegex } from '../utils';
|
||||
import { getProcessedDataFrames } from 'app/features/query/state/runRequest';
|
||||
|
||||
export function toMetricFindValues(): OperatorFunction<PanelData, MetricFindValue[]> {
|
||||
return (source) =>
|
||||
@ -23,6 +24,7 @@ export function toMetricFindValues(): OperatorFunction<PanelData, MetricFindValu
|
||||
return frames;
|
||||
}
|
||||
|
||||
const processedDataFrames = getProcessedDataFrames(frames);
|
||||
const metrics: MetricFindValue[] = [];
|
||||
|
||||
let valueIndex = -1;
|
||||
@ -30,7 +32,7 @@ export function toMetricFindValues(): OperatorFunction<PanelData, MetricFindValu
|
||||
let stringIndex = -1;
|
||||
let expandableIndex = -1;
|
||||
|
||||
for (const frame of frames) {
|
||||
for (const frame of processedDataFrames) {
|
||||
for (let index = 0; index < frame.fields.length; index++) {
|
||||
const field = frame.fields[index];
|
||||
const fieldName = getFieldDisplayName(field, frame, frames).toLowerCase();
|
||||
@ -181,6 +183,7 @@ export function areMetricFindValues(data: any[]): data is MetricFindValue[] {
|
||||
}
|
||||
|
||||
const firstValue: any = data[0];
|
||||
|
||||
if (isDataFrame(firstValue)) {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user