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) {
|
createNewLabel: function(term) {
|
||||||
return `Use a future Consul Service called '${term}'`;
|
return `Use a future Consul Service called '${term}'`;
|
||||||
},
|
},
|
||||||
|
isUnique: function(term) {
|
||||||
|
return !get(this, 'items').findBy('Name', term);
|
||||||
|
},
|
||||||
change: function(e, value, _target) {
|
change: function(e, value, _target) {
|
||||||
// normalize back to standard event
|
// normalize back to standard event
|
||||||
const target = e.target || { ..._target, ...{ name: e, value: value } };
|
const target = e.target || { ..._target, ...{ name: e, value: value } };
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
selected=SourceName
|
selected=SourceName
|
||||||
searchPlaceholder='Type service name'
|
searchPlaceholder='Type service name'
|
||||||
buildSuggestion=(action 'createNewLabel')
|
buildSuggestion=(action 'createNewLabel')
|
||||||
|
showCreateWhen=(action "isUnique")
|
||||||
oncreate=(action 'change' 'SourceName')
|
oncreate=(action 'change' 'SourceName')
|
||||||
onchange=(action 'change' 'SourceName') as |service search|
|
onchange=(action 'change' 'SourceName') as |service search|
|
||||||
}}
|
}}
|
||||||
|
@ -27,6 +28,7 @@
|
||||||
selected=DestinationName
|
selected=DestinationName
|
||||||
searchPlaceholder='Type service name'
|
searchPlaceholder='Type service name'
|
||||||
buildSuggestion=(action 'createNewLabel')
|
buildSuggestion=(action 'createNewLabel')
|
||||||
|
showCreateWhen=(action "isUnique")
|
||||||
oncreate=(action 'change' 'DestinationName')
|
oncreate=(action 'change' 'DestinationName')
|
||||||
onchange=(action 'change' 'DestinationName') as |service|
|
onchange=(action 'change' 'DestinationName') as |service|
|
||||||
}}
|
}}
|
||||||
|
|
Loading…
Reference in New Issue