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';
|
|
|
|
import { get } from '@ember/object';
|
|
|
|
|
2019-12-17 18:47:37 +00:00
|
|
|
import WithIntentionActions from 'consul-ui/mixins/intention/with-actions';
|
2018-05-22 15:03:45 +00:00
|
|
|
|
2019-12-17 18:47:37 +00:00
|
|
|
// TODO: This route and the create Route need merging somehow
|
|
|
|
export default Route.extend(WithIntentionActions, {
|
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'),
|
2020-04-16 14:15:45 +00:00
|
|
|
buildRouteInfoMetadata: function() {
|
|
|
|
return { history: this.history };
|
|
|
|
},
|
|
|
|
model: function(params, transition) {
|
|
|
|
const from = get(transition, 'from');
|
|
|
|
this.history = [];
|
|
|
|
if (from && get(from, 'name') === 'dc.services.show.intentions') {
|
|
|
|
this.history.push({
|
|
|
|
key: get(from, 'name'),
|
|
|
|
value: get(from, 'parent.params.name'),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-12-17 18:47:37 +00:00
|
|
|
const dc = this.modelFor('dc').dc.Name;
|
|
|
|
// We load all of your services that you are able to see here
|
|
|
|
// as even if it doesn't exist in the namespace you are targetting
|
|
|
|
// you may want to add it after you've added the intention
|
|
|
|
const nspace = '*';
|
2018-05-22 15:03:45 +00:00
|
|
|
return hash({
|
|
|
|
isLoading: false,
|
2019-12-17 18:47:37 +00:00
|
|
|
item: this.repo.findBySlug(params.id, dc, nspace),
|
|
|
|
services: this.servicesRepo.findAllByDatacenter(dc, nspace),
|
|
|
|
nspaces: this.nspacesRepo.findAll(),
|
2020-04-16 14:15:45 +00:00
|
|
|
history: this.history,
|
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);
|
|
|
|
},
|
|
|
|
});
|