diff --git a/ui-v2/app/controllers/dc/intentions/edit.js b/ui-v2/app/controllers/dc/intentions/edit.js index ad433645a8..8ddf30981f 100644 --- a/ui-v2/app/controllers/dc/intentions/edit.js +++ b/ui-v2/app/controllers/dc/intentions/edit.js @@ -18,18 +18,31 @@ export default Controller.extend({ }); }, actions: { + createNewLabel: function(term) { + return `Use a future Consul Service called '${term}'`; + }, change: function(e, value, _target) { // normalize back to standard event const target = e.target || { ..._target, ...{ name: e, value: value } }; switch (target.name) { case 'Action': set(this.changeset, target.name, target.value); - console.log(target.name, target.value, get(this.changeset, target.name)); break; case 'SourceName': case 'DestinationName': - set(this.changeset, target.name, get(target.value, 'Name')); - set(this, target.name, target.value); + let name = target.value; + let selected = target.value; + if (typeof name !== 'string') { + name = get(target.value, 'Name'); + } + const match = get(this, 'items').filterBy('Name', name); + if (match.length === 0) { + selected = { Name: name }; + const items = [selected].concat(this.items.toArray()); + set(this, 'items', items); + } + set(this.changeset, target.name, name); + set(this, target.name, selected); break; } }, diff --git a/ui-v2/app/routes/dc/intentions/create.js b/ui-v2/app/routes/dc/intentions/create.js index db467b16cb..0d6bc72989 100644 --- a/ui-v2/app/routes/dc/intentions/create.js +++ b/ui-v2/app/routes/dc/intentions/create.js @@ -20,6 +20,13 @@ export default Route.extend(WithIntentionActions, { item: this.item, items: get(this, 'servicesRepo').findAllByDatacenter(this.modelFor('dc').dc.Name), intents: ['allow', 'deny'], + }).then(function(model) { + return { + ...model, + ...{ + items: [{ Name: '*' }].concat(model.items.toArray()), + }, + }; }); }, setupController: function(controller, model) { diff --git a/ui-v2/app/routes/dc/intentions/edit.js b/ui-v2/app/routes/dc/intentions/edit.js index 12bd62a263..49c30e6aba 100644 --- a/ui-v2/app/routes/dc/intentions/edit.js +++ b/ui-v2/app/routes/dc/intentions/edit.js @@ -14,6 +14,13 @@ export default Route.extend(WithAclActions, { item: get(this, 'repo').findBySlug(params.id, this.modelFor('dc').dc.Name), items: get(this, 'servicesRepo').findAllByDatacenter(this.modelFor('dc').dc.Name), intents: ['allow', 'deny'], + }).then(function(model) { + return { + ...model, + ...{ + items: [{ Name: '*' }].concat(model.items.toArray()), + }, + }; }); }, setupController: function(controller, model) { diff --git a/ui-v2/app/templates/dc/intentions/-form.hbs b/ui-v2/app/templates/dc/intentions/-form.hbs index 47cff7f6ee..37347b1212 100644 --- a/ui-v2/app/templates/dc/intentions/-form.hbs +++ b/ui-v2/app/templates/dc/intentions/-form.hbs @@ -2,28 +2,40 @@