-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport of ui: Add ServerExternalAddresses to peer token create form…
… into release/1.14.x (#15620) * backport of commit ea23bac * backport of commit a4d1535 * backport of commit f782c16 * backport of commit 198eb09 * backport of commit 38c0e32 * backport of commit b388266 Co-authored-by: wenincode <tyler.wendlandt@hashicorp.com>
- Loading branch information
1 parent
18dffc5
commit 13836d5
Showing
10 changed files
with
161 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:feature | ||
ui: Add field for fallback server addresses to peer token generation form | ||
``` |
52 changes: 34 additions & 18 deletions
52
ui/packages/consul-peerings/app/components/consul/peer/form/generate/fieldsets/index.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
ui/packages/consul-peerings/app/components/consul/peer/form/generate/fieldsets/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Component from '@glimmer/component'; | ||
import { action } from '@ember/object'; | ||
|
||
export default class PeerGenerateFieldSets extends Component { | ||
@action | ||
onInput(addresses) { | ||
if (addresses) { | ||
addresses = addresses.split(',').map(address => address.trim()); | ||
} else { | ||
addresses = []; | ||
} | ||
|
||
this.args.item.ServerExternalAddresses = addresses; | ||
} | ||
} |
145 changes: 69 additions & 76 deletions
145
ui/packages/consul-peerings/app/components/consul/peer/form/generate/index.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,81 @@ | ||
<div | ||
class={{class-map | ||
'consul-peer-form-generate' | ||
}} | ||
...attributes | ||
> | ||
<div class={{class-map "consul-peer-form-generate"}} ...attributes> | ||
<StateMachine | ||
@src={{require './chart.xstate' from="/components/consul/peer/form/generate"}} | ||
@initial={{if @regenerate 'loading' 'idle'}} | ||
as |fsm|> | ||
@src={{require | ||
"./chart.xstate" | ||
from="/components/consul/peer/form/generate" | ||
}} | ||
@initial={{if @regenerate "loading" "idle"}} | ||
as |fsm| | ||
> | ||
|
||
{{#let | ||
(unique-id) | ||
as |id reset|}} | ||
<form | ||
{{on 'submit' (fn fsm.dispatch 'LOAD')}} | ||
id={{id}} | ||
> | ||
{{#let (unique-id) as |id reset|}} | ||
<form {{on "submit" (fn fsm.dispatch "LOAD")}} id={{id}}> | ||
|
||
<fsm.State @matches={{array 'idle' 'error'}}> | ||
<fsm.State @matches={{'error'}}> | ||
<Notice | ||
@type="error" | ||
role="alert" | ||
as |notice|> | ||
<notice.Body> | ||
<p> | ||
<strong>Error</strong><br /> | ||
{{fsm.state.context.error.message}} | ||
</p> | ||
</notice.Body> | ||
</Notice> | ||
</fsm.State> | ||
{{yield (hash | ||
Fieldsets=(component "consul/peer/form/generate/fieldsets" | ||
item=@item | ||
) | ||
Actions=(component "consul/peer/form/generate/actions" | ||
item=@item | ||
id=id | ||
) | ||
)}} | ||
</fsm.State> | ||
|
||
<fsm.State @matches={{'loading'}}> | ||
<DataSource | ||
@src={{uri '/${partition}/${nspace}/${dc}/peering/token-for/${name}' | ||
<fsm.State @matches={{array "idle" "error"}}> | ||
<fsm.State @matches={{"error"}}> | ||
<Notice @type="error" role="alert" as |notice|> | ||
<notice.Body> | ||
<p> | ||
<strong>Error</strong><br /> | ||
{{fsm.state.context.error.message}} | ||
</p> | ||
</notice.Body> | ||
</Notice> | ||
</fsm.State> | ||
{{yield | ||
(hash | ||
partition=@item.Partition | ||
nspace='' | ||
dc=@item.Datacenter | ||
name=@item.Name | ||
Fieldsets=(component | ||
"consul/peer/form/generate/fieldsets" item=@item | ||
) | ||
Actions=(component | ||
"consul/peer/form/generate/actions" item=@item id=id | ||
) | ||
) | ||
}} | ||
@onchange={{queue | ||
@onchange | ||
(pick 'data' (fn fsm.dispatch 'SUCCESS')) | ||
}} | ||
@onerror={{queue | ||
(fn fsm.dispatch 'ERROR') | ||
}} | ||
/> | ||
</fsm.State> | ||
</fsm.State> | ||
|
||
<fsm.State @matches={{'success'}}> | ||
{{yield (hash | ||
Fieldsets=(component "consul/peer/form/token/fieldsets" | ||
item=@item | ||
token=fsm.state.context.PeeringToken | ||
regenerate=@regenerate | ||
onclick=(queue | ||
(set @item 'Name' '') | ||
(fn fsm.dispatch 'RESET') | ||
<fsm.State @matches={{"loading"}}> | ||
<DataSource | ||
@src={{uri | ||
"/${partition}/${nspace}/${dc}/peering/token-for/${name}/${externalAddresses}" | ||
(hash | ||
partition=@item.Partition | ||
nspace="" | ||
dc=@item.Datacenter | ||
name=@item.Name | ||
externalAddresses=@item.ServerExternalAddresses | ||
) | ||
}} | ||
@onchange={{queue | ||
@onchange | ||
(pick "data" (fn fsm.dispatch "SUCCESS")) | ||
}} | ||
@onerror={{queue (fn fsm.dispatch "ERROR")}} | ||
/> | ||
</fsm.State> | ||
|
||
<fsm.State @matches={{"success"}}> | ||
{{yield | ||
(hash | ||
Fieldsets=(component | ||
"consul/peer/form/token/fieldsets" | ||
item=@item | ||
token=fsm.state.context.PeeringToken | ||
regenerate=@regenerate | ||
onclick=(queue (set @item "Name" "") (fn fsm.dispatch "RESET")) | ||
) | ||
Actions=(component | ||
"consul/peer/form/token/actions" | ||
token=fsm.state.context.PeeringToken | ||
item=@item | ||
id=id | ||
) | ||
) | ||
) | ||
Actions=(component "consul/peer/form/token/actions" | ||
token=fsm.state.context.PeeringToken | ||
item=@item | ||
id=id | ||
) | ||
)}} | ||
</fsm.State> | ||
}} | ||
</fsm.State> | ||
|
||
</form> | ||
{{/let}} | ||
</form> | ||
{{/let}} | ||
|
||
</StateMachine> | ||
</div> |
53 changes: 20 additions & 33 deletions
53
ui/packages/consul-peerings/app/components/consul/peer/form/index.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,50 @@ | ||
<div | ||
class={{class-map | ||
'consul-peer-form' | ||
}} | ||
...attributes | ||
> | ||
<div class={{class-map "consul-peer-form"}} ...attributes> | ||
<StateMachine | ||
@src={{require './chart.xstate' from='/components/consul/peer/form'}} | ||
as |fsm|> | ||
@src={{require "./chart.xstate" from="/components/consul/peer/form"}} | ||
as |fsm| | ||
> | ||
|
||
<TabNav | ||
@items={{array | ||
(hash | ||
label='Generate token' | ||
selected=(state-matches fsm.state 'generate') | ||
label=(t "components.consul.peer.form.generate-label") | ||
selected=(state-matches fsm.state "generate") | ||
state="GENERATE" | ||
) | ||
(hash | ||
label='Establish peering' | ||
selected=(state-matches fsm.state 'initiate') | ||
label=(t "components.consul.peer.form.establish-label") | ||
selected=(state-matches fsm.state "initiate") | ||
state="INITIATE" | ||
) | ||
}} | ||
@onTabClicked={{pick 'state' fsm.dispatch}} | ||
@onTabClicked={{pick "state" fsm.dispatch}} | ||
/> | ||
|
||
<fsm.State @matches={{array 'generate'}}> | ||
<fsm.State @matches={{array "generate"}}> | ||
|
||
<DataSource | ||
@src={{uri '/${partition}/${nspace}/${dc}/peer-generate/' | ||
@params | ||
@src={{uri "/${partition}/${nspace}/${dc}/peer-generate/" @params}} | ||
as |source| | ||
> | ||
{{yield | ||
(hash Form=(component "consul/peer/form/generate" item=source.data)) | ||
}} | ||
as |source|> | ||
{{yield (hash | ||
Form=(component 'consul/peer/form/generate' | ||
item=source.data | ||
) | ||
) | ||
}} | ||
</DataSource> | ||
|
||
</fsm.State> | ||
|
||
<fsm.State @matches="initiate"> | ||
|
||
<DataSource | ||
@src={{uri '/${partition}/${nspace}/${dc}/peer-initiate/' | ||
@params | ||
@src={{uri "/${partition}/${nspace}/${dc}/peer-initiate/" @params}} | ||
as |source| | ||
> | ||
{{yield | ||
(hash Form=(component "consul/peer/form/initiate" item=source.data)) | ||
}} | ||
as |source|> | ||
{{yield (hash | ||
Form=(component 'consul/peer/form/initiate' | ||
item=source.data | ||
) | ||
) | ||
}} | ||
</DataSource> | ||
|
||
</fsm.State> | ||
|
||
|
||
</StateMachine> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.