mirror of https://github.com/status-im/consul.git
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 .
This commit is contained in:
parent
f1246801b1
commit
de6644675d
|
@ -6,7 +6,7 @@ import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions';
|
||||||
export default Route.extend(WithBlockingActions, {
|
export default Route.extend(WithBlockingActions, {
|
||||||
settings: service('settings'),
|
settings: service('settings'),
|
||||||
feedback: service('feedback'),
|
feedback: service('feedback'),
|
||||||
repo: service('tokens'),
|
repo: service('repository/token'),
|
||||||
actions: {
|
actions: {
|
||||||
authorize: function(secret) {
|
authorize: function(secret) {
|
||||||
const dc = this.modelFor('dc').dc.Name;
|
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';
|
import WithPolicyActions from 'consul-ui/mixins/policy/with-actions';
|
||||||
|
|
||||||
export default SingleRoute.extend(WithPolicyActions, {
|
export default SingleRoute.extend(WithPolicyActions, {
|
||||||
repo: service('policies'),
|
repo: service('repository/policy'),
|
||||||
tokensRepo: service('tokens'),
|
tokenRepo: service('repository/token'),
|
||||||
datacenterRepo: service('dc'),
|
datacenterRepo: service('repository/dc'),
|
||||||
model: function(params) {
|
model: function(params) {
|
||||||
const dc = this.modelFor('dc').dc.Name;
|
const dc = this.modelFor('dc').dc.Name;
|
||||||
const tokensRepo = get(this, 'tokensRepo');
|
const tokenRepo = get(this, 'tokenRepo');
|
||||||
return this._super(...arguments).then(model => {
|
return this._super(...arguments).then(model => {
|
||||||
return hash({
|
return hash({
|
||||||
...model,
|
...model,
|
||||||
...{
|
...{
|
||||||
datacenters: get(this, 'datacenterRepo').findAll(),
|
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')) {
|
switch (get(e, 'errors.firstObject.status')) {
|
||||||
case '403':
|
case '403':
|
||||||
case '401':
|
case '401':
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { get } from '@ember/object';
|
||||||
import WithPolicyActions from 'consul-ui/mixins/policy/with-actions';
|
import WithPolicyActions from 'consul-ui/mixins/policy/with-actions';
|
||||||
|
|
||||||
export default Route.extend(WithPolicyActions, {
|
export default Route.extend(WithPolicyActions, {
|
||||||
repo: service('policies'),
|
repo: service('repository/policy'),
|
||||||
queryParams: {
|
queryParams: {
|
||||||
s: {
|
s: {
|
||||||
as: 'filter',
|
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_PARSE_RULES = 'Failed to parse ACL rules';
|
||||||
const ERROR_NAME_EXISTS = 'Invalid Policy: A Policy with Name';
|
const ERROR_NAME_EXISTS = 'Invalid Policy: A Policy with Name';
|
||||||
export default SingleRoute.extend(WithTokenActions, {
|
export default SingleRoute.extend(WithTokenActions, {
|
||||||
repo: service('tokens'),
|
repo: service('repository/token'),
|
||||||
policiesRepo: service('policies'),
|
policyRepo: service('repository/policy'),
|
||||||
datacenterRepo: service('dc'),
|
datacenterRepo: service('repository/dc'),
|
||||||
settings: service('settings'),
|
settings: service('settings'),
|
||||||
model: function(params, transition) {
|
model: function(params, transition) {
|
||||||
const dc = this.modelFor('dc').dc.Name;
|
const dc = this.modelFor('dc').dc.Name;
|
||||||
const policiesRepo = get(this, 'policiesRepo');
|
const policyRepo = get(this, 'policyRepo');
|
||||||
return this._super(...arguments).then(model => {
|
return this._super(...arguments).then(model => {
|
||||||
return hash({
|
return hash({
|
||||||
...model,
|
...model,
|
||||||
|
@ -24,7 +24,7 @@ export default SingleRoute.extend(WithTokenActions, {
|
||||||
datacenters: get(this, 'datacenterRepo').findAll(),
|
datacenters: get(this, 'datacenterRepo').findAll(),
|
||||||
policy: this.getEmptyPolicy(),
|
policy: this.getEmptyPolicy(),
|
||||||
token: get(this, 'settings').findBySlug('token'),
|
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')) {
|
switch (get(e, 'errors.firstObject.status')) {
|
||||||
case '403':
|
case '403':
|
||||||
case '401':
|
case '401':
|
||||||
|
@ -43,12 +43,12 @@ export default SingleRoute.extend(WithTokenActions, {
|
||||||
},
|
},
|
||||||
getEmptyPolicy: function() {
|
getEmptyPolicy: function() {
|
||||||
const dc = this.modelFor('dc').dc.Name;
|
const dc = this.modelFor('dc').dc.Name;
|
||||||
return get(this, 'policiesRepo').create({ Datacenter: dc });
|
return get(this, 'policyRepo').create({ Datacenter: dc });
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
// TODO: Some of this could potentially be moved to the repo services
|
// TODO: Some of this could potentially be moved to the repo services
|
||||||
loadPolicy: function(item, items) {
|
loadPolicy: function(item, items) {
|
||||||
const repo = get(this, 'policiesRepo');
|
const repo = get(this, 'policyRepo');
|
||||||
const dc = this.modelFor('dc').dc.Name;
|
const dc = this.modelFor('dc').dc.Name;
|
||||||
const slug = get(item, repo.getSlugKey());
|
const slug = get(item, repo.getSlugKey());
|
||||||
repo.findBySlug(slug, dc).then(item => {
|
repo.findBySlug(slug, dc).then(item => {
|
||||||
|
@ -68,7 +68,7 @@ export default SingleRoute.extend(WithTokenActions, {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
createPolicy: function(item, policies, success) {
|
createPolicy: function(item, policies, success) {
|
||||||
get(this, 'policiesRepo')
|
get(this, 'policyRepo')
|
||||||
.persist(item)
|
.persist(item)
|
||||||
.then(item => {
|
.then(item => {
|
||||||
set(item, 'CreateTime', new Date().getTime());
|
set(item, 'CreateTime', new Date().getTime());
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { hash } from 'rsvp';
|
||||||
import { get } from '@ember/object';
|
import { get } from '@ember/object';
|
||||||
import WithTokenActions from 'consul-ui/mixins/token/with-actions';
|
import WithTokenActions from 'consul-ui/mixins/token/with-actions';
|
||||||
export default Route.extend(WithTokenActions, {
|
export default Route.extend(WithTokenActions, {
|
||||||
repo: service('tokens'),
|
repo: service('repository/token'),
|
||||||
settings: service('settings'),
|
settings: service('settings'),
|
||||||
queryParams: {
|
queryParams: {
|
||||||
s: {
|
s: {
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
import { moduleFor, test, skip } from 'ember-qunit';
|
import { moduleFor, test, skip } from 'ember-qunit';
|
||||||
|
const NAME = 'policy';
|
||||||
import repo from 'consul-ui/tests/helpers/repo';
|
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.
|
// Specify the other units that are required for this test.
|
||||||
needs: [
|
integration: true,
|
||||||
'service:store',
|
|
||||||
'model:policy',
|
|
||||||
'adapter:policy',
|
|
||||||
'serializer:policy',
|
|
||||||
'service:settings',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
const dc = 'dc-1';
|
const dc = 'dc-1';
|
||||||
const id = 'policy-name';
|
const id = 'policy-name';
|
|
@ -1,8 +1,9 @@
|
||||||
import { moduleFor, test, skip } from 'ember-qunit';
|
import { moduleFor, test, skip } from 'ember-qunit';
|
||||||
import repo from 'consul-ui/tests/helpers/repo';
|
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.
|
// 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 dc = 'dc-1';
|
||||||
const id = 'token-id';
|
const id = 'token-id';
|
|
@ -13,7 +13,7 @@ moduleFor('mixin:policy/with-actions', 'Unit | Mixin | policy/with actions', {
|
||||||
'service:flashMessages',
|
'service:flashMessages',
|
||||||
'service:logger',
|
'service:logger',
|
||||||
'service:settings',
|
'service:settings',
|
||||||
'service:policies',
|
'service:repository/policy',
|
||||||
],
|
],
|
||||||
subject: function() {
|
subject: function() {
|
||||||
const MixedIn = Route.extend(Mixin);
|
const MixedIn = Route.extend(Mixin);
|
||||||
|
|
|
@ -13,7 +13,7 @@ moduleFor('mixin:token/with-actions', 'Unit | Mixin | token/with actions', {
|
||||||
'service:flashMessages',
|
'service:flashMessages',
|
||||||
'service:logger',
|
'service:logger',
|
||||||
'service:settings',
|
'service:settings',
|
||||||
'service:tokens',
|
'service:repository/token',
|
||||||
],
|
],
|
||||||
subject: function() {
|
subject: function() {
|
||||||
const MixedIn = Route.extend(Mixin);
|
const MixedIn = Route.extend(Mixin);
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { moduleFor, test } from 'ember-qunit';
|
||||||
moduleFor('route:dc/acls', 'Unit | Route | dc/acls', {
|
moduleFor('route:dc/acls', 'Unit | Route | dc/acls', {
|
||||||
// Specify the other units that are required for this test.
|
// Specify the other units that are required for this test.
|
||||||
needs: [
|
needs: [
|
||||||
'service:tokens',
|
'service:repository/token',
|
||||||
'service:feedback',
|
'service:feedback',
|
||||||
'service:logger',
|
'service:logger',
|
||||||
'service:settings',
|
'service:settings',
|
||||||
|
|
|
@ -3,9 +3,9 @@ import { moduleFor, test } from 'ember-qunit';
|
||||||
moduleFor('route:dc/acls/policies/create', 'Unit | Route | dc/acls/policies/create', {
|
moduleFor('route:dc/acls/policies/create', 'Unit | Route | dc/acls/policies/create', {
|
||||||
// Specify the other units that are required for this test.
|
// Specify the other units that are required for this test.
|
||||||
needs: [
|
needs: [
|
||||||
'service:policies',
|
'service:repository/policy',
|
||||||
'service:tokens',
|
'service:repository/token',
|
||||||
'service:dc',
|
'service:repository/dc',
|
||||||
'service:feedback',
|
'service:feedback',
|
||||||
'service:logger',
|
'service:logger',
|
||||||
'service:settings',
|
'service:settings',
|
||||||
|
|
|
@ -3,9 +3,9 @@ import { moduleFor, test } from 'ember-qunit';
|
||||||
moduleFor('route:dc/acls/policies/edit', 'Unit | Route | dc/acls/policies/edit', {
|
moduleFor('route:dc/acls/policies/edit', 'Unit | Route | dc/acls/policies/edit', {
|
||||||
// Specify the other units that are required for this test.
|
// Specify the other units that are required for this test.
|
||||||
needs: [
|
needs: [
|
||||||
'service:policies',
|
'service:repository/policy',
|
||||||
'service:tokens',
|
'service:repository/token',
|
||||||
'service:dc',
|
'service:repository/dc',
|
||||||
'service:feedback',
|
'service:feedback',
|
||||||
'service:logger',
|
'service:logger',
|
||||||
'service:settings',
|
'service:settings',
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { moduleFor, test } from 'ember-qunit';
|
||||||
moduleFor('route:dc/acls/policies/index', 'Unit | Route | dc/acls/policies/index', {
|
moduleFor('route:dc/acls/policies/index', 'Unit | Route | dc/acls/policies/index', {
|
||||||
// Specify the other units that are required for this test.
|
// Specify the other units that are required for this test.
|
||||||
needs: [
|
needs: [
|
||||||
'service:policies',
|
'service:repository/policy',
|
||||||
'service:feedback',
|
'service:feedback',
|
||||||
'service:logger',
|
'service:logger',
|
||||||
'service:settings',
|
'service:settings',
|
||||||
|
|
|
@ -3,9 +3,9 @@ import { moduleFor, test } from 'ember-qunit';
|
||||||
moduleFor('route:dc/acls/tokens/create', 'Unit | Route | dc/acls/tokens/create', {
|
moduleFor('route:dc/acls/tokens/create', 'Unit | Route | dc/acls/tokens/create', {
|
||||||
// Specify the other units that are required for this test.
|
// Specify the other units that are required for this test.
|
||||||
needs: [
|
needs: [
|
||||||
'service:tokens',
|
'service:repository/token',
|
||||||
'service:policies',
|
'service:repository/policy',
|
||||||
'service:dc',
|
'service:repository/dc',
|
||||||
'service:feedback',
|
'service:feedback',
|
||||||
'service:logger',
|
'service:logger',
|
||||||
'service:settings',
|
'service:settings',
|
||||||
|
|
|
@ -3,9 +3,9 @@ import { moduleFor, test } from 'ember-qunit';
|
||||||
moduleFor('route:dc/acls/tokens/edit', 'Unit | Route | dc/acls/tokens/edit', {
|
moduleFor('route:dc/acls/tokens/edit', 'Unit | Route | dc/acls/tokens/edit', {
|
||||||
// Specify the other units that are required for this test.
|
// Specify the other units that are required for this test.
|
||||||
needs: [
|
needs: [
|
||||||
'service:tokens',
|
'service:repository/token',
|
||||||
'service:policies',
|
'service:repository/policy',
|
||||||
'service:dc',
|
'service:repository/dc',
|
||||||
'service:feedback',
|
'service:feedback',
|
||||||
'service:logger',
|
'service:logger',
|
||||||
'service:settings',
|
'service:settings',
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { moduleFor, test } from 'ember-qunit';
|
||||||
moduleFor('route:dc/acls/tokens/index', 'Unit | Route | dc/acls/tokens/index', {
|
moduleFor('route:dc/acls/tokens/index', 'Unit | Route | dc/acls/tokens/index', {
|
||||||
// Specify the other units that are required for this test.
|
// Specify the other units that are required for this test.
|
||||||
needs: [
|
needs: [
|
||||||
'service:tokens',
|
'service:repository/token',
|
||||||
'service:feedback',
|
'service:feedback',
|
||||||
'service:logger',
|
'service:logger',
|
||||||
'service:settings',
|
'service:settings',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { moduleFor, test } from 'ember-qunit';
|
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.
|
// Specify the other units that are required for this test.
|
||||||
// needs: ['service:foo']
|
// 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';
|
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.
|
// Specify the other units that are required for this test.
|
||||||
// needs: ['service:foo']
|
needs: ['service:store'],
|
||||||
});
|
});
|
||||||
|
|
||||||
// Replace this with your real tests.
|
// Replace this with your real tests.
|
Loading…
Reference in New Issue