Commit 541a691a by Erik Sundell

only display scan button if there is at least one existing selector that returned an empty result

parent e21ca3f5
......@@ -62,6 +62,7 @@ export interface LogsModel {
meta?: LogsMetaItem[];
rows: LogRow[];
series?: TimeSeries[];
queryEmpty?: boolean;
}
export interface LogsStream {
......
......@@ -133,7 +133,12 @@ export function ensureQueries(queries?: DataQuery[]): DataQuery[] {
* A target is non-empty when it has keys other than refId and key.
*/
export function hasNonEmptyQuery(queries: DataQuery[]): boolean {
return queries.some(query => Object.keys(query).length > 2);
return queries.some(
query =>
Object.keys(query)
.map(k => query[k])
.filter(v => v).length > 2
);
}
export function calculateResultsFromQueryTransactions(
......@@ -148,15 +153,17 @@ export function calculateResultsFromQueryTransactions(
new TableModel(),
...queryTransactions.filter(qt => qt.resultType === 'Table' && qt.done && qt.result).map(qt => qt.result)
);
const logsResult =
datasource && datasource.mergeStreams
const logsResult = {
...datasource && datasource.mergeStreams
? datasource.mergeStreams(
_.flatten(
queryTransactions.filter(qt => qt.resultType === 'Logs' && qt.done && qt.result).map(qt => qt.result)
),
graphInterval
)
: undefined;
: undefined,
queryEmpty: queryTransactions.filter(qt => qt.resultType === 'Logs' && qt.done).every(qt => qt.result.length === 0),
};
return {
graphResult,
......
......@@ -220,7 +220,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
modifiedQueries = [...this.modifiedQueries];
} else if (datasource.importQueries) {
// Datasource-specific importers
modifiedQueries = await datasource.importQueries(this.modifiedQueries, origin.meta);
modifiedQueries = await datasource.importQueries(this.modifiedQueries, datasource.meta);
} else {
// Default is blank queries
modifiedQueries = ensureQueries();
......
......@@ -358,7 +358,7 @@ export default class Logs extends PureComponent<LogsProps, LogsState> {
{hasData && deferLogs && <span>Rendering {dedupedData.rows.length} rows...</span>}
</div>
{!loading &&
!hasData &&
data.queryEmpty &&
!scanning && (
<div className="logs-nodata">
No logs found.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment