From 4e591653bd261f45dac1a04eba7928e7a601a967 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Tue, 4 Dec 2018 13:26:26 +0100 Subject: [PATCH] Set query empty condition in render function. Also clear query transactions when no valid query is present --- public/app/features/explore/Explore.tsx | 5 +++++ public/app/features/explore/Logs.tsx | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/public/app/features/explore/Explore.tsx b/public/app/features/explore/Explore.tsx index 3e35a68bf84..b381fdbcd41 100644 --- a/public/app/features/explore/Explore.tsx +++ b/public/app/features/explore/Explore.tsx @@ -771,6 +771,9 @@ export class Explore extends React.PureComponent { async runQueries(resultType: ResultType, queryOptions: any, resultGetter?: any) { const queries = [...this.modifiedQueries]; if (!hasNonEmptyQuery(queries)) { + this.setState({ + queryTransactions: [], + }); return; } const { datasource } = this.state; @@ -837,6 +840,7 @@ export class Explore extends React.PureComponent { const tableLoading = queryTransactions.some(qt => qt.resultType === 'Table' && !qt.done); const logsLoading = queryTransactions.some(qt => qt.resultType === 'Logs' && !qt.done); const loading = queryTransactions.some(qt => !qt.done); + const queryEmpty = queryTransactions.some(qt => qt.resultType === 'Logs' && qt.done && qt.result.length === 0); return (
@@ -969,6 +973,7 @@ export class Explore extends React.PureComponent { range={range} scanning={scanning} scanRange={scanRange} + queryEmpty={queryEmpty} /> )} diff --git a/public/app/features/explore/Logs.tsx b/public/app/features/explore/Logs.tsx index 42a9a2fdbb0..8d098813490 100644 --- a/public/app/features/explore/Logs.tsx +++ b/public/app/features/explore/Logs.tsx @@ -140,6 +140,7 @@ interface LogsProps { range?: RawTimeRange; scanning?: boolean; scanRange?: RawTimeRange; + queryEmpty: boolean; onChangeTime?: (range: RawTimeRange) => void; onClickLabel?: (label: string, value: string) => void; onStartScanning?: () => void; @@ -239,7 +240,17 @@ export default class Logs extends PureComponent { }; render() { - const { className = '', data, loading = false, onClickLabel, position, range, scanning, scanRange } = this.props; + const { + className = '', + data, + loading = false, + onClickLabel, + position, + range, + scanning, + scanRange, + queryEmpty, + } = this.props; const { dedup, deferLogs, hiddenLogLevels, renderAll, showLocalTime, showUtc } = this.state; let { showLabels } = this.state; const hasData = data && data.rows && data.rows.length > 0; @@ -358,7 +369,7 @@ export default class Logs extends PureComponent { {hasData && deferLogs && Rendering {dedupedData.rows.length} rows...}
{!loading && - data.queryEmpty && + queryEmpty && !scanning && (
No logs found.