ui: Miscellaneous Lock Session fixes (#10225)

This commit is contained in:
John Cowen 2021-05-19 11:05:54 +01:00 committed by GitHub
parent 106534f367
commit f86218c39e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 59 additions and 35 deletions

3
.changelog/10225.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
ui: Reflect the change of Session API response shape for Checks in post 1.7 Consul
```

View File

@ -16,30 +16,32 @@
<a href="{{env 'CONSUL_DOCS_URL'}}/internals/sessions.html#session-design" rel="help noopener noreferrer" target="_blank">Lock Session</a> <a href="{{env 'CONSUL_DOCS_URL'}}/internals/sessions.html#session-design" rel="help noopener noreferrer" target="_blank">Lock Session</a>
</h2> </h2>
<dl> <dl>
{{#if api.data.Name}}
<dt>Name</dt> <dt>Name</dt>
<dd>{{api.data.Name}}</dd> <dd>{{api.data.Name}}</dd>
<dt>Agent</dt> {{/if}}
<dt>ID</dt>
<dd>{{api.data.ID}}</dd>
<dt>Node</dt>
<dd> <dd>
<a href={{href-to 'dc.nodes.show' api.data.Node}}>{{api.data.Node}}</a> <a href={{href-to 'dc.nodes.show' api.data.Node}}>{{api.data.Node}}</a>
</dd> </dd>
<dt>ID</dt>
<dd>{{api.data.ID}}</dd>
<dt>Behavior</dt>
<dd>{{api.data.Behavior}}</dd>
{{#if form.data.Delay }}
<dt>Delay</dt> <dt>Delay</dt>
<dd>{{duration-from api.data.LockDelay}}</dd> <dd>{{duration-from api.data.LockDelay}}</dd>
{{/if}}
{{#if form.data.TTL }}
<dt>TTL</dt> <dt>TTL</dt>
<dd>{{api.data.TTL}}</dd> <dd>{{or api.data.TTL '-'}}</dd>
{{/if}} <dt>Behavior</dt>
{{#if (gt api.data.Checks.length 0)}} <dd>{{api.data.Behavior}}</dd>
{{#let (union api.data.NodeChecks api.data.ServiceChecks) as |checks|}}
<dt>Health Checks</dt> <dt>Health Checks</dt>
<dd> <dd>
{{ join ', ' api.data.Checks}} {{#if (gt checks.length 0)}}
{{ join ', ' checks}}
{{else}}
-
{{/if}}
</dd> </dd>
{{/if}} {{/let}}
</dl> </dl>
{{#if (can 'delete session' item=api.data)}} {{#if (can 'delete session' item=api.data)}}
<ConfirmationDialog @message="Are you sure you want to invalidate this session?"> <ConfirmationDialog @message="Are you sure you want to invalidate this session?">

View File

@ -17,27 +17,26 @@
{{#if item.Name}} {{#if item.Name}}
<dl> <dl>
<dt> <dt>
ID
</dt>
<dd>
<CopyButton <CopyButton
@value={{item.ID}} @value={{item.ID}}
@name="ID" @name="ID"
/> />
</dt> {{item.ID}}
<dd>{{item.ID}}</dd> </dd>
</dl> </dl>
{{/if}} {{/if}}
<dl class="lock-delay"> <dl class="lock-delay">
<dt> <dt {{tooltip}}>
<Tooltip>
Delay Delay
</Tooltip>
</dt> </dt>
<dd data-test-session-delay>{{duration-from item.LockDelay}}</dd> <dd data-test-session-delay>{{duration-from item.LockDelay}}</dd>
</dl> </dl>
<dl class="ttl"> <dl class="ttl">
<dt> <dt {{tooltip}}>
<Tooltip>
TTL TTL
</Tooltip>
</dt> </dt>
{{#if (eq item.TTL "")}} {{#if (eq item.TTL "")}}
<dd data-test-session-ttl={{item.TTL}}>-</dd> <dd data-test-session-ttl={{item.TTL}}>-</dd>
@ -46,25 +45,27 @@
{{/if}} {{/if}}
</dl> </dl>
<dl class="behavior"> <dl class="behavior">
<dt> <dt {{tooltip}}>
<Tooltip>
Behavior Behavior
</Tooltip>
</dt> </dt>
<dd>{{item.Behavior}}</dd> <dd>{{item.Behavior}}</dd>
</dl> </dl>
{{#let (union item.NodeChecks item.ServiceChecks) as |checks|}}
<dl class="checks"> <dl class="checks">
<dt> <dt {{tooltip}}>
<Tooltip>
Checks Checks
</Tooltip>
</dt> </dt>
<dd> <dd>
{{#each item.Checks as |item|}} {{#if (gt checks.length 0)}}
{{#each checks as |item|}}
<span>{{item}}</span> <span>{{item}}</span>
{{/each}} {{/each}}
{{else}}
-
{{/if}}
</dd> </dd>
</dl> </dl>
{{/let}}
</BlockSlot> </BlockSlot>
{{#if (can "delete sessions")}} {{#if (can "delete sessions")}}
<BlockSlot @name="actions"> <BlockSlot @name="actions">

View File

@ -0,0 +1,11 @@
.consul-lock-session-list .checks dd {
display: inline-flex;
flex-wrap: wrap;
padding-left: 0px;
}
.consul-lock-session-list .checks dd > *:not(:last-child)::after {
content: ',';
margin-right: 0.3em;
display: inline;
}

View File

@ -1,4 +1,5 @@
import Model, { attr } from '@ember-data/model'; import Model, { attr } from '@ember-data/model';
import { nullValue } from 'consul-ui/decorators/replace';
export const PRIMARY_KEY = 'uid'; export const PRIMARY_KEY = 'uid';
export const SLUG_KEY = 'ID'; export const SLUG_KEY = 'ID';
@ -18,6 +19,8 @@ export default class Session extends Model {
@attr('number') CreateIndex; @attr('number') CreateIndex;
@attr('number') ModifyIndex; @attr('number') ModifyIndex;
@attr({ defaultValue: () => [] }) Checks; @nullValue([]) @attr({ defaultValue: () => [] }) NodeChecks;
@nullValue([]) @attr({ defaultValue: () => [] }) ServiceChecks;
@attr({ defaultValue: () => [] }) Resources; // [] @attr({ defaultValue: () => [] }) Resources; // []
} }

View File

@ -68,6 +68,7 @@
@import 'consul-ui/components/consul/external-source'; @import 'consul-ui/components/consul/external-source';
@import 'consul-ui/components/consul/kind'; @import 'consul-ui/components/consul/kind';
@import 'consul-ui/components/consul/intention'; @import 'consul-ui/components/consul/intention';
@import 'consul-ui/components/consul/lock-session/list';
@import 'consul-ui/components/consul/lock-session/form'; @import 'consul-ui/components/consul/lock-session/form';
@import 'consul-ui/components/consul/auth-method'; @import 'consul-ui/components/consul/auth-method';

View File

@ -18,6 +18,7 @@
} }
// TODO: This hides the iconless dt's in the below lists as they don't have // TODO: This hides the iconless dt's in the below lists as they don't have
// tooltips the todo would be to wrap these texts in spans // tooltips the todo would be to wrap these texts in spans
.consul-lock-session-list ul > li:not(:first-child) dl:not([class]) dt,
.consul-nspace-list > ul > li:not(:first-child) dt, .consul-nspace-list > ul > li:not(:first-child) dt,
.consul-token-list > ul > li:not(:first-child) dt, .consul-token-list > ul > li:not(:first-child) dt,
.consul-policy-list > ul li:not(:first-child) dl:not(.datacenter) dt, .consul-policy-list > ul li:not(:first-child) dl:not(.datacenter) dt,

View File

@ -7,7 +7,8 @@
typeof http.body.Namespace !== 'undefined' ? http.body.Namespace : 'default' typeof http.body.Namespace !== 'undefined' ? http.body.Namespace : 'default'
}", }",
"Node":"node-1", "Node":"node-1",
"Checks":["serfHealth"], "NodeChecks":["serfHealth"],
"ServiceChecks": ["${fake.hacker.noun()}Health"],
"LockDelay":15000000000, "LockDelay":15000000000,
"Behavior":"${fake.helpers.randomize(['release', 'delete'])}", "Behavior":"${fake.helpers.randomize(['release', 'delete'])}",
"TTL":"", "TTL":"",

View File

@ -19,7 +19,8 @@ ${typeof location.search.ns !== 'undefined' ? `
"Namespace": "${location.search.ns}", "Namespace": "${location.search.ns}",
` : ``} ` : ``}
"Node":"${location.pathname.get(3)}", "Node":"${location.pathname.get(3)}",
"Checks":["serfHealth"], "NodeChecks":["serfHealth"],
"ServiceChecks": ["${fake.hacker.noun()}Health"],
"LockDelay":15000000000, "LockDelay":15000000000,
"Behavior":"${fake.helpers.randomize(['release', 'delete'])}", "Behavior":"${fake.helpers.randomize(['release', 'delete'])}",
"TTL":"", "TTL":"",