open-consul/ui-v2/app/templates/dc/services/show/intentions/index.hbs

72 lines
2.5 KiB
Handlebars

<DataLoader @src={{uri nspace dc 'intentions' 'for-service' slug}} as |api|>
<BlockSlot @name="error">
<ErrorState @error={{api.error}} />
</BlockSlot>
<BlockSlot @name="loaded">
{{#let api.data as |items|}}
{{#let (hash
accesses=(if access (split access ',') undefined)
) as |filters|}}
{{#let (or sortBy "Action:asc") as |sort|}}
<div id="intentions" class="tab-section">
<div role="tabpanel">
<Portal @target="app-view-actions">
<a data-test-create href={{href-to 'dc.services.show.intentions.create'}} class="type-create">Create</a>
</Portal>
{{#if (gt items.length 0) }}
<ConsulIntentionSearchBar
@search={{search}}
@onsearch={{action (mut search) value="target.value"}}
@sort={{sort}}
@onsort={{action (mut sortBy) value="target.selected"}}
@filter={{filters}}
@onfilter={{hash
access=(action (mut access) value="target.selectedItems")
}}
/>
{{/if}}
{{#let (filter (filter-predicate 'intention' filters) items) as |filtered|}}
{{#let (sort-by (comparator 'intention' sort) filtered) as |sorted|}}
<ChangeableSet @dispatcher={{searchable 'intention' sorted}} @terms={{search}}>
<BlockSlot @name="content" as |searched|>
<Consul::Intention::List
@items={{searched}}
@ondelete={{refresh-route}}
@routeName="dc.services.show.intentions.edit"
>
<:idle as |list|>
{{#if (eq searched.length 1)}}
{{#let searched.firstObject as |item|}}
{{#if (eq search item.SourceName)}}
<list.Check @item={{item}} />
{{/if}}
{{/let}}
{{/if}}
<list.Table />
</:idle>
<:empty as |list|>
<EmptyState>
<BlockSlot @name="body">
<p>
There are no intentions {{if (gt items.length 0) 'found '}} for this service.
</p>
</BlockSlot>
</EmptyState>
</:empty>
</Consul::Intention::List>
</BlockSlot>
</ChangeableSet>
{{/let}}
{{/let}}
</div>
</div>
{{/let}}
{{/let}}
{{/let}}
</BlockSlot>
</DataLoader>