ui: Brings the new ACLs into line with the new repo folder structure (#4857)

This PR updates the folder structure and naming of the new ACLs, the same as #4694 .
pull/4858/head
John Cowen 6 years ago committed by GitHub
parent f1246801b1
commit de6644675d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,7 +6,7 @@ import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions';
export default Route.extend(WithBlockingActions, {
settings: service('settings'),
feedback: service('feedback'),
repo: service('tokens'),
repo: service('repository/token'),
actions: {
authorize: function(secret) {
const dc = this.modelFor('dc').dc.Name;

@ -6,18 +6,18 @@ import { get } from '@ember/object';
import WithPolicyActions from 'consul-ui/mixins/policy/with-actions';
export default SingleRoute.extend(WithPolicyActions, {
repo: service('policies'),
tokensRepo: service('tokens'),
datacenterRepo: service('dc'),
repo: service('repository/policy'),
tokenRepo: service('repository/token'),
datacenterRepo: service('repository/dc'),
model: function(params) {
const dc = this.modelFor('dc').dc.Name;
const tokensRepo = get(this, 'tokensRepo');
const tokenRepo = get(this, 'tokenRepo');
return this._super(...arguments).then(model => {
return hash({
...model,
...{
datacenters: get(this, 'datacenterRepo').findAll(),
items: tokensRepo.findByPolicy(get(model.item, 'ID'), dc).catch(function(e) {
items: tokenRepo.findByPolicy(get(model.item, 'ID'), dc).catch(function(e) {
switch (get(e, 'errors.firstObject.status')) {
case '403':
case '401':

@ -6,7 +6,7 @@ import { get } from '@ember/object';
import WithPolicyActions from 'consul-ui/mixins/policy/with-actions';
export default Route.extend(WithPolicyActions, {
repo: service('policies'),
repo: service('repository/policy'),
queryParams: {
s: {
as: 'filter',

@ -9,13 +9,13 @@ import WithTokenActions from 'consul-ui/mixins/token/with-actions';
const ERROR_PARSE_RULES = 'Failed to parse ACL rules';
const ERROR_NAME_EXISTS = 'Invalid Policy: A Policy with Name';
export default SingleRoute.extend(WithTokenActions, {
repo: service('tokens'),
policiesRepo: service('policies'),
datacenterRepo: service('dc'),
repo: service('repository/token'),
policyRepo: service('repository/policy'),
datacenterRepo: service('repository/dc'),
settings: service('settings'),
model: function(params, transition) {
const dc = this.modelFor('dc').dc.Name;
const policiesRepo = get(this, 'policiesRepo');
const policyRepo = get(this, 'policyRepo');
return this._super(...arguments).then(model => {
return hash({
...model,
@ -24,7 +24,7 @@ export default SingleRoute.extend(WithTokenActions, {
datacenters: get(this, 'datacenterRepo').findAll(),
policy: this.getEmptyPolicy(),
token: get(this, 'settings').findBySlug('token'),
items: policiesRepo.findAllByDatacenter(dc).catch(function(e) {
items: policyRepo.findAllByDatacenter(dc).catch(function(e) {
switch (get(e, 'errors.firstObject.status')) {
case '403':
case '401':
@ -43,12 +43,12 @@ export default SingleRoute.extend(WithTokenActions, {
},
getEmptyPolicy: function() {
const dc = this.modelFor('dc').dc.Name;
return get(this, 'policiesRepo').create({ Datacenter: dc });
return get(this, 'policyRepo').create({ Datacenter: dc });
},
actions: {
// TODO: Some of this could potentially be moved to the repo services
loadPolicy: function(item, items) {
const repo = get(this, 'policiesRepo');
const repo = get(this, 'policyRepo');
const dc = this.modelFor('dc').dc.Name;
const slug = get(item, repo.getSlugKey());
repo.findBySlug(slug, dc).then(item => {
@ -68,7 +68,7 @@ export default SingleRoute.extend(WithTokenActions, {
});
},
createPolicy: function(item, policies, success) {
get(this, 'policiesRepo')
get(this, 'policyRepo')
.persist(item)
.then(item => {
set(item, 'CreateTime', new Date().getTime());

@ -4,7 +4,7 @@ import { hash } from 'rsvp';
import { get } from '@ember/object';
import WithTokenActions from 'consul-ui/mixins/token/with-actions';
export default Route.extend(WithTokenActions, {
repo: service('tokens'),
repo: service('repository/token'),
settings: service('settings'),
queryParams: {
s: {

@ -1,14 +1,9 @@
import { moduleFor, test, skip } from 'ember-qunit';
const NAME = 'policy';
import repo from 'consul-ui/tests/helpers/repo';
moduleFor('service:policies', 'Integration | Service | policies', {
moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, {
// Specify the other units that are required for this test.
needs: [
'service:store',
'model:policy',
'adapter:policy',
'serializer:policy',
'service:settings',
],
integration: true,
});
const dc = 'dc-1';
const id = 'policy-name';

@ -1,8 +1,9 @@
import { moduleFor, test, skip } from 'ember-qunit';
import repo from 'consul-ui/tests/helpers/repo';
moduleFor('service:tokens', 'Integration | Service | tokens', {
const NAME = 'token';
moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, {
// Specify the other units that are required for this test.
needs: ['service:store', 'model:token', 'adapter:token', 'serializer:token', 'service:settings'],
integration: true,
});
const dc = 'dc-1';
const id = 'token-id';

@ -13,7 +13,7 @@ moduleFor('mixin:policy/with-actions', 'Unit | Mixin | policy/with actions', {
'service:flashMessages',
'service:logger',
'service:settings',
'service:policies',
'service:repository/policy',
],
subject: function() {
const MixedIn = Route.extend(Mixin);

@ -13,7 +13,7 @@ moduleFor('mixin:token/with-actions', 'Unit | Mixin | token/with actions', {
'service:flashMessages',
'service:logger',
'service:settings',
'service:tokens',
'service:repository/token',
],
subject: function() {
const MixedIn = Route.extend(Mixin);

@ -3,7 +3,7 @@ import { moduleFor, test } from 'ember-qunit';
moduleFor('route:dc/acls', 'Unit | Route | dc/acls', {
// Specify the other units that are required for this test.
needs: [
'service:tokens',
'service:repository/token',
'service:feedback',
'service:logger',
'service:settings',

@ -3,9 +3,9 @@ import { moduleFor, test } from 'ember-qunit';
moduleFor('route:dc/acls/policies/create', 'Unit | Route | dc/acls/policies/create', {
// Specify the other units that are required for this test.
needs: [
'service:policies',
'service:tokens',
'service:dc',
'service:repository/policy',
'service:repository/token',
'service:repository/dc',
'service:feedback',
'service:logger',
'service:settings',

@ -3,9 +3,9 @@ import { moduleFor, test } from 'ember-qunit';
moduleFor('route:dc/acls/policies/edit', 'Unit | Route | dc/acls/policies/edit', {
// Specify the other units that are required for this test.
needs: [
'service:policies',
'service:tokens',
'service:dc',
'service:repository/policy',
'service:repository/token',
'service:repository/dc',
'service:feedback',
'service:logger',
'service:settings',

@ -3,7 +3,7 @@ import { moduleFor, test } from 'ember-qunit';
moduleFor('route:dc/acls/policies/index', 'Unit | Route | dc/acls/policies/index', {
// Specify the other units that are required for this test.
needs: [
'service:policies',
'service:repository/policy',
'service:feedback',
'service:logger',
'service:settings',

@ -3,9 +3,9 @@ import { moduleFor, test } from 'ember-qunit';
moduleFor('route:dc/acls/tokens/create', 'Unit | Route | dc/acls/tokens/create', {
// Specify the other units that are required for this test.
needs: [
'service:tokens',
'service:policies',
'service:dc',
'service:repository/token',
'service:repository/policy',
'service:repository/dc',
'service:feedback',
'service:logger',
'service:settings',

@ -3,9 +3,9 @@ import { moduleFor, test } from 'ember-qunit';
moduleFor('route:dc/acls/tokens/edit', 'Unit | Route | dc/acls/tokens/edit', {
// Specify the other units that are required for this test.
needs: [
'service:tokens',
'service:policies',
'service:dc',
'service:repository/token',
'service:repository/policy',
'service:repository/dc',
'service:feedback',
'service:logger',
'service:settings',

@ -3,7 +3,7 @@ import { moduleFor, test } from 'ember-qunit';
moduleFor('route:dc/acls/tokens/index', 'Unit | Route | dc/acls/tokens/index', {
// Specify the other units that are required for this test.
needs: [
'service:tokens',
'service:repository/token',
'service:feedback',
'service:logger',
'service:settings',

@ -1,6 +1,6 @@
import { moduleFor, test } from 'ember-qunit';
moduleFor('service:acl', 'Unit | Service | acl', {
moduleFor('service:repository/acl', 'Unit | Service | acl', {
// Specify the other units that are required for this test.
// needs: ['service:foo']
});

@ -0,0 +1,12 @@
import { moduleFor, test } from 'ember-qunit';
moduleFor('service:repository/policy', 'Unit | Service | policy', {
// Specify the other units that are required for this test.
needs: ['service:store'],
});
// Replace this with your real tests.
test('it exists', function(assert) {
let service = this.subject();
assert.ok(service);
});

@ -1,8 +1,8 @@
import { moduleFor, test } from 'ember-qunit';
moduleFor('service:repository/acl', 'Unit | Service | acl', {
moduleFor('service:repository/token', 'Unit | Service | token', {
// Specify the other units that are required for this test.
// needs: ['service:foo']
needs: ['service:store'],
});
// Replace this with your real tests.
Loading…
Cancel
Save