Always transition to imported peers.edit

This commit is contained in:
Michael Klein 2022-10-11 16:53:09 +02:00
parent a61085258e
commit 45f06149d4
7 changed files with 123 additions and 100 deletions

View File

@ -5,11 +5,7 @@ import { action } from "@ember/object";
export default class DcPeersEditIndexController extends Controller {
@service router;
@action transitionToStartSubRouteByType(peerModel) {
if (peerModel.isDialer) {
this.router.replaceWith("dc.peers.edit.exported");
} else {
this.router.replaceWith("dc.peers.edit.imported");
}
@action transitionToImported() {
this.router.replaceWith("dc.peers.edit.imported");
}
}

View File

@ -31,6 +31,7 @@
@type="search"
@value={{this.search}}
placeholder="Search"
class="rounded-sm border-hds-border-faint"
{{on "input" (pick "target.value" this.updateSearch)}}
/>
</div>

View File

@ -76,6 +76,7 @@
<Consul::Service::List
@items={{collection.items}}
@partition={{partition}}
@peer={{route.model.peer}}
/>
</collection.Collection>
<collection.Empty>

View File

@ -1,3 +1,3 @@
<Route @name={{routeName}} as |route|>
{{did-insert (fn this.transitionToStartSubRouteByType route.model.peer)}}
{{did-insert this.transitionToImported}}
</Route>

View File

@ -1,97 +1,111 @@
<ListCollection
class="consul-service-list"
class='consul-service-list'
...attributes
@items={{@items}}
@linkable="linkable service"
@linkable='linkable service'
as |item index|
>
<BlockSlot @name="header">
<dl class={{item.MeshStatus}}>
<dt>
Health
</dt>
<dd>
<Tooltip @position="top-start">
{{#if (eq 'critical' item.MeshStatus)}}
At least one health check on one instance is failing.
{{else if (eq 'warning' item.MeshStatus)}}
At least one health check on one instance has a warning.
{{else if (eq 'passing' item.MeshStatus)}}
All health checks are passing.
{{else}}
There are no health checks.
{{/if}}
</Tooltip>
</dd>
</dl>
{{#if (gt item.InstanceCount 0)}}
<a
data-test-service-name
href={{href-to "dc.services.show.index" item.Name
params=(if (not-eq item.Partition @partition)
(hash
partition=item.Partition
nspace=item.Namespace
peer=item.PeerName
)
(hash
peer=item.PeerName
)
)
<BlockSlot @name='header'>
{{#let
(eq @peer.State 'FAILING')
(and @peer (eq item.InstanceCount 0))
as |peerIsFailing peeredAndInstanceCountZero|
}}
>
{{item.Name}}
</a>
{{else}}
<p data-test-service-name>
{{item.Name}}
</p>
{{/if}}
<dl class={{if (or peerIsFailing peeredAndInstanceCountZero) 'help' item.MeshStatus}}>
<dt>
Health
</dt>
<dd>
<Tooltip @position='top-start'>
{{#if peerIsFailing}}
This peer is out of sync, so the current health statuses of its services are unknown.
{{else if peeredAndInstanceCountZero}}
This service currently has 0 instances. Check with the operator of its peer to make
sure this is expected behavior.
{{else if (eq 'critical' item.MeshStatus)}}
At least one health check on one instance is failing.
{{else if (eq 'warning' item.MeshStatus)}}
At least one health check on one instance has a warning.
{{else if (eq 'passing' item.MeshStatus)}}
All health checks are passing.
{{else}}
There are no health checks.
{{/if}}
</Tooltip>
</dd>
</dl>
{{/let}}
{{#if (gt item.InstanceCount 0)}}
<a
data-test-service-name
href={{href-to
'dc.services.show.index'
item.Name
params=(if
(not-eq item.Partition @partition)
(hash partition=item.Partition nspace=item.Namespace peer=item.PeerName)
(hash peer=item.PeerName)
)
}}
>
{{item.Name}}
</a>
{{else}}
<p data-test-service-name>
{{item.Name}}
</p>
{{/if}}
</BlockSlot>
<BlockSlot @name="details">
<BlockSlot @name='details'>
<Consul::Kind @item={{item}} />
<Consul::ExternalSource @item={{item}} />
{{#if (and (not-eq item.InstanceCount 0) (and (not-eq item.Kind 'terminating-gateway') (not-eq item.Kind 'ingress-gateway'))) }}
<span>
{{format-number item.InstanceCount}} {{pluralize item.InstanceCount 'instance' without-count=true}}
</span>
{{/if}}
<Consul::Bucket::List
@item={{item}}
@nspace={{@nspace}}
@partition={{@partition}}
/>
{{#if (eq item.Kind 'terminating-gateway')}}
<span data-test-associated-service-count>
{{format-number item.GatewayConfig.AssociatedServiceCount}} {{pluralize item.GatewayConfig.AssociatedServiceCount 'linked service' without-count=true}}
</span>
{{else if (eq item.Kind 'ingress-gateway')}}
<span data-test-associated-service-count>
{{format-number item.GatewayConfig.AssociatedServiceCount}} {{pluralize item.GatewayConfig.AssociatedServiceCount 'upstream' without-count=true}}
</span>
{{/if}}
{{#if (or item.ConnectedWithGateway item.ConnectedWithProxy)}}
<dl class="mesh">
<dt>
<Tooltip>
This service uses a proxy for the Consul service mesh
</Tooltip>
</dt>
{{#if (and item.ConnectedWithGateway item.ConnectedWithProxy )}}
<dd data-test-mesh>
in service mesh with proxy and gateway
</dd>
{{else if item.ConnectedWithProxy}}
<dd data-test-mesh>
in service mesh with proxy
</dd>
{{else if item.ConnectedWithGateway}}
<dd data-test-mesh>
in service mesh with gateway
</dd>
{{/if}}
</dl>
{{/if}}
{{#if
(and
(not-eq item.InstanceCount 0)
(and (not-eq item.Kind 'terminating-gateway') (not-eq item.Kind 'ingress-gateway'))
)
}}
<span>
{{format-number item.InstanceCount}}
{{pluralize item.InstanceCount 'instance' without-count=true}}
</span>
{{/if}}
{{#unless @peer}}
<Consul::Bucket::List @item={{item}} @nspace={{@nspace}} @partition={{@partition}} />
{{/unless}}
{{#if (eq item.Kind 'terminating-gateway')}}
<span data-test-associated-service-count>
{{format-number item.GatewayConfig.AssociatedServiceCount}}
{{pluralize item.GatewayConfig.AssociatedServiceCount 'linked service' without-count=true}}
</span>
{{else if (eq item.Kind 'ingress-gateway')}}
<span data-test-associated-service-count>
{{format-number item.GatewayConfig.AssociatedServiceCount}}
{{pluralize item.GatewayConfig.AssociatedServiceCount 'upstream' without-count=true}}
</span>
{{/if}}
{{#if (or item.ConnectedWithGateway item.ConnectedWithProxy)}}
<dl class='mesh'>
<dt>
<Tooltip>
This service uses a proxy for the Consul service mesh
</Tooltip>
</dt>
{{#if (and item.ConnectedWithGateway item.ConnectedWithProxy)}}
<dd data-test-mesh>
in service mesh with proxy and gateway
</dd>
{{else if item.ConnectedWithProxy}}
<dd data-test-mesh>
in service mesh with proxy
</dd>
{{else if item.ConnectedWithGateway}}
<dd data-test-mesh>
in service mesh with gateway
</dd>
{{/if}}
</dl>
{{/if}}
<TagList @item={{item}} />
</BlockSlot>
</ListCollection>

View File

@ -25,6 +25,11 @@
@extend %with-minus-square-fill-mask, %as-pseudo;
color: rgb(var(--tone-gray-500));
}
%icon-definition.empty dt::before,
%composite-row-header .help dd::before {
@extend %with-help-circle-outline-mask, %as-pseudo;
color: rgb(var(--tone-gray-500));
}
%composite-row-header [rel='me'] dd::before {
@extend %with-check-circle-fill-mask, %as-pseudo;

View File

@ -107,16 +107,22 @@ export default class PeerService extends RepositoryService {
}}
`
)((headers, body, cache) => {
// we can't easily use fragments as we are working around the serializer
// layer
const { StreamStatus } = body;
if (StreamStatus.LastHeartbeat) {
StreamStatus.LastHeartbeat = new Date(StreamStatus.LastHeartbeat);
}
if (StreamStatus.LastReceive) {
StreamStatus.LastReceive = new Date(StreamStatus.LastReceive);
}
if (StreamStatus.LastSend) {
StreamStatus.LastSend = new Date(StreamStatus.LastSend);
if (StreamStatus) {
if (StreamStatus.LastHeartbeat) {
StreamStatus.LastHeartbeat = new Date(StreamStatus.LastHeartbeat);
}
if (StreamStatus.LastReceive) {
StreamStatus.LastReceive = new Date(StreamStatus.LastReceive);
}
if (StreamStatus.LastSend) {
StreamStatus.LastSend = new Date(StreamStatus.LastSend);
}
}
return {
meta: {
version: 2,