From f831836fa75107e4254028fe47eaf384e883042b Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Fri, 23 Nov 2018 12:15:26 +0100 Subject: [PATCH] Explore: make query field suggestions more robust - drop invalid history items - make highlighter more robust by defaulting to empty string on text to highlight --- public/app/features/explore/Typeahead.tsx | 2 +- public/app/plugins/datasource/logging/language_provider.ts | 5 +++-- .../app/plugins/datasource/prometheus/language_provider.ts | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/public/app/features/explore/Typeahead.tsx b/public/app/features/explore/Typeahead.tsx index 13882e030f6..721527fbebe 100644 --- a/public/app/features/explore/Typeahead.tsx +++ b/public/app/features/explore/Typeahead.tsx @@ -42,7 +42,7 @@ class TypeaheadItem extends React.PureComponent { render() { const { isSelected, item, prefix } = this.props; const className = isSelected ? 'typeahead-item typeahead-item__selected' : 'typeahead-item'; - const { label } = item; + const label = item.label || ''; return (
  • diff --git a/public/app/plugins/datasource/logging/language_provider.ts b/public/app/plugins/datasource/logging/language_provider.ts index 79e1cf68af1..21d2846ac63 100644 --- a/public/app/plugins/datasource/logging/language_provider.ts +++ b/public/app/plugins/datasource/logging/language_provider.ts @@ -97,9 +97,10 @@ export default class LoggingLanguageProvider extends LanguageProvider { if (history && history.length > 0) { const historyItems = _.chain(history) - .uniqBy('query.expr') - .take(HISTORY_ITEM_COUNT) .map(h => h.query.expr) + .filter() + .uniq() + .take(HISTORY_ITEM_COUNT) .map(wrapLabel) .map(item => addHistoryMetadata(item, history)) .value(); diff --git a/public/app/plugins/datasource/prometheus/language_provider.ts b/public/app/plugins/datasource/prometheus/language_provider.ts index 5fd8fcebaaf..d7ccead8725 100644 --- a/public/app/plugins/datasource/prometheus/language_provider.ts +++ b/public/app/plugins/datasource/prometheus/language_provider.ts @@ -125,9 +125,10 @@ export default class PromQlLanguageProvider extends LanguageProvider { if (history && history.length > 0) { const historyItems = _.chain(history) - .uniqBy('query.expr') - .take(HISTORY_ITEM_COUNT) .map(h => h.query.expr) + .filter() + .uniq() + .take(HISTORY_ITEM_COUNT) .map(wrapLabel) .map(item => addHistoryMetadata(item, history)) .value();