Always transition to imported peers.edit

This commit is contained in:
Michael Klein 2022-10-11 16:53:09 +02:00
parent 1228b9a8a8
commit 2f19d4e97e
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 {
@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,18 +1,28 @@
<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}}>
<BlockSlot @name='header'>
{{#let
(eq @peer.State 'FAILING')
(and @peer (eq item.InstanceCount 0))
as |peerIsFailing peeredAndInstanceCountZero|
}}
<dl class={{if (or peerIsFailing peeredAndInstanceCountZero) 'help' item.MeshStatus}}>
<dt>
Health
</dt>
<dd>
<Tooltip @position="top-start">
{{#if (eq 'critical' item.MeshStatus)}}
<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.
@ -24,60 +34,64 @@
</Tooltip>
</dd>
</dl>
{{#if (gt item.InstanceCount 0)}}
{{/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
)
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}}
{{else}}
<p data-test-service-name>
{{item.Name}}
</p>
{{/if}}
{{/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'))) }}
{{#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}}
{{format-number item.InstanceCount}}
{{pluralize item.InstanceCount 'instance' without-count=true}}
</span>
{{/if}}
<Consul::Bucket::List
@item={{item}}
@nspace={{@nspace}}
@partition={{@partition}}
/>
{{#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}}
{{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}}
{{format-number item.GatewayConfig.AssociatedServiceCount}}
{{pluralize item.GatewayConfig.AssociatedServiceCount 'upstream' without-count=true}}
</span>
{{/if}}
{{#if (or item.ConnectedWithGateway item.ConnectedWithProxy)}}
<dl class="mesh">
<dl class='mesh'>
<dt>
<Tooltip>
This service uses a proxy for the Consul service mesh
</Tooltip>
</dt>
{{#if (and item.ConnectedWithGateway item.ConnectedWithProxy )}}
{{#if (and item.ConnectedWithGateway item.ConnectedWithProxy)}}
<dd data-test-mesh>
in service mesh with proxy and gateway
</dd>

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,7 +107,11 @@ 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) {
if (StreamStatus.LastHeartbeat) {
StreamStatus.LastHeartbeat = new Date(StreamStatus.LastHeartbeat);
}
@ -117,6 +121,8 @@ export default class PeerService extends RepositoryService {
if (StreamStatus.LastSend) {
StreamStatus.LastSend = new Date(StreamStatus.LastSend);
}
}
return {
meta: {
version: 2,