455dfe0a1b
* Add model layer support for filtering intentions by service * Add Route, Controller and template for services.show.intentions tab We are still loading the intentions themselves in the parent Route for the moment * Load the intentions in in the parent route for the moment * Temporarily add support for returning to history -1 Once we have an intention form underneath the service/intention tab this will no longer be needed * Add the new tab and enable blocking queries for it * Add some further acceptance testing around intention listings
53 lines
1.8 KiB
JavaScript
53 lines
1.8 KiB
JavaScript
import Route from '@ember/routing/route';
|
|
import { inject as service } from '@ember/service';
|
|
import { hash } from 'rsvp';
|
|
import { get } from '@ember/object';
|
|
|
|
import WithIntentionActions from 'consul-ui/mixins/intention/with-actions';
|
|
|
|
// TODO: This route and the create Route need merging somehow
|
|
export default Route.extend(WithIntentionActions, {
|
|
repo: service('repository/intention'),
|
|
servicesRepo: service('repository/service'),
|
|
nspacesRepo: service('repository/nspace/disabled'),
|
|
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'),
|
|
});
|
|
}
|
|
|
|
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 = '*';
|
|
return hash({
|
|
isLoading: false,
|
|
item: this.repo.findBySlug(params.id, dc, nspace),
|
|
services: this.servicesRepo.findAllByDatacenter(dc, nspace),
|
|
nspaces: this.nspacesRepo.findAll(),
|
|
history: this.history,
|
|
}).then(function(model) {
|
|
return {
|
|
...model,
|
|
...{
|
|
services: [{ Name: '*' }].concat(
|
|
model.services.toArray().filter(item => get(item, 'Kind') !== 'connect-proxy')
|
|
),
|
|
nspaces: [{ Name: '*' }].concat(model.nspaces.toArray()),
|
|
},
|
|
};
|
|
});
|
|
},
|
|
setupController: function(controller, model) {
|
|
controller.setProperties(model);
|
|
},
|
|
});
|