open-consul/ui-v2/app/routing/single.js
John Cowen 81f209d71e UI: ACL Roles (#5635)
Adds support for ACL Roles and Service Identities CRUD, along with necessary changes to Tokens, and the CSS improvements required.

Also includes refinements/improvements for easier testing of deeply nested components.

1. ember-data adapter/serializer/model triplet for Roles
2. repository, form/validations and searching filter for Roles
3. Moves potentially, repeated, or soon to to repeated functionality
into a mixin (mainly for 'many policy' relationships)
4. A few styling tweaks for little edge cases around roles
5. Router additions, Route, Controller and templates for Roles

Also see: 

* UI: ACL Roles cont. plus Service Identities (#5661 and #5720)
2019-05-01 18:22:37 +00:00

30 lines
913 B
JavaScript

import Route from '@ember/routing/route';
import { get } from '@ember/object';
import { assert } from '@ember/debug';
import { Promise, hash } from 'rsvp';
export default Route.extend({
// repo: service('repositoryName'),
isCreate: function(params, transition) {
return transition.targetName.split('.').pop() === 'create';
},
model: function(params, transition) {
const repo = get(this, 'repo');
assert(
"`repo` is undefined, please define RepositoryService using `repo: service('repositoryName')`",
typeof repo !== 'undefined'
);
const dc = this.modelFor('dc').dc.Name;
const create = this.isCreate(...arguments);
return hash({
isLoading: false,
dc: dc,
create: create,
...repo.status({
item: create
? Promise.resolve(repo.create({ Datacenter: dc }))
: repo.findBySlug(params.id, dc),
}),
});
},
});