Merge pull request #15156 from hashicorp/ui/peer-create-redirect-to-show
ui: peer create redirect to show
This commit is contained in:
commit
9d36db3a2a
|
@ -1,27 +1,20 @@
|
|||
<div
|
||||
class={{class-map
|
||||
'consul-peer-form-initiate'
|
||||
}}
|
||||
...attributes
|
||||
>
|
||||
<div class={{class-map "consul-peer-form-initiate"}} ...attributes>
|
||||
<DataWriter
|
||||
@sink={{uri
|
||||
'/${partition}/${nspace}/${dc}/peer'
|
||||
"/${partition}/${nspace}/${dc}/peer"
|
||||
(hash
|
||||
partition=(or @item.Partition '')
|
||||
nspace=(or @item.Namespace '')
|
||||
dc=(or @item.Datacenter '')
|
||||
partition=(or @item.Partition "")
|
||||
nspace=(or @item.Namespace "")
|
||||
dc=(or @item.Datacenter "")
|
||||
)
|
||||
}}
|
||||
@type={{'peer'}}
|
||||
@label={{'peer'}}
|
||||
@type={{"peer"}}
|
||||
@label={{"peer"}}
|
||||
@onchange={{fn (optional @onsubmit) @item}}
|
||||
as |writer|>
|
||||
as |writer|
|
||||
>
|
||||
<BlockSlot @name="error" as |after error|>
|
||||
<Notice
|
||||
@type="error"
|
||||
role="alert"
|
||||
as |notice|>
|
||||
<Notice @type="error" role="alert" as |notice|>
|
||||
<notice.Body>
|
||||
<p>
|
||||
<strong>Error</strong><br />
|
||||
|
@ -31,24 +24,20 @@
|
|||
</Notice>
|
||||
</BlockSlot>
|
||||
<BlockSlot @name="content">
|
||||
{{#let
|
||||
(unique-id)
|
||||
as |id|}}
|
||||
<form
|
||||
id={{id}}
|
||||
{{on 'submit' (fn writer.persist @item)}}
|
||||
>
|
||||
{{yield (hash
|
||||
Fieldsets=(component "consul/peer/form/initiate/fieldsets"
|
||||
item=@item
|
||||
{{#let (unique-id) as |id|}}
|
||||
<form id={{id}} {{on "submit" (fn writer.persist @item)}}>
|
||||
{{yield
|
||||
(hash
|
||||
Fieldsets=(component
|
||||
"consul/peer/form/initiate/fieldsets" item=@item
|
||||
)
|
||||
Actions=(component "consul/peer/form/initiate/actions"
|
||||
item=@item
|
||||
id=id
|
||||
Actions=(component
|
||||
"consul/peer/form/initiate/actions" item=@item id=id
|
||||
)
|
||||
)}}
|
||||
)
|
||||
}}
|
||||
</form>
|
||||
{{/let}}
|
||||
{{/let}}
|
||||
</BlockSlot>
|
||||
</DataWriter>
|
||||
</div>
|
|
@ -0,0 +1,12 @@
|
|||
import Controller from "@ember/controller";
|
||||
import { inject as service } from "@ember/service";
|
||||
|
||||
export default class DcPeersIndexController extends Controller {
|
||||
@service router;
|
||||
|
||||
redirectToPeerShow = (modalCloseFn, peerModel) => {
|
||||
modalCloseFn?.();
|
||||
|
||||
this.router.transitionTo("dc.peers.show", peerModel.Name);
|
||||
};
|
||||
}
|
|
@ -1,55 +1,48 @@
|
|||
<Route
|
||||
@name={{routeName}}
|
||||
as |route|>
|
||||
<Route @name={{routeName}} as |route|>
|
||||
<DataLoader
|
||||
@src={{
|
||||
uri '/${partition}/${nspace}/${dc}/peers'
|
||||
@src={{uri
|
||||
"/${partition}/${nspace}/${dc}/peers"
|
||||
(hash
|
||||
partition=route.params.partition
|
||||
nspace=route.params.nspace
|
||||
dc=route.params.dc
|
||||
)}}
|
||||
as |loader|>
|
||||
)
|
||||
}}
|
||||
as |loader|
|
||||
>
|
||||
|
||||
<BlockSlot @name="error">
|
||||
<AppError
|
||||
@error={{loader.error}}
|
||||
@login={{route.model.app.login.open}}
|
||||
/>
|
||||
<AppError @error={{loader.error}} @login={{route.model.app.login.open}} />
|
||||
</BlockSlot>
|
||||
|
||||
<BlockSlot @name="loaded">
|
||||
{{#let
|
||||
|
||||
{{#let
|
||||
(hash
|
||||
value=(or sortBy "State:asc")
|
||||
change=(action (mut sortBy) value="target.selected")
|
||||
)
|
||||
|
||||
(hash
|
||||
state=(hash
|
||||
value=(if state (split state ',') undefined)
|
||||
value=(if state (split state ",") undefined)
|
||||
change=(action (mut state) value="target.selectedItems")
|
||||
)
|
||||
searchproperty=(hash
|
||||
value=(if (not-eq searchproperty undefined)
|
||||
(split searchproperty ',')
|
||||
value=(if
|
||||
(not-eq searchproperty undefined)
|
||||
(split searchproperty ",")
|
||||
searchProperties
|
||||
)
|
||||
change=(action (mut searchproperty) value="target.selectedItems")
|
||||
default=searchProperties
|
||||
)
|
||||
)
|
||||
|
||||
loader.data
|
||||
|
||||
as |sort filters items|}}
|
||||
as |sort filters items|
|
||||
}}
|
||||
<AppView>
|
||||
<BlockSlot @name="header">
|
||||
<h1>
|
||||
<route.Title
|
||||
@title="Peers"
|
||||
/>
|
||||
<route.Title @title="Peers" />
|
||||
</h1>
|
||||
</BlockSlot>
|
||||
<BlockSlot @name="toolbar">
|
||||
|
@ -58,9 +51,7 @@ as |sort filters items|}}
|
|||
<Consul::Peer::SearchBar
|
||||
@search={{search}}
|
||||
@onsearch={{action (mut search) value="target.value"}}
|
||||
|
||||
@sort={{sort}}
|
||||
|
||||
@filter={{filters}}
|
||||
/>
|
||||
{{/if}}
|
||||
|
@ -68,15 +59,13 @@ as |sort filters items|}}
|
|||
</BlockSlot>
|
||||
<BlockSlot @name="actions">
|
||||
|
||||
|
||||
<ModalDialog
|
||||
@aria={{hash
|
||||
label="Add peer connection"
|
||||
}}
|
||||
@aria={{hash label="Add peer connection"}}
|
||||
class="peer-create-modal"
|
||||
as |modal|>
|
||||
as |modal|
|
||||
>
|
||||
<BlockSlot @name="header">
|
||||
{{did-insert (set this 'create' modal)}}
|
||||
{{did-insert (set this "create" modal)}}
|
||||
<h2>
|
||||
Add peer connection
|
||||
</h2>
|
||||
|
@ -84,14 +73,13 @@ as |sort filters items|}}
|
|||
<BlockSlot @name="body">
|
||||
|
||||
{{#if modal.opened}}
|
||||
<Consul::Peer::Form
|
||||
@params={{route.params}}
|
||||
as |form|>
|
||||
<Consul::Peer::Form @params={{route.params}} as |form|>
|
||||
<form.Form
|
||||
@onchange={{loader.invalidate}}
|
||||
@onsubmit={{modal.close}}
|
||||
as |form|>
|
||||
{{did-insert (set this 'form' form)}}
|
||||
@onsubmit={{fn this.redirectToPeerShow modal.close}}
|
||||
as |form|
|
||||
>
|
||||
{{did-insert (set this "form" form)}}
|
||||
<form.Fieldsets />
|
||||
</form.Form>
|
||||
</Consul::Peer::Form>
|
||||
|
@ -99,9 +87,7 @@ as |sort filters items|}}
|
|||
|
||||
</BlockSlot>
|
||||
<BlockSlot @name="actions">
|
||||
<this.form.Actions
|
||||
@onclose={{this.create.close}}
|
||||
/>
|
||||
<this.form.Actions @onclose={{this.create.close}} />
|
||||
</BlockSlot>
|
||||
</ModalDialog>
|
||||
<Action
|
||||
|
@ -116,7 +102,8 @@ as |sort filters items|}}
|
|||
<BlockSlot @name="content">
|
||||
|
||||
<DataWriter
|
||||
@sink={{uri '/${partition}/${dc}/${nspace}/peer/'
|
||||
@sink={{uri
|
||||
"/${partition}/${dc}/${nspace}/peer/"
|
||||
(hash
|
||||
partition=route.params.partition
|
||||
nspace=route.params.nspace
|
||||
|
@ -125,26 +112,24 @@ as |sort filters items|}}
|
|||
}}
|
||||
@type="peer"
|
||||
@label="Peer"
|
||||
as |writer|>
|
||||
as |writer|
|
||||
>
|
||||
|
||||
<BlockSlot @name="removed" as |after|>
|
||||
<Consul::Peer::Notifications
|
||||
{{notification
|
||||
after=(action after)
|
||||
}}
|
||||
{{notification after=(action after)}}
|
||||
@type="remove"
|
||||
/>
|
||||
</BlockSlot>
|
||||
<BlockSlot @name="content">
|
||||
|
||||
<ModalDialog
|
||||
@aria={{hash
|
||||
label="Regenerate token"
|
||||
}}
|
||||
@onclose={{set this 'item' undefined}}
|
||||
as |modal|>
|
||||
@aria={{hash label="Regenerate token"}}
|
||||
@onclose={{set this "item" undefined}}
|
||||
as |modal|
|
||||
>
|
||||
<BlockSlot @name="header">
|
||||
{{did-insert (set this 'regenerate' modal)}}
|
||||
{{did-insert (set this "regenerate" modal)}}
|
||||
<h2>
|
||||
Regenerate token
|
||||
</h2>
|
||||
|
@ -155,8 +140,9 @@ as |sort filters items|}}
|
|||
@item={{this.item}}
|
||||
@onchange={{loader.invalidate}}
|
||||
@regenerate={{true}}
|
||||
as |form|>
|
||||
{{did-insert (set this 'regenerateForm' form)}}
|
||||
as |form|
|
||||
>
|
||||
{{did-insert (set this "regenerateForm" form)}}
|
||||
<form.Fieldsets />
|
||||
</Consul::Peer::Form::Generate>
|
||||
{{/if}}
|
||||
|
@ -174,34 +160,32 @@ as |sort filters items|}}
|
|||
@filters={{filters}}
|
||||
@search={{search}}
|
||||
@items={{items}}
|
||||
as |collection|>
|
||||
as |collection|
|
||||
>
|
||||
<collection.Collection>
|
||||
|
||||
<Consul::Peer::List
|
||||
@items={{collection.items}}
|
||||
@onedit={{queue
|
||||
(set this 'item')
|
||||
this.regenerate.open
|
||||
}}
|
||||
@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}}
|
||||
>
|
||||
{{! 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'
|
||||
{{t
|
||||
"routes.dc.peers.index.empty.header"
|
||||
items=items.length
|
||||
}}
|
||||
</h2>
|
||||
</BlockSlot>
|
||||
<BlockSlot @name="body">
|
||||
<p>
|
||||
{{t 'routes.dc.peers.index.empty.body'
|
||||
{{t
|
||||
"routes.dc.peers.index.empty.body"
|
||||
items=items.length
|
||||
canUsePartitions=(can "use partitions")
|
||||
canUseACLs=(can "use acls")
|
||||
|
@ -211,13 +195,25 @@ as |sort filters items|}}
|
|||
</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">
|
||||
{{! 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">
|
||||
<a
|
||||
href="{{env
|
||||
'CONSUL_DOCS_URL'
|
||||
}}/connect/cluster-peering/create-manage-peering"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
Take the tutorial
|
||||
</a>
|
||||
</li>
|
||||
|
@ -229,7 +225,7 @@ as |sort filters items|}}
|
|||
</DataWriter>
|
||||
</BlockSlot>
|
||||
</AppView>
|
||||
{{/let}}
|
||||
{{/let}}
|
||||
</BlockSlot>
|
||||
</DataLoader>
|
||||
</Route>
|
|
@ -28,3 +28,4 @@ Feature: dc / peers / establish: Peer Establish Peering
|
|||
---
|
||||
And "[data-notification]" has the "notification-update" class
|
||||
And "[data-notification]" has the "success" class
|
||||
And the url should be /dc-1/peers/new-peer/imported-services
|
||||
|
|
Loading…
Reference in New Issue