diff --git a/ui-v2/app/controllers/dc/intentions/edit.js b/ui-v2/app/controllers/dc/intentions/edit.js index e20c7eccb..df4bf8c53 100644 --- a/ui-v2/app/controllers/dc/intentions/edit.js +++ b/ui-v2/app/controllers/dc/intentions/edit.js @@ -33,6 +33,9 @@ export default Controller.extend({ createNewLabel: function(term) { return `Use a future Consul Service called '${term}'`; }, + isUnique: function(term) { + return !get(this, 'items').findBy('Name', term); + }, change: function(e, value, _target) { // normalize back to standard event const target = e.target || { ..._target, ...{ name: e, value: value } }; diff --git a/ui-v2/app/templates/dc/intentions/-form.hbs b/ui-v2/app/templates/dc/intentions/-form.hbs index 37347b121..739b21220 100644 --- a/ui-v2/app/templates/dc/intentions/-form.hbs +++ b/ui-v2/app/templates/dc/intentions/-form.hbs @@ -8,6 +8,7 @@ selected=SourceName searchPlaceholder='Type service name' buildSuggestion=(action 'createNewLabel') + showCreateWhen=(action "isUnique") oncreate=(action 'change' 'SourceName') onchange=(action 'change' 'SourceName') as |service search| }} @@ -27,6 +28,7 @@ selected=DestinationName searchPlaceholder='Type service name' buildSuggestion=(action 'createNewLabel') + showCreateWhen=(action "isUnique") oncreate=(action 'change' 'DestinationName') onchange=(action 'change' 'DestinationName') as |service| }}