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:
Torkel Ödegaard 2021-02-27 18:03:31 +01:00 committed by GitHub
parent aeabaee2da
commit e9d2592481
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}