chore(ui): use fatal error screen if there's only 1 upstream and it's down

This commit is contained in:
Łukasz Mierzwa
2018-09-12 21:50:51 +01:00
parent 84cda643f3
commit 6a3bc39bf5
2 changed files with 30 additions and 0 deletions

View File

@@ -25,6 +25,18 @@ const Grid = observer(
return <FatalError message={alertStore.status.error} />;
}
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 (
<FatalError message={alertStore.data.upstreams.instances[0].error} />
);
}
return (
<React.Fragment>
{alertStore.data.upstreams.instances

View File

@@ -33,6 +33,24 @@ describe("<Grid />", () => {
expect(tree.text()).toBe("<AlertGrid />");
});
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("<FatalError />");
});
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("<AlertGrid />");
});
it("renders UpstreamError for each unhealthy upstream", () => {
alertStore.data.upstreams = {
counters: { total: 3, healthy: 1, failed: 2 },