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; 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'; return 'No data';
} }

View File

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