Prettify peers.index template

pull/15156/head
Michael Klein 2022-10-26 11:15:06 +02:00
parent 44c7614b3b
commit 63a2d5a1f5
1 changed files with 191 additions and 195 deletions

View File

@ -1,235 +1,231 @@
<Route <Route @name={{routeName}} as |route|>
@name={{routeName}}
as |route|>
<DataLoader <DataLoader
@src={{ @src={{uri
uri '/${partition}/${nspace}/${dc}/peers' "/${partition}/${nspace}/${dc}/peers"
(hash (hash
partition=route.params.partition partition=route.params.partition
nspace=route.params.nspace nspace=route.params.nspace
dc=route.params.dc dc=route.params.dc
)}} )
as |loader|> }}
as |loader|
>
<BlockSlot @name="error"> <BlockSlot @name="error">
<AppError <AppError @error={{loader.error}} @login={{route.model.app.login.open}} />
@error={{loader.error}}
@login={{route.model.app.login.open}}
/>
</BlockSlot> </BlockSlot>
<BlockSlot @name="loaded"> <BlockSlot @name="loaded">
{{#let {{#let
(hash
(hash value=(or sortBy "State:asc")
value=(or sortBy "State:asc") change=(action (mut sortBy) value="target.selected")
change=(action (mut sortBy) value="target.selected") )
) (hash
state=(hash
(hash value=(if state (split state ",") undefined)
state=(hash change=(action (mut state) value="target.selectedItems")
value=(if state (split state ',') undefined)
change=(action (mut state) value="target.selectedItems")
)
searchproperty=(hash
value=(if (not-eq searchproperty undefined)
(split searchproperty ',')
searchProperties
)
change=(action (mut searchproperty) value="target.selectedItems")
default=searchProperties
)
)
loader.data
as |sort filters items|}}
<AppView>
<BlockSlot @name="header">
<h1>
<route.Title
@title="Peers"
/>
</h1>
</BlockSlot>
<BlockSlot @name="toolbar">
{{#if (gt items.length 0)}}
<Consul::Peer::SearchBar
@search={{search}}
@onsearch={{action (mut search) value="target.value"}}
@sort={{sort}}
@filter={{filters}}
/>
{{/if}}
</BlockSlot>
<BlockSlot @name="actions">
<ModalDialog
@aria={{hash
label="Add peer connection"
}}
class="peer-create-modal"
as |modal|>
<BlockSlot @name="header">
{{did-insert (set this 'create' modal)}}
<h2>
Add peer connection
</h2>
</BlockSlot>
<BlockSlot @name="body">
{{#if modal.opened}}
<Consul::Peer::Form
@params={{route.params}}
as |form|>
<form.Form
@onchange={{loader.invalidate}}
@onsubmit={{modal.close}}
as |form|>
{{did-insert (set this 'form' form)}}
<form.Fieldsets />
</form.Form>
</Consul::Peer::Form>
{{/if}}
</BlockSlot>
<BlockSlot @name="actions">
<this.form.Actions
@onclose={{this.create.close}}
/>
</BlockSlot>
</ModalDialog>
<Action
data-test-create
class="type-create"
{{on "click" (optional this.create.open)}}
>
Add peer connection
</Action>
</BlockSlot>
<BlockSlot @name="content">
<DataWriter
@sink={{uri '/${partition}/${dc}/${nspace}/peer/'
(hash
partition=route.params.partition
nspace=route.params.nspace
dc=route.params.dc
) )
}} searchproperty=(hash
@type="peer" value=(if
@label="Peer" (not-eq searchproperty undefined)
as |writer|> (split searchproperty ",")
searchProperties
)
change=(action (mut searchproperty) value="target.selectedItems")
default=searchProperties
)
)
loader.data
as |sort filters items|
}}
<AppView>
<BlockSlot @name="header">
<h1>
<route.Title @title="Peers" />
</h1>
</BlockSlot>
<BlockSlot @name="toolbar">
<BlockSlot @name="removed" as |after|> {{#if (gt items.length 0)}}
<Consul::Peer::Notifications <Consul::Peer::SearchBar
{{notification @search={{search}}
after=(action after) @onsearch={{action (mut search) value="target.value"}}
}} @sort={{sort}}
@type="remove" @filter={{filters}}
/> />
</BlockSlot> {{/if}}
<BlockSlot @name="content">
</BlockSlot>
<BlockSlot @name="actions">
<ModalDialog <ModalDialog
@aria={{hash @aria={{hash label="Add peer connection"}}
label="Regenerate token" class="peer-create-modal"
}} as |modal|
@onclose={{set this 'item' undefined}} >
as |modal|>
<BlockSlot @name="header"> <BlockSlot @name="header">
{{did-insert (set this 'regenerate' modal)}} {{did-insert (set this "create" modal)}}
<h2> <h2>
Regenerate token Add peer connection
</h2> </h2>
</BlockSlot> </BlockSlot>
<BlockSlot @name="body"> <BlockSlot @name="body">
{{#if this.item}}
<Consul::Peer::Form::Generate {{#if modal.opened}}
@item={{this.item}} <Consul::Peer::Form @params={{route.params}} as |form|>
@onchange={{loader.invalidate}} <form.Form
@regenerate={{true}} @onchange={{loader.invalidate}}
as |form|> @onsubmit={{modal.close}}
{{did-insert (set this 'regenerateForm' form)}} as |form|
<form.Fieldsets /> >
</Consul::Peer::Form::Generate> {{did-insert (set this "form" form)}}
<form.Fieldsets />
</form.Form>
</Consul::Peer::Form>
{{/if}} {{/if}}
</BlockSlot> </BlockSlot>
<BlockSlot @name="actions"> <BlockSlot @name="actions">
<this.regenerateForm.Actions <this.form.Actions @onclose={{this.create.close}} />
@onclose={{this.regenerate.close}}
/>
</BlockSlot> </BlockSlot>
</ModalDialog> </ModalDialog>
<Action
data-test-create
class="type-create"
{{on "click" (optional this.create.open)}}
>
Add peer connection
</Action>
<DataCollection </BlockSlot>
<BlockSlot @name="content">
<DataWriter
@sink={{uri
"/${partition}/${dc}/${nspace}/peer/"
(hash
partition=route.params.partition
nspace=route.params.nspace
dc=route.params.dc
)
}}
@type="peer" @type="peer"
@sort={{sort.value}} @label="Peer"
@filters={{filters}} as |writer|
@search={{search}} >
@items={{items}}
as |collection|>
<collection.Collection>
<Consul::Peer::List <BlockSlot @name="removed" as |after|>
@items={{collection.items}} <Consul::Peer::Notifications
@onedit={{queue {{notification after=(action after)}}
(set this 'item') @type="remove"
this.regenerate.open
}}
@ondelete={{writer.delete}}
/> />
</BlockSlot>
<BlockSlot @name="content">
</collection.Collection> <ModalDialog
<collection.Empty> @aria={{hash label="Regenerate token"}}
{{!-- TODO: do we need to check permissions here or will we receive an error automatically? --}} @onclose={{set this "item" undefined}}
<EmptyState as |modal|
@login={{route.model.app.login.open}}
> >
<BlockSlot @name="header"> <BlockSlot @name="header">
{{did-insert (set this "regenerate" modal)}}
<h2> <h2>
{{t 'routes.dc.peers.index.empty.header' Regenerate token
items=items.length
}}
</h2> </h2>
</BlockSlot> </BlockSlot>
<BlockSlot @name="body"> <BlockSlot @name="body">
<p> {{#if this.item}}
{{t 'routes.dc.peers.index.empty.body' <Consul::Peer::Form::Generate
items=items.length @item={{this.item}}
canUsePartitions=(can "use partitions") @onchange={{loader.invalidate}}
canUseACLs=(can "use acls") @regenerate={{true}}
htmlSafe=true as |form|
}} >
</p> {{did-insert (set this "regenerateForm" form)}}
<form.Fieldsets />
</Consul::Peer::Form::Generate>
{{/if}}
</BlockSlot> </BlockSlot>
<BlockSlot @name="actions"> <BlockSlot @name="actions">
<li class="docs-link"> <this.regenerateForm.Actions
{{!-- what's the docs for peering?--}} @onclose={{this.regenerate.close}}
<a href="{{env 'CONSUL_DOCS_URL'}}/connect/cluster-peering" rel="noopener noreferrer" target="_blank"> />
Documentation on Peers
</a>
</li>
<li class="learn-link">
<a href="{{env "CONSUL_DOCS_URL"}}/connect/cluster-peering/create-manage-peering" rel="noopener noreferrer" target="_blank">
Take the tutorial
</a>
</li>
</BlockSlot> </BlockSlot>
</EmptyState> </ModalDialog>
</collection.Empty>
</DataCollection> <DataCollection
</BlockSlot> @type="peer"
</DataWriter> @sort={{sort.value}}
</BlockSlot> @filters={{filters}}
</AppView> @search={{search}}
{{/let}} @items={{items}}
as |collection|
>
<collection.Collection>
<Consul::Peer::List
@items={{collection.items}}
@onedit={{queue (set this "item") this.regenerate.open}}
@ondelete={{writer.delete}}
/>
</collection.Collection>
<collection.Empty>
{{! TODO: do we need to check permissions here or will we receive an error automatically? }}
<EmptyState @login={{route.model.app.login.open}}>
<BlockSlot @name="header">
<h2>
{{t
"routes.dc.peers.index.empty.header"
items=items.length
}}
</h2>
</BlockSlot>
<BlockSlot @name="body">
<p>
{{t
"routes.dc.peers.index.empty.body"
items=items.length
canUsePartitions=(can "use partitions")
canUseACLs=(can "use acls")
htmlSafe=true
}}
</p>
</BlockSlot>
<BlockSlot @name="actions">
<li class="docs-link">
{{! what's the docs for peering?}}
<a
href="{{env
'CONSUL_DOCS_URL'
}}/connect/cluster-peering"
rel="noopener noreferrer"
target="_blank"
>
Documentation on Peers
</a>
</li>
<li class="learn-link">
<a
href="{{env
'CONSUL_DOCS_URL'
}}/connect/cluster-peering/create-manage-peering"
rel="noopener noreferrer"
target="_blank"
>
Take the tutorial
</a>
</li>
</BlockSlot>
</EmptyState>
</collection.Empty>
</DataCollection>
</BlockSlot>
</DataWriter>
</BlockSlot>
</AppView>
{{/let}}
</BlockSlot> </BlockSlot>
</DataLoader> </DataLoader>
</Route> </Route>