2018-05-22 15:03:45 +00:00
|
|
|
import Route from '@ember/routing/route';
|
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import { hash } from 'rsvp';
|
2019-12-17 18:47:37 +00:00
|
|
|
import { get } from '@ember/object';
|
2018-05-22 15:03:45 +00:00
|
|
|
import WithIntentionActions from 'consul-ui/mixins/intention/with-actions';
|
|
|
|
|
2019-12-17 18:47:37 +00:00
|
|
|
// TODO: This route and the edit Route need merging somehow
|
2018-05-22 15:03:45 +00:00
|
|
|
export default Route.extend(WithIntentionActions, {
|
|
|
|
templateName: 'dc/intentions/edit',
|
2018-10-26 16:36:15 +00:00
|
|
|
repo: service('repository/intention'),
|
|
|
|
servicesRepo: service('repository/service'),
|
2019-12-17 18:47:37 +00:00
|
|
|
nspacesRepo: service('repository/nspace/disabled'),
|
2018-05-22 15:03:45 +00:00
|
|
|
model: function(params) {
|
2019-12-17 18:47:37 +00:00
|
|
|
const dc = this.modelFor('dc').dc.Name;
|
2020-01-24 12:26:28 +00:00
|
|
|
const nspace = '*';
|
2019-12-17 18:47:37 +00:00
|
|
|
this.item = this.repo.create({
|
|
|
|
Datacenter: dc,
|
|
|
|
});
|
2018-05-22 15:03:45 +00:00
|
|
|
return hash({
|
|
|
|
create: true,
|
|
|
|
isLoading: false,
|
|
|
|
item: this.item,
|
2019-12-17 18:47:37 +00:00
|
|
|
services: this.servicesRepo.findAllByDatacenter(dc, nspace),
|
|
|
|
nspaces: this.nspacesRepo.findAll(),
|
2018-06-08 12:20:13 +00:00
|
|
|
}).then(function(model) {
|
|
|
|
return {
|
|
|
|
...model,
|
|
|
|
...{
|
2019-12-17 18:47:37 +00:00
|
|
|
services: [{ Name: '*' }].concat(
|
|
|
|
model.services.toArray().filter(item => get(item, 'Kind') !== 'connect-proxy')
|
2018-06-19 13:54:57 +00:00
|
|
|
),
|
2019-12-17 18:47:37 +00:00
|
|
|
nspaces: [{ Name: '*' }].concat(model.nspaces.toArray()),
|
2018-06-08 12:20:13 +00:00
|
|
|
},
|
|
|
|
};
|
2018-05-22 15:03:45 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
setupController: function(controller, model) {
|
|
|
|
controller.setProperties(model);
|
|
|
|
},
|
|
|
|
deactivate: function() {
|
|
|
|
if (get(this.item, 'isNew')) {
|
2020-04-01 08:55:49 +00:00
|
|
|
this.item.rollbackAttributes();
|
2018-05-22 15:03:45 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|