From c0131758d2ca119a051bf9e427a327040b4c2f86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Thu, 30 Aug 2018 20:09:43 +0100 Subject: [PATCH] fix(ui): drop check for storedIndex since we check for filter mismatch before reaching there Add a check to validate that filters are marked as applied after fetch --- ui/src/Stores/AlertStore.js | 31 +++++++++++-------------------- ui/src/Stores/AlertStore.test.js | 1 + 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/ui/src/Stores/AlertStore.js b/ui/src/Stores/AlertStore.js index 9166d85db..21e03792d 100644 --- a/ui/src/Stores/AlertStore.js +++ b/ui/src/Stores/AlertStore.js @@ -242,26 +242,17 @@ class AlertStore { const storedIndex = this.filters.values.findIndex( f => f.raw === filter.text ); - if (storedIndex >= 0) { - this.filters.values[storedIndex] = Object.assign( - this.filters.values[storedIndex], - { - applied: true, - isValid: filter.isValid, - hits: filter.hits, - name: filter.name, - matcher: filter.matcher, - value: filter.value - } - ); - } else { - console.warn( - `Got response with filter ${ - filter.text - } which isn't one of applied filters, ignoring` - ); - return; - } + this.filters.values[storedIndex] = Object.assign( + this.filters.values[storedIndex], + { + applied: true, + isValid: filter.isValid, + hits: filter.hits, + name: filter.name, + matcher: filter.matcher, + value: filter.value + } + ); } let updates = {}; diff --git a/ui/src/Stores/AlertStore.test.js b/ui/src/Stores/AlertStore.test.js index fb55d512e..b8958bd1e 100644 --- a/ui/src/Stores/AlertStore.test.js +++ b/ui/src/Stores/AlertStore.test.js @@ -204,6 +204,7 @@ describe("AlertStore.fetch", () => { expect(store.status.value).toEqual(AlertStoreStatuses.Idle); expect(store.info.version).toBe("fakeVersion"); + expect(store.filters.values[0].applied).toBe(true); }); it("fetch() works with valid response", async () => {