From ea23bac1fb7258074aad2a090ff5c1633fbfafd5 Mon Sep 17 00:00:00 2001 From: wenincode Date: Thu, 24 Nov 2022 15:06:01 -0700 Subject: [PATCH] ui: Add ServerExternalAddresses field to token generation --- .../peer/form/generate/fieldsets/index.hbs | 21 +++++++++++++++++++ .../peer/form/generate/fieldsets/index.js | 15 +++++++++++++ .../consul/peer/form/generate/index.hbs | 3 ++- ui/packages/consul-ui/app/models/peer.js | 2 ++ .../consul-ui/app/services/repository/peer.js | 8 +++++-- .../consul-ui/translations/common/en-us.yaml | 4 ++++ 6 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 ui/packages/consul-peerings/app/components/consul/peer/form/generate/fieldsets/index.js diff --git a/ui/packages/consul-peerings/app/components/consul/peer/form/generate/fieldsets/index.hbs b/ui/packages/consul-peerings/app/components/consul/peer/form/generate/fieldsets/index.hbs index f6fd4fcbc0..3c1a72ff24 100644 --- a/ui/packages/consul-peerings/app/components/consul/peer/form/generate/fieldsets/index.hbs +++ b/ui/packages/consul-peerings/app/components/consul/peer/form/generate/fieldsets/index.hbs @@ -36,5 +36,26 @@ {{/let}} + + {{#let + (hash + help=(t 'common.validations.server-external-addresses.help') + ) + as |ServerExternalAddresses|}} +
+ + {{yield (hash + valid=(not (state-matches fsm.state 'error')) + )}} +
+ + {{/let}} diff --git a/ui/packages/consul-peerings/app/components/consul/peer/form/generate/fieldsets/index.js b/ui/packages/consul-peerings/app/components/consul/peer/form/generate/fieldsets/index.js new file mode 100644 index 0000000000..ea90d94060 --- /dev/null +++ b/ui/packages/consul-peerings/app/components/consul/peer/form/generate/fieldsets/index.js @@ -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; + } +} diff --git a/ui/packages/consul-peerings/app/components/consul/peer/form/generate/index.hbs b/ui/packages/consul-peerings/app/components/consul/peer/form/generate/index.hbs index 0e4e63a658..2d9c160262 100644 --- a/ui/packages/consul-peerings/app/components/consul/peer/form/generate/index.hbs +++ b/ui/packages/consul-peerings/app/components/consul/peer/form/generate/index.hbs @@ -44,12 +44,13 @@ 0 ? externalAddresses.split(',') : []; + return ( await request` POST /v1/peering/token @@ -53,6 +56,7 @@ export default class PeerService extends RepositoryService { ${{ PeerName: name, Partition: partition || undefined, + ServerExternalAddresses, }} ` )((headers, body, cache) => body); diff --git a/ui/packages/consul-ui/translations/common/en-us.yaml b/ui/packages/consul-ui/translations/common/en-us.yaml index 8fce904302..04ce5ae95d 100644 --- a/ui/packages/consul-ui/translations/common/en-us.yaml +++ b/ui/packages/consul-ui/translations/common/en-us.yaml @@ -81,4 +81,8 @@ validations: error: "{name} must be a valid DNS hostname." immutable: help: Once created, this cannot be changed. + server-external-addresses: + help: | + Enter a fallback server address for this peer to be used in the event of failed automatic updates. This field is required for HCP-managed clusters. + test: "^$|^[a-zA-Z0-9]([a-zA-Z0-9-]'{0,62}'[a-zA-Z0-9])?$"