From 5b253c2adc6c4d21d35a66e467757aa08d165085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Thu, 23 Aug 2018 23:59:32 +0100 Subject: [PATCH] fix(ui): labels in the history menu should render with whatever matcher was used for the filter --- .../Components/Labels/HistoryLabel/index.js | 37 ++++++++++++++----- .../Components/NavBar/FilterInput/History.js | 9 +++-- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/ui/src/Components/Labels/HistoryLabel/index.js b/ui/src/Components/Labels/HistoryLabel/index.js index 0fe5cac9e..79ef08d31 100644 --- a/ui/src/Components/Labels/HistoryLabel/index.js +++ b/ui/src/Components/Labels/HistoryLabel/index.js @@ -1,24 +1,43 @@ import React from "react"; +import PropTypes from "prop-types"; import { observer } from "mobx-react"; +import { DefaultLabelClass } from "Common/Colors"; +import { QueryOperators } from "Common/Query"; import { BaseLabel } from "Components/Labels/BaseLabel"; import "./index.css"; const HistoryLabel = observer( class HistoryLabel extends BaseLabel { + static propTypes = { + ...BaseLabel.propTypes, + matcher: PropTypes.string.isRequired + }; + render() { - const { name, value } = this.props; + const { name, matcher, value } = this.props; + + let classNames = [ + "components-label", + "components-label-history", + "text-nowrap", + "text-truncate", + "badge", + "mw-100" + ]; + let style = {}; + if (matcher === QueryOperators.Equal) { + classNames.push(`badge-${this.getColorClass(name, value)}`); + style = this.getColorStyle(name, value); + } else { + classNames.push(`badge-${DefaultLabelClass}`); + } + return ( - - {name ? `${name}: ` : null} + + {name ? `${name}${matcher}` : null} {value} ); diff --git a/ui/src/Components/NavBar/FilterInput/History.js b/ui/src/Components/NavBar/FilterInput/History.js index 01d4b49fd..f48c21471 100644 --- a/ui/src/Components/NavBar/FilterInput/History.js +++ b/ui/src/Components/NavBar/FilterInput/History.js @@ -86,7 +86,7 @@ const HistoryMenu = onClickOutside( filters.map(historyFilters => (