From 50507b34a51631eee9d865b9fbd6ce9d39bd451b Mon Sep 17 00:00:00 2001 From: John Cowen Date: Fri, 8 Jun 2018 14:55:23 +0100 Subject: [PATCH] Make sure future services are available when editing intentions --- ui-v2/app/controllers/dc/intentions/edit.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ui-v2/app/controllers/dc/intentions/edit.js b/ui-v2/app/controllers/dc/intentions/edit.js index 8ddf30981f..e20c7eccbe 100644 --- a/ui-v2/app/controllers/dc/intentions/edit.js +++ b/ui-v2/app/controllers/dc/intentions/edit.js @@ -8,12 +8,24 @@ import validations from 'consul-ui/validations/intention'; export default Controller.extend({ setProperties: function(model) { this.changeset = new Changeset(model.item, lookupValidator(validations), validations); + const sourceName = get(model.item, 'SourceName'); + const destinationName = get(model.item, 'DestinationName'); + let source = model.items.findBy('Name', sourceName); + let destination = model.items.findBy('Name', destinationName); + if (!source) { + source = { Name: sourceName }; + model.items = [source].concat(model.items); + } + if (!destination) { + destination = { Name: destinationName }; + model.items = [destination].concat(model.items); + } this._super({ ...model, ...{ item: this.changeset, - SourceName: model.items.filterBy('Name', get(model.item, 'SourceName'))[0], - DestinationName: model.items.filterBy('Name', get(model.item, 'DestinationName'))[0], + SourceName: source, + DestinationName: destination, }, }); },