[v10.0.x] Dashboard: Fix Drawer validation to avoid errors with empty request objects (#68287)

Co-authored-by: Alexa V <239999+axelavargas@users.noreply.github.com>
Fix Drawer validation to avoid errors with empty `request` objects (#68214)
This commit is contained in:
Grot (@grafanabot)
2023-05-11 11:29:32 +02:00
committed by GitHub
parent 298542e353
commit 869a693bcf
2 changed files with 4 additions and 2 deletions
@@ -1,3 +1,4 @@
import { isEmpty } from 'lodash';
import React, { useState } from 'react';
import { CoreApp, DataSourceApi, formattedValueToString, getValueFormat, PanelData, PanelPlugin } from '@grafana/data';
@@ -116,7 +117,8 @@ export const InspectContent = ({
function formatStats(data: PanelData) {
const { request } = data;
if (!request) {
if (!request || isEmpty(request)) {
return '';
}
@@ -44,7 +44,7 @@ export const InspectStatsTab = ({ data, timeZone }: InspectStatsTabProps) => {
}
stats.push({
displayName: t('dashboard.inspect-stats.queries', 'Number of queries'),
value: data.request.targets.length,
value: data.request.targets?.length ?? 0,
});
stats.push({
displayName: t('dashboard.inspect-stats.rows', 'Total number rows'),