Skip to content

Commit

Permalink
feat(ui): change badge if there's alertmanager error
Browse files Browse the repository at this point in the history
Fixes #3987
  • Loading branch information
prymitive committed Feb 20, 2022
1 parent 4f5c4cd commit 44af332
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Changed

- Don't render `@cluster` labels if there's only one cluster configured #3994.
- Show `!` on favicon badge if there's any alertmanager upstream with errors #3987.

## v0.98

Expand Down
23 changes: 23 additions & 0 deletions ui/src/Components/FaviconBadge/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,27 @@ describe("<FaviconBadge />", () => {
expect(Favico.badge).toHaveBeenCalledTimes(1);
expect(Favico.badge).toHaveBeenCalledWith("?");
});

it("badge is ! when there are alertmanager upstreams with errors", () => {
alertStore.data.setUpstreams({
counters: { total: 1, healthy: 1, failed: 0 },
clusters: { default: ["default"] },
instances: [
{
name: "default",
uri: "http://localhost",
publicURI: "http://example.com",
readonly: false,
headers: { foo: "bar" },
corsCredentials: "include",
error: 'Healthcheck filter "DeadMansSwitch" didn\'t match any alerts',
version: "0.21.0",
cluster: "default",
clusterMembers: ["default"],
},
],
});
MountedFaviconBadge();
expect(Favico.badge).toHaveBeenCalledWith("!");
});
});
6 changes: 5 additions & 1 deletion ui/src/Components/FaviconBadge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ const FaviconBadge: FC<{
() =>
autorun(() => {
favico.badge(
alertStore.status.error === null ? alertStore.info.totalAlerts : "?"
alertStore.data.upstreamsWithErrors.length > 0
? "!"
: alertStore.status.error === null
? alertStore.info.totalAlerts
: "?"
);
}),
[] // eslint-disable-line react-hooks/exhaustive-deps
Expand Down

0 comments on commit 44af332

Please sign in to comment.