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 @@
diff --git a/ui-v2/package.json b/ui-v2/package.json index 37dcb95e84..6936ec9aad 100644 --- a/ui-v2/package.json +++ b/ui-v2/package.json @@ -73,6 +73,7 @@ "ember-math-helpers": "^2.4.0", "ember-pluralize": "^0.2.0", "ember-power-select": "^2.0.2", + "ember-power-select-with-create": "^0.6.0", "ember-resolver": "^4.0.0", "ember-sinon-qunit": "^2.1.0", "ember-source": "~2.18.2", diff --git a/ui-v2/yarn.lock b/ui-v2/yarn.lock index 4d8c8400b8..faf19854dd 100644 --- a/ui-v2/yarn.lock +++ b/ui-v2/yarn.lock @@ -3640,6 +3640,25 @@ ember-pluralize@^0.2.0: dependencies: ember-cli-babel "5.1.5" +ember-power-select-with-create@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/ember-power-select-with-create/-/ember-power-select-with-create-0.6.0.tgz#40ac701276379b78efbaedc33fb5f82e49f80674" + dependencies: + ember-cli-babel "^6.6.0" + ember-cli-htmlbars "^2.0.1" + ember-power-select "^2.0.0" + +ember-power-select@^2.0.0: + version "2.0.3" + resolved "https://registry.yarnpkg.com/ember-power-select/-/ember-power-select-2.0.3.tgz#a44b62d74ca286e1fdc4b8f3b0ea9a7cf53f34ed" + dependencies: + ember-basic-dropdown "^1.0.0" + ember-cli-babel "^6.11.0" + ember-cli-htmlbars "^2.0.1" + ember-concurrency "^0.8.19" + ember-text-measurer "^0.4.0" + ember-truth-helpers "^2.0.0" + ember-power-select@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/ember-power-select/-/ember-power-select-2.0.2.tgz#e8c9a4f266b5a32847e859ddd4db5b2f95108ee8"