LogsPanel: Show message and actions if panel cannot visualize data (#42878)

This commit is contained in:
Torkel Ödegaard 2021-12-09 11:46:24 +01:00 committed by GitHub
parent e555221523
commit d76dd7d14b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -64,7 +64,8 @@ function getMessageFor(
return message;
}
if (!data.series || data.series.length === 0) {
// In some cases there is a data frame but with no fields
if (!data.series || data.series.length === 0 || (data.series.length === 1 && data.series[0].fields.length === 0)) {
return 'No data';
}

View File

@ -15,6 +15,7 @@ import { Options } from './types';
import { dataFrameToLogsModel, dedupLogRows } from 'app/core/logs_model';
import { getFieldLinksForExplore } from 'app/features/explore/utils/links';
import { COMMON_LABELS } from '../../../core/logs_model';
import { PanelDataErrorView } from 'app/features/panel/components/PanelDataErrorView';
interface LogsPanelProps extends PanelProps<Options> {}
@ -32,6 +33,7 @@ export const LogsPanel: React.FunctionComponent<LogsPanelProps> = ({
enableLogDetails,
},
title,
id,
}) => {
const isAscending = sortOrder === LogsSortOrder.Ascending;
const style = useStyles2(getStyles(title, isAscending));
@ -80,12 +82,8 @@ export const LogsPanel: React.FunctionComponent<LogsPanelProps> = ({
[data]
);
if (!data) {
return (
<div className="panel-empty">
<p>No data found in response</p>
</div>
);
if (!data || logRows.length === 0) {
return <PanelDataErrorView panelId={id} data={data} needsStringField />;
}
const renderCommonLabels = () => (