ui: Update helper to return Proxy and Service Health if the Service has a Proxy (#8168)

This commit is contained in:
Kenia 2020-06-23 10:28:29 -04:00 committed by hashicorp-ci
parent 5315f37d19
commit 44f03b4f6c
3 changed files with 16 additions and 12 deletions

View File

@ -1,17 +1,16 @@
{{#if (gt items.length 0)}} {{#if (gt items.length 0)}}
<ListCollection @items={{items}} class="consul-service-list" as |item index|> <ListCollection @items={{items}} class="consul-service-list" as |item index|>
<BlockSlot @name="header"> <BlockSlot @name="header">
<dl class={{service/health-checks item}}> {{#let (get proxies item.Name) as |proxy|}}
<dt> {{#let (service/health-checks item proxy) as |health|}}
Health <dl class={{health}}>
</dt>
<dd> <dd>
<Tooltip @position="top-start"> <Tooltip @position="top-start">
{{#if (eq 'critical' (service/health-checks item))}} {{#if (eq 'critical' health)}}
At least one health check on one instance is failing. At least one health check on one instance is failing.
{{else if (eq 'warning' (service/health-checks item))}} {{else if (eq 'warning' health)}}
At least one health check on one instance has a warning. At least one health check on one instance has a warning.
{{else if (eq 'passing' (service/health-checks item))}} {{else if (eq 'passing' health)}}
All health checks are passing. All health checks are passing.
{{else}} {{else}}
There are no health checks. There are no health checks.
@ -19,6 +18,8 @@
</Tooltip> </Tooltip>
</dd> </dd>
</dl> </dl>
{{/let}}
{{/let}}
{{#if (eq item.Kind 'terminating-gateway')}} {{#if (eq item.Kind 'terminating-gateway')}}
<a data-test-service-name href={{href-to "dc.services.show.services" item.Name}}> <a data-test-service-name href={{href-to "dc.services.show.services" item.Name}}>
{{item.Name}} {{item.Name}}

View File

@ -24,7 +24,7 @@ export default Controller.extend({
// used by more than one service // used by more than one service
if (item.ProxyFor) { if (item.ProxyFor) {
item.ProxyFor.forEach(service => { item.ProxyFor.forEach(service => {
proxies[service] = true; proxies[service] = item;
}); });
} }
}); });

View File

@ -1,12 +1,15 @@
import { helper } from '@ember/component/helper'; import { helper } from '@ember/component/helper';
export function healthChecks([item], hash) { export function healthChecks(
[item, proxy = { ChecksCritical: 0, ChecksWarning: 0, ChecksPassing: 0 }],
hash
) {
switch (true) { switch (true) {
case item.ChecksCritical !== 0: case item.ChecksCritical !== 0 || proxy.ChecksCritical !== 0:
return 'critical'; return 'critical';
case item.ChecksWarning !== 0: case item.ChecksWarning !== 0 || proxy.ChecksWarning !== 0:
return 'warning'; return 'warning';
case item.ChecksPassing !== 0: case item.ChecksPassing !== 0 || proxy.ChecksPassing !== 0:
return 'passing'; return 'passing';
default: default:
return 'empty'; return 'empty';