diff --git a/ui-v2/app/controllers/dc/intentions/edit.js b/ui-v2/app/controllers/dc/intentions/edit.js index 669ed0fb25..f085a95c60 100644 --- a/ui-v2/app/controllers/dc/intentions/edit.js +++ b/ui-v2/app/controllers/dc/intentions/edit.js @@ -11,19 +11,23 @@ export default Controller.extend({ ...model, ...{ item: this.changeset, + SourceName: model.items.filterBy('Name', get(model.item, 'SourceName'))[0], + DestinationName: model.items.filterBy('Name', get(model.item, 'DestinationName'))[0], }, }); }, actions: { - change: function(e) { - const target = e.target || { name: 'SourceName', value: e }; + change: function(e, value, _target) { + const target = e.target || { ..._target, ...{ name: e, value: value } }; switch (target.name) { case 'Action': set(this.changeset, target.name, target.value); break; case 'SourceName': - set(this.changeset, 'SourceName', get(target.value, 'Name')); - set(this.item, 'SourceName', get(target.value, 'Name')); + case 'DestinationName': + set(this.changeset, target.name, get(target.value, 'Name')); + set(this.item, target.name, get(target.value, 'Name')); + set(this, target.name, target.value); break; } }, diff --git a/ui-v2/app/routes/dc/intentions/create.js b/ui-v2/app/routes/dc/intentions/create.js index c05f05ba16..db467b16cb 100644 --- a/ui-v2/app/routes/dc/intentions/create.js +++ b/ui-v2/app/routes/dc/intentions/create.js @@ -7,6 +7,7 @@ import WithIntentionActions from 'consul-ui/mixins/intention/with-actions'; export default Route.extend(WithIntentionActions, { templateName: 'dc/intentions/edit', repo: service('intentions'), + servicesRepo: service('services'), beforeModel: function() { get(this, 'repo').invalidate(); }, @@ -17,6 +18,7 @@ export default Route.extend(WithIntentionActions, { create: true, isLoading: false, item: this.item, + items: get(this, 'servicesRepo').findAllByDatacenter(this.modelFor('dc').dc.Name), intents: ['allow', 'deny'], }); }, diff --git a/ui-v2/app/templates/dc/intentions/-form.hbs b/ui-v2/app/templates/dc/intentions/-form.hbs index e560804a47..47cff7f6ee 100644 --- a/ui-v2/app/templates/dc/intentions/-form.hbs +++ b/ui-v2/app/templates/dc/intentions/-form.hbs @@ -2,15 +2,28 @@