John Cowen 4480302883
ui: [BUGFIX] Request intention listing with ns parameter (#9432)
This PR adds the ns=* query parameter when namespaces are enabled to keep backwards compatibility with how the UI used to work (Intentions page always lists all intention across all namespace you have access to)

I found a tiny dev bug for printing out the current URL during acceptance testing and fixed that up while I was there.
2021-01-04 17:22:10 +00:00

35 lines
942 B
JavaScript

import { inject as service } from '@ember/service';
import Route from 'consul-ui/routing/route';
export default class EditRoute extends Route {
@service('repository/intention') repo;
@service('env') env;
async model({ intention_id }, transition) {
const dc = this.modelFor('dc').dc.Name;
const nspace = this.modelFor('nspace').nspace.substr(1);
let item;
if (typeof intention_id !== 'undefined') {
item = await this.repo.findBySlug(intention_id, dc, nspace);
} else {
const defaultNspace = this.env.var('CONSUL_NSPACES_ENABLED') ? '*' : 'default';
item = await this.repo.create({
SourceNS: nspace || defaultNspace,
DestinationNS: nspace || defaultNspace,
Datacenter: dc,
});
}
return {
dc,
nspace,
item,
};
}
setupController(controller, model) {
super.setupController(...arguments);
controller.setProperties(model);
}
}