From 6a3bc39bf5dacb1d3750ca52229f4c1e956d530a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Wed, 12 Sep 2018 21:50:51 +0100 Subject: [PATCH] chore(ui): use fatal error screen if there's only 1 upstream and it's down --- ui/src/Components/Grid/index.js | 12 ++++++++++++ ui/src/Components/Grid/index.test.js | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/ui/src/Components/Grid/index.js b/ui/src/Components/Grid/index.js index 1be9f3e3a..950c10d33 100644 --- a/ui/src/Components/Grid/index.js +++ b/ui/src/Components/Grid/index.js @@ -25,6 +25,18 @@ const Grid = observer( return ; } + if ( + alertStore.data.upstreams.counters && + alertStore.data.upstreams.counters.total === 1 && + alertStore.data.upstreams.counters.healthy === 0 && + alertStore.data.upstreams.instances[0] && + alertStore.data.upstreams.instances[0].error !== "" + ) { + return ( + + ); + } + return ( {alertStore.data.upstreams.instances diff --git a/ui/src/Components/Grid/index.test.js b/ui/src/Components/Grid/index.test.js index d2a23fdcb..291343ae1 100644 --- a/ui/src/Components/Grid/index.test.js +++ b/ui/src/Components/Grid/index.test.js @@ -33,6 +33,24 @@ describe("", () => { expect(tree.text()).toBe(""); }); + it("renders FatalError if there's only one upstream and it's unhealthy", () => { + alertStore.data.upstreams = { + counters: { total: 1, healthy: 0, failed: 1 }, + instances: [{ name: "am1", uri: "http://am1", error: "error" }] + }; + const tree = ShallowGrid(); + expect(tree.text()).toBe(""); + }); + + it("renders FatalError if there's only one upstream and it's unhealthy but without any error", () => { + alertStore.data.upstreams = { + counters: { total: 1, healthy: 0, failed: 1 }, + instances: [{ name: "am1", uri: "http://am1", error: "" }] + }; + const tree = ShallowGrid(); + expect(tree.text()).toBe(""); + }); + it("renders UpstreamError for each unhealthy upstream", () => { alertStore.data.upstreams = { counters: { total: 3, healthy: 1, failed: 2 },