diff --git a/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.js b/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.js
index c1b0b7241..3c56f6eea 100644
--- a/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.js
+++ b/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.js
@@ -4,6 +4,8 @@ import PropTypes from "prop-types";
import { action } from "mobx";
import { observer } from "mobx-react";
+import hash from "object-hash";
+
import { components } from "react-select";
import { SilenceFormStore } from "Stores/SilenceFormStore";
@@ -12,6 +14,16 @@ import { MultiSelect } from "Components/MultiSelect";
import { ValidationError } from "Components/MultiSelect/ValidationError";
import { MatchCounter } from "./MatchCounter";
+const GenerateHashFromMatchers = (silenceFormStore, matcher) =>
+ hash({
+ alertmanagers: silenceFormStore.data.alertmanagers,
+ matcher: {
+ name: matcher.name,
+ values: matcher.values,
+ isRegex: matcher.isRegex
+ }
+ });
+
const Placeholder = props => {
return (
@@ -20,15 +32,19 @@ const Placeholder = props => {
);
};
-const ValueContainer = ({ children, ...props }) => (
+const ValueContainer = observer(({ children, ...props }) => (
{children}
-);
+));
const LabelValueInput = observer(
class LabelValueInput extends MultiSelect {
diff --git a/ui/src/Components/SilenceModal/SilenceMatch/MatchCounter.js b/ui/src/Components/SilenceModal/SilenceMatch/MatchCounter.js
index 37ccec5f2..0921ade76 100644
--- a/ui/src/Components/SilenceModal/SilenceMatch/MatchCounter.js
+++ b/ui/src/Components/SilenceModal/SilenceMatch/MatchCounter.js
@@ -6,10 +6,9 @@ import { observer } from "mobx-react";
import { throttle } from "lodash";
-import hash from "object-hash";
-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faExclamationCircle } from "@fortawesome/free-solid-svg-icons/faExclamationCircle";
+import { faSpinner } from "@fortawesome/free-solid-svg-icons/faSpinner";
import { FormatBackendURI, FormatAlertsQ } from "Stores/AlertStore";
import { SilenceFormStore } from "Stores/SilenceFormStore";
@@ -26,7 +25,7 @@ const MatchCounter = observer(
matchedAlerts = observable(
{
- total: 0,
+ total: null,
error: null,
fetch: null,
setTotal(value) {
@@ -85,13 +84,7 @@ const MatchCounter = observer(
this.onUpdateCounter();
}
- componentDidUpdate() {
- this.onUpdateCounter();
- }
-
render() {
- const { silenceFormStore, matcher } = this.props;
-
if (this.matchedAlerts.error !== null) {
return (
- {this.matchedAlerts.total}
+ {this.matchedAlerts.total === null ? (
+
+ ) : (
+ this.matchedAlerts.total
+ )}
);
diff --git a/ui/src/Components/SilenceModal/SilenceMatch/MatchCounter.test.js b/ui/src/Components/SilenceModal/SilenceMatch/MatchCounter.test.js
index 118866c25..bbe8be648 100644
--- a/ui/src/Components/SilenceModal/SilenceMatch/MatchCounter.test.js
+++ b/ui/src/Components/SilenceModal/SilenceMatch/MatchCounter.test.js
@@ -33,6 +33,7 @@ const MountedMatchCounter = () => {
describe("
", () => {
it("matches snapshot with empty matcher", () => {
+ fetch.mockResponse(JSON.stringify({ totalAlerts: 0 }));
const tree = MountedMatchCounter();
expect(toDiffableHtml(tree.html())).toMatchSnapshot();
});
@@ -66,6 +67,7 @@ describe("
", () => {
});
it("totalAlerts is 0 after mount", async () => {
+ fetch.mockResponse(JSON.stringify({ totalAlerts: 0 }));
const tree = MountedMatchCounter();
expect(tree.text()).toBe("0");
});
@@ -78,7 +80,7 @@ describe("
", () => {
matcher.values = [MatcherValueToObject("bar")];
const tree = MountedMatchCounter();
- expect(tree.text()).toBe("0");
+ expect(tree.text()).toBe("");
await expect(tree.instance().matchedAlerts.fetch).resolves.toBeUndefined();
expect(tree.text()).toBe("123");
});
diff --git a/ui/src/Components/SilenceModal/SilenceMatch/__snapshots__/LabelValueInput.test.js.snap b/ui/src/Components/SilenceModal/SilenceMatch/__snapshots__/LabelValueInput.test.js.snap
index b140c2418..4844b5a35 100644
--- a/ui/src/Components/SilenceModal/SilenceMatch/__snapshots__/LabelValueInput.test.js.snap
+++ b/ui/src/Components/SilenceModal/SilenceMatch/__snapshots__/LabelValueInput.test.js.snap
@@ -11,9 +11,21 @@ exports[`
matches snapshot 1`] = `
>
- 0
+
diff --git a/ui/src/Components/SilenceModal/SilenceMatch/__snapshots__/MatchCounter.test.js.snap b/ui/src/Components/SilenceModal/SilenceMatch/__snapshots__/MatchCounter.test.js.snap
index 79623f9aa..0b646cfcb 100644
--- a/ui/src/Components/SilenceModal/SilenceMatch/__snapshots__/MatchCounter.test.js.snap
+++ b/ui/src/Components/SilenceModal/SilenceMatch/__snapshots__/MatchCounter.test.js.snap
@@ -10,7 +10,6 @@ exports[` matches snapshot with empty matcher 1`] = `
>
0