2019-12-17 18:47:37 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
2020-11-09 09:25:35 +00:00
|
|
|
import Route from 'consul-ui/routing/route';
|
2019-12-17 18:47:37 +00:00
|
|
|
import { hash } from 'rsvp';
|
|
|
|
|
|
|
|
import WithNspaceActions from 'consul-ui/mixins/nspace/with-actions';
|
|
|
|
|
2020-11-09 09:25:35 +00:00
|
|
|
export default class EditRoute extends Route.extend(WithNspaceActions) {
|
|
|
|
@service('repository/nspace')
|
|
|
|
repo;
|
|
|
|
|
|
|
|
isCreate(params, transition) {
|
2019-12-17 18:47:37 +00:00
|
|
|
return transition.targetName.split('.').pop() === 'create';
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
model(params, transition) {
|
2019-12-17 18:47:37 +00:00
|
|
|
const repo = this.repo;
|
|
|
|
const create = this.isCreate(...arguments);
|
|
|
|
const dc = this.modelFor('dc').dc.Name;
|
|
|
|
return hash({
|
|
|
|
create: create,
|
|
|
|
dc: dc,
|
|
|
|
item: create
|
|
|
|
? Promise.resolve(
|
|
|
|
repo.create({
|
|
|
|
ACLs: {
|
|
|
|
PolicyDefaults: [],
|
|
|
|
RoleDefaults: [],
|
|
|
|
},
|
|
|
|
})
|
|
|
|
)
|
|
|
|
: repo.findBySlug(params.name),
|
|
|
|
});
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
setupController(controller, model) {
|
|
|
|
super.setupController(...arguments);
|
2019-12-17 18:47:37 +00:00
|
|
|
controller.setProperties(model);
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
}
|