Only offer to create a future service if the name doesn't already exist
This commit is contained in:
parent
f914a760fc
commit
1c4b1ee798
|
@ -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 } };
|
||||
|
|
|
@ -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|
|
||||
}}
|
||||
|
|
Loading…
Reference in New Issue