open-consul/ui-v2/app/templates/dc/kv/edit.hbs
John Cowen d1fea9ec0a
UI: Simplify/refactor the actions/notification layer (#4572) + (#4573)
* Move notification texts to a slightly different layer (#4572)
* Further Simplify/refactor the actions/notification layer (#4573)

1. Move the 'with-feedback' actions to a 'with-blocking-action' mixin
which better describes what it does
2. Additional set of unit tests almost over the entire layer to prove
things work/add confidence for further changes

The multiple 'with-action' mixins used for every 'index/edit' combo are
now reduced down to only contain the functionality related to their
specific routes, i.e. where to redirect.

The actual functionality to block and carry out the action and then
notify are 'almost' split out so that their respective classes/objects do
one thing and one thing 'well'.

Mixins are chosen for the moment as the decoration approach used by
mixins feels better than multiple levels of inheritence, but I would
like to take this fuether in the future to a 'compositional' based
approach.

There is still possible further work to be done here, but I'm a lot
happier now this is reduced down into separate parts.
2018-08-29 19:14:31 +01:00

73 lines
3.3 KiB
Handlebars

{{#app-view class="kv edit" loading=isLoading}}
{{#block-slot 'notification' as |status type|}}
{{partial 'dc/kv/notifications'}}
{{/block-slot}}
{{#block-slot 'breadcrumbs'}}
<ol>
<li><a data-test-back href={{href-to 'dc.kv.index'}}>Key / Values</a></li>
{{#if (not-eq parent.Key '/') }}
{{#each (slice 0 -1 (split parent.Key '/')) as |breadcrumb index|}}
<li><a href={{href-to 'dc.kv.folder' (join '/' (append (slice 0 (add index 1) (split parent.Key '/')) ''))}}>{{breadcrumb}}</a></li>
{{/each}}
{{/if}}
</ol>
{{/block-slot}}
{{#block-slot 'header'}}
<h1>
{{#if item.Key }}
{{left-trim item.Key parent.Key }}
{{else}}
New Key / Value
{{/if}}
</h1>
{{/block-slot}}
{{#block-slot 'content'}}
{{#if session}}
<p class="notice warning"><strong>Warning.</strong> This KV has a lock session. You can edit KV's with lock sessions, but we recommend doing so with care, or not doing so at all. It may negatively impact the active node it's associated with. See below for more details on the Lock Session and see <a href="{{env 'CONSUL_DOCUMENTATION_URL'}}/internals/sessions.html" target="_blank" rel="noopener noreferrer">our documentation</a> for more information.</p>
{{/if}}
{{partial 'dc/kv/form'}}
{{#if session}}
<div data-test-session>
<h2><a href="{{env 'CONSUL_DOCUMENTATION_URL'}}/internals/sessions.html#session-design" rel="help noopener noreferrer" target="_blank">Lock Session</a></h2>
<dl>
<dt>Name</dt>
<dd>{{session.Name}}</dd>
<dt>Agent</dt>
<dd>
<a href={{href-to 'dc.nodes.show' session.Node }}>{{session.Node}}</a>
</dd>
<dt>ID</dt>
<dd>{{session.ID}}</dd>
<dt>Behavior</dt>
<dd><{{session.Behavior}}/dd>
{{#if session.Delay }}
<dt>Delay</dt>
<dd><{{session.LockDelay}}/dd>
{{/if}}
{{#if session.TTL }}
<dt>TTL</dt>
<dd>{{session.TTL}}</dd>
{{/if}}
{{#if (gt session.Checks.length 0)}}
<dt>Health Checks</dt>
<dd>
{{ join ', ' session.Checks}}
</dd>
{{/if}}
</dl>
{{#confirmation-dialog message='Are you sure you want to invalidate this session?'}}
{{#block-slot 'action' as |confirm|}}
<button type="button" data-test-delete class="type-delete" {{ action confirm "invalidateSession" session }}>Invalidate Session</button>
{{/block-slot}}
{{#block-slot 'dialog' as |execute cancel message|}}
<p>
{{message}}
</p>
<button type="button" class="type-delete" {{action execute}}>Confirm Invalidation</button>
<button type="button" class="type-cancel" {{action cancel}}>Cancel</button>
{{/block-slot}}
{{/confirmation-dialog}}
</div>
{{/if}}
{{/block-slot}}
{{/app-view}}