mirror of https://github.com/status-im/consul.git
ui: Move repo services to repository/ folder and standardize naming (#4694)
Repositories are a class of services to help with CRUD actions, most of the functionality is reused across various Models. This creates a new repository service that centralizes all this reused functionality. Inheritance via ember `Service.extend` is used as opposed to decorating via Mixins. 1. Move all repository services (and their tests) to a services/repository folder 2. Standardize on a singular name format 'node vs nodes' 3. Create a new 'repository' service to centralize functionality. This should be extended by 'repository' services
This commit is contained in:
parent
7ad6596454
commit
14aa90e309
|
@ -11,7 +11,7 @@ export default Route.extend({
|
|||
init: function() {
|
||||
this._super(...arguments);
|
||||
},
|
||||
repo: service('dc'),
|
||||
repo: service('repository/dc'),
|
||||
actions: {
|
||||
loading: function(transition, originRoute) {
|
||||
let dc = null;
|
||||
|
|
|
@ -3,7 +3,7 @@ import { inject as service } from '@ember/service';
|
|||
import { hash } from 'rsvp';
|
||||
import { get } from '@ember/object';
|
||||
export default Route.extend({
|
||||
repo: service('dc'),
|
||||
repo: service('repository/dc'),
|
||||
settings: service('settings'),
|
||||
model: function(params) {
|
||||
const repo = get(this, 'repo');
|
||||
|
|
|
@ -7,7 +7,7 @@ import WithAclActions from 'consul-ui/mixins/acl/with-actions';
|
|||
|
||||
export default Route.extend(WithAclActions, {
|
||||
templateName: 'dc/acls/edit',
|
||||
repo: service('acls'),
|
||||
repo: service('repository/acl'),
|
||||
beforeModel: function() {
|
||||
get(this, 'repo').invalidate();
|
||||
},
|
||||
|
|
|
@ -6,7 +6,7 @@ import { get } from '@ember/object';
|
|||
import WithAclActions from 'consul-ui/mixins/acl/with-actions';
|
||||
|
||||
export default Route.extend(WithAclActions, {
|
||||
repo: service('acls'),
|
||||
repo: service('repository/acl'),
|
||||
settings: service('settings'),
|
||||
model: function(params) {
|
||||
return hash({
|
||||
|
|
|
@ -6,7 +6,7 @@ import { get } from '@ember/object';
|
|||
import WithAclActions from 'consul-ui/mixins/acl/with-actions';
|
||||
|
||||
export default Route.extend(WithAclActions, {
|
||||
repo: service('acls'),
|
||||
repo: service('repository/acl'),
|
||||
queryParams: {
|
||||
s: {
|
||||
as: 'filter',
|
||||
|
|
|
@ -6,8 +6,8 @@ import WithIntentionActions from 'consul-ui/mixins/intention/with-actions';
|
|||
|
||||
export default Route.extend(WithIntentionActions, {
|
||||
templateName: 'dc/intentions/edit',
|
||||
repo: service('intentions'),
|
||||
servicesRepo: service('services'),
|
||||
repo: service('repository/intention'),
|
||||
servicesRepo: service('repository/service'),
|
||||
beforeModel: function() {
|
||||
get(this, 'repo').invalidate();
|
||||
},
|
||||
|
|
|
@ -6,8 +6,8 @@ import { get } from '@ember/object';
|
|||
import WithAclActions from 'consul-ui/mixins/intention/with-actions';
|
||||
|
||||
export default Route.extend(WithAclActions, {
|
||||
repo: service('intentions'),
|
||||
servicesRepo: service('services'),
|
||||
repo: service('repository/intention'),
|
||||
servicesRepo: service('repository/service'),
|
||||
model: function(params) {
|
||||
return hash({
|
||||
isLoading: false,
|
||||
|
|
|
@ -6,7 +6,7 @@ import { get } from '@ember/object';
|
|||
import WithIntentionActions from 'consul-ui/mixins/intention/with-actions';
|
||||
|
||||
export default Route.extend(WithIntentionActions, {
|
||||
repo: service('intentions'),
|
||||
repo: service('repository/intention'),
|
||||
queryParams: {
|
||||
s: {
|
||||
as: 'filter',
|
||||
|
|
|
@ -6,7 +6,7 @@ import WithKvActions from 'consul-ui/mixins/kv/with-actions';
|
|||
|
||||
export default Route.extend(WithKvActions, {
|
||||
templateName: 'dc/kv/edit',
|
||||
repo: service('kv'),
|
||||
repo: service('repository/kv'),
|
||||
beforeModel: function() {
|
||||
get(this, 'repo').invalidate();
|
||||
},
|
||||
|
|
|
@ -7,8 +7,8 @@ import WithKvActions from 'consul-ui/mixins/kv/with-actions';
|
|||
import ascend from 'consul-ui/utils/ascend';
|
||||
|
||||
export default Route.extend(WithKvActions, {
|
||||
repo: service('kv'),
|
||||
sessionRepo: service('session'),
|
||||
repo: service('repository/kv'),
|
||||
sessionRepo: service('repository/session'),
|
||||
model: function(params) {
|
||||
const key = params.key;
|
||||
const dc = this.modelFor('dc').dc.Name;
|
||||
|
|
|
@ -12,7 +12,7 @@ export default Route.extend(WithKvActions, {
|
|||
replace: true,
|
||||
},
|
||||
},
|
||||
repo: service('kv'),
|
||||
repo: service('repository/kv'),
|
||||
beforeModel: function() {
|
||||
// we are index or folder, so if the key doesn't have a trailing slash
|
||||
// add one to force a fake findBySlug
|
||||
|
|
|
@ -4,7 +4,7 @@ import { hash } from 'rsvp';
|
|||
import { get } from '@ember/object';
|
||||
|
||||
export default Route.extend({
|
||||
repo: service('nodes'),
|
||||
repo: service('repository/node'),
|
||||
queryParams: {
|
||||
s: {
|
||||
as: 'filter',
|
||||
|
|
|
@ -10,8 +10,8 @@ import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions';
|
|||
const tomography = tomographyFactory(distance);
|
||||
|
||||
export default Route.extend(WithBlockingActions, {
|
||||
repo: service('nodes'),
|
||||
sessionRepo: service('session'),
|
||||
repo: service('repository/node'),
|
||||
sessionRepo: service('repository/session'),
|
||||
queryParams: {
|
||||
s: {
|
||||
as: 'filter',
|
||||
|
|
|
@ -4,7 +4,7 @@ import { hash } from 'rsvp';
|
|||
import { get } from '@ember/object';
|
||||
|
||||
export default Route.extend({
|
||||
repo: service('services'),
|
||||
repo: service('repository/service'),
|
||||
queryParams: {
|
||||
s: {
|
||||
as: 'filter',
|
||||
|
|
|
@ -4,7 +4,7 @@ import { hash } from 'rsvp';
|
|||
import { get } from '@ember/object';
|
||||
|
||||
export default Route.extend({
|
||||
repo: service('services'),
|
||||
repo: service('repository/service'),
|
||||
queryParams: {
|
||||
s: {
|
||||
as: 'filter',
|
||||
|
|
|
@ -4,7 +4,7 @@ import { hash } from 'rsvp';
|
|||
import { get } from '@ember/object';
|
||||
|
||||
export default Route.extend({
|
||||
repo: service('dc'),
|
||||
repo: service('repository/dc'),
|
||||
model: function(params) {
|
||||
return hash({
|
||||
item: get(this, 'repo').getActive(),
|
||||
|
|
|
@ -6,7 +6,7 @@ import { get } from '@ember/object';
|
|||
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions';
|
||||
export default Route.extend(WithBlockingActions, {
|
||||
repo: service('settings'),
|
||||
dcRepo: service('dc'),
|
||||
dcRepo: service('repository/dc'),
|
||||
model: function(params) {
|
||||
return hash({
|
||||
item: get(this, 'repo').findAll(),
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
import Service, { inject as service } from '@ember/service';
|
||||
import { get } from '@ember/object';
|
||||
import { typeOf } from '@ember/utils';
|
||||
import { PRIMARY_KEY } from 'consul-ui/models/acl';
|
||||
export default Service.extend({
|
||||
store: service('store'),
|
||||
clone: function(item) {
|
||||
return get(this, 'store').clone('acl', get(item, PRIMARY_KEY));
|
||||
},
|
||||
findAllByDatacenter: function(dc) {
|
||||
return get(this, 'store').query('acl', {
|
||||
dc: dc,
|
||||
});
|
||||
},
|
||||
findBySlug: function(slug, dc) {
|
||||
return get(this, 'store').queryRecord('acl', {
|
||||
id: slug,
|
||||
dc: dc,
|
||||
});
|
||||
},
|
||||
create: function() {
|
||||
return get(this, 'store').createRecord('acl');
|
||||
},
|
||||
persist: function(item) {
|
||||
return item.save();
|
||||
},
|
||||
remove: function(obj) {
|
||||
let item = obj;
|
||||
if (typeof obj.destroyRecord === 'undefined') {
|
||||
item = obj.get('data');
|
||||
}
|
||||
if (typeOf(item) === 'object') {
|
||||
item = get(this, 'store').peekRecord('acl', item[PRIMARY_KEY]);
|
||||
}
|
||||
return item.destroyRecord().then(item => {
|
||||
return get(this, 'store').unloadRecord(item);
|
||||
});
|
||||
},
|
||||
invalidate: function() {
|
||||
get(this, 'store').unloadAll('acl');
|
||||
},
|
||||
});
|
|
@ -1,9 +0,0 @@
|
|||
import Service, { inject as service } from '@ember/service';
|
||||
import { get } from '@ember/object';
|
||||
|
||||
export default Service.extend({
|
||||
store: service('store'),
|
||||
findAllByDatacenter: function(dc) {
|
||||
return get(this, 'store').query('coordinate', { dc: dc });
|
||||
},
|
||||
});
|
|
@ -1,37 +0,0 @@
|
|||
import Service, { inject as service } from '@ember/service';
|
||||
import { get } from '@ember/object';
|
||||
import { typeOf } from '@ember/utils';
|
||||
import { PRIMARY_KEY } from 'consul-ui/models/intention';
|
||||
export default Service.extend({
|
||||
store: service('store'),
|
||||
findAllByDatacenter: function(dc) {
|
||||
return get(this, 'store').query('intention', { dc: dc });
|
||||
},
|
||||
findBySlug: function(slug, dc) {
|
||||
return get(this, 'store').queryRecord('intention', {
|
||||
id: slug,
|
||||
dc: dc,
|
||||
});
|
||||
},
|
||||
create: function() {
|
||||
return get(this, 'store').createRecord('intention');
|
||||
},
|
||||
persist: function(item) {
|
||||
return item.save();
|
||||
},
|
||||
remove: function(obj) {
|
||||
let item = obj;
|
||||
if (typeof obj.destroyRecord === 'undefined') {
|
||||
item = obj.get('data');
|
||||
}
|
||||
if (typeOf(item) === 'object') {
|
||||
item = get(this, 'store').peekRecord('intention', item[PRIMARY_KEY]);
|
||||
}
|
||||
return item.destroyRecord().then(item => {
|
||||
return get(this, 'store').unloadRecord(item);
|
||||
});
|
||||
},
|
||||
invalidate: function() {
|
||||
return get(this, 'store').unloadAll('intention');
|
||||
},
|
||||
});
|
|
@ -1,24 +0,0 @@
|
|||
import Service, { inject as service } from '@ember/service';
|
||||
import { get } from '@ember/object';
|
||||
export default Service.extend({
|
||||
store: service('store'),
|
||||
coordinates: service('coordinates'),
|
||||
findAllByDatacenter: function(dc) {
|
||||
return get(this, 'store').query('node', { dc: dc });
|
||||
},
|
||||
findBySlug: function(slug, dc) {
|
||||
return get(this, 'store')
|
||||
.queryRecord('node', {
|
||||
id: slug,
|
||||
dc: dc,
|
||||
})
|
||||
.then(node => {
|
||||
return get(this, 'coordinates')
|
||||
.findAllByDatacenter(dc)
|
||||
.then(function(res) {
|
||||
node.Coordinates = res;
|
||||
return node;
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
|
@ -0,0 +1,50 @@
|
|||
import Service, { inject as service } from '@ember/service';
|
||||
import { get } from '@ember/object';
|
||||
import { assert } from '@ember/debug';
|
||||
import { typeOf } from '@ember/utils';
|
||||
export default Service.extend({
|
||||
getModelName: function() {
|
||||
assert('RepositoryService.getModelName should be overridden', false);
|
||||
},
|
||||
getPrimaryKey: function() {
|
||||
assert('RepositoryService.getPrimaryKey should be overridden', false);
|
||||
},
|
||||
getSlugKey: function() {
|
||||
assert('RepositoryService.getSlugKey should be overridden', false);
|
||||
},
|
||||
//
|
||||
store: service('store'),
|
||||
findAllByDatacenter: function(dc) {
|
||||
return get(this, 'store').query(this.getModelName(), {
|
||||
dc: dc,
|
||||
});
|
||||
},
|
||||
findBySlug: function(slug, dc) {
|
||||
return get(this, 'store').queryRecord(this.getModelName(), {
|
||||
id: slug,
|
||||
dc: dc,
|
||||
});
|
||||
},
|
||||
create: function(obj) {
|
||||
// TODO: This should probably return a Promise
|
||||
return get(this, 'store').createRecord(this.getModelName(), obj);
|
||||
},
|
||||
persist: function(item) {
|
||||
return item.save();
|
||||
},
|
||||
remove: function(obj) {
|
||||
let item = obj;
|
||||
if (typeof obj.destroyRecord === 'undefined') {
|
||||
item = obj.get('data');
|
||||
}
|
||||
if (typeOf(item) === 'object') {
|
||||
item = get(this, 'store').peekRecord(this.getModelName(), item[this.getPrimaryKey()]);
|
||||
}
|
||||
return item.destroyRecord().then(item => {
|
||||
return get(this, 'store').unloadRecord(item);
|
||||
});
|
||||
},
|
||||
invalidate: function() {
|
||||
get(this, 'store').unloadAll(this.getModelName());
|
||||
},
|
||||
});
|
|
@ -0,0 +1,15 @@
|
|||
import RepositoryService from 'consul-ui/services/repository';
|
||||
import { get } from '@ember/object';
|
||||
import { PRIMARY_KEY } from 'consul-ui/models/acl';
|
||||
const modelName = 'acl';
|
||||
export default RepositoryService.extend({
|
||||
getModelName: function() {
|
||||
return modelName;
|
||||
},
|
||||
getPrimaryKey: function() {
|
||||
return PRIMARY_KEY;
|
||||
},
|
||||
clone: function(item) {
|
||||
return get(this, 'store').clone(this.getModelName(), get(item, this.getPrimaryKey()));
|
||||
},
|
||||
});
|
|
@ -0,0 +1,8 @@
|
|||
import RepositoryService from 'consul-ui/services/repository';
|
||||
|
||||
const modelName = 'coordinate';
|
||||
export default RepositoryService.extend({
|
||||
getModelName: function() {
|
||||
return modelName;
|
||||
},
|
||||
});
|
|
@ -1,10 +1,21 @@
|
|||
import Service, { inject as service } from '@ember/service';
|
||||
import RepositoryService from 'consul-ui/services/repository';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { get } from '@ember/object';
|
||||
import Error from '@ember/error';
|
||||
|
||||
export default Service.extend({
|
||||
store: service('store'),
|
||||
const modelName = 'dc';
|
||||
export default RepositoryService.extend({
|
||||
settings: service('settings'),
|
||||
getModelName: function() {
|
||||
return modelName;
|
||||
},
|
||||
findAll: function() {
|
||||
return get(this, 'store')
|
||||
.findAll(this.getModelName())
|
||||
.then(function(items) {
|
||||
return items.sortBy('Name');
|
||||
});
|
||||
},
|
||||
findBySlug: function(name, items) {
|
||||
if (name != null) {
|
||||
const item = items.findBy('Name', name);
|
||||
|
@ -34,11 +45,4 @@ export default Service.extend({
|
|||
}
|
||||
);
|
||||
},
|
||||
findAll: function() {
|
||||
return get(this, 'store')
|
||||
.findAll('dc')
|
||||
.then(function(items) {
|
||||
return items.sortBy('Name');
|
||||
});
|
||||
},
|
||||
});
|
|
@ -0,0 +1,11 @@
|
|||
import RepositoryService from 'consul-ui/services/repository';
|
||||
import { PRIMARY_KEY } from 'consul-ui/models/intention';
|
||||
const modelName = 'intention';
|
||||
export default RepositoryService.extend({
|
||||
getModelName: function() {
|
||||
return modelName;
|
||||
},
|
||||
getPrimaryKey: function() {
|
||||
return PRIMARY_KEY;
|
||||
},
|
||||
});
|
|
@ -1,17 +1,22 @@
|
|||
import Service, { inject as service } from '@ember/service';
|
||||
import { typeOf } from '@ember/utils';
|
||||
import RepositoryService from 'consul-ui/services/repository';
|
||||
import { Promise } from 'rsvp';
|
||||
import isFolder from 'consul-ui/utils/isFolder';
|
||||
import { get, set } from '@ember/object';
|
||||
import { PRIMARY_KEY } from 'consul-ui/models/kv';
|
||||
|
||||
export default Service.extend({
|
||||
store: service('store'),
|
||||
const modelName = 'kv';
|
||||
export default RepositoryService.extend({
|
||||
getModelName: function() {
|
||||
return modelName;
|
||||
},
|
||||
getPrimaryKey: function() {
|
||||
return PRIMARY_KEY;
|
||||
},
|
||||
// this one gives you the full object so key,values and meta
|
||||
findBySlug: function(key, dc) {
|
||||
if (isFolder(key)) {
|
||||
const id = JSON.stringify([dc, key]);
|
||||
let item = get(this, 'store').peekRecord('kv', id);
|
||||
let item = get(this, 'store').peekRecord(this.getModelName(), id);
|
||||
if (!item) {
|
||||
item = this.create();
|
||||
set(item, 'Key', key);
|
||||
|
@ -19,7 +24,7 @@ export default Service.extend({
|
|||
}
|
||||
return Promise.resolve(item);
|
||||
}
|
||||
return get(this, 'store').queryRecord('kv', {
|
||||
return get(this, 'store').queryRecord(this.getModelName(), {
|
||||
id: key,
|
||||
dc: dc,
|
||||
});
|
||||
|
@ -31,7 +36,7 @@ export default Service.extend({
|
|||
key = '';
|
||||
}
|
||||
return this.get('store')
|
||||
.query('kv', {
|
||||
.query(this.getModelName(), {
|
||||
id: key,
|
||||
dc: dc,
|
||||
separator: '/',
|
||||
|
@ -44,7 +49,7 @@ export default Service.extend({
|
|||
.catch(e => {
|
||||
if (e.errors && e.errors[0] && e.errors[0].status == '404') {
|
||||
const id = JSON.stringify([dc, key]);
|
||||
const record = get(this, 'store').peekRecord('kv', id);
|
||||
const record = get(this, 'store').peekRecord(this.getModelName(), id);
|
||||
if (record) {
|
||||
record.destroyRecord();
|
||||
}
|
||||
|
@ -52,25 +57,4 @@ export default Service.extend({
|
|||
throw e;
|
||||
});
|
||||
},
|
||||
create: function() {
|
||||
return get(this, 'store').createRecord('kv');
|
||||
},
|
||||
persist: function(item) {
|
||||
return item.save();
|
||||
},
|
||||
remove: function(obj) {
|
||||
let item = obj;
|
||||
if (typeof obj.destroyRecord === 'undefined') {
|
||||
item = obj.get('data');
|
||||
}
|
||||
if (typeOf(item) === 'object') {
|
||||
item = get(this, 'store').peekRecord('kv', item[PRIMARY_KEY]);
|
||||
}
|
||||
return item.destroyRecord().then(item => {
|
||||
return get(this, 'store').unloadRecord(item);
|
||||
});
|
||||
},
|
||||
invalidate: function() {
|
||||
return get(this, 'store').unloadAll('kv');
|
||||
},
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
import RepositoryService from 'consul-ui/services/repository';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { get } from '@ember/object';
|
||||
const modelName = 'node';
|
||||
export default RepositoryService.extend({
|
||||
coordinates: service('repository/coordinate'),
|
||||
getModelName: function() {
|
||||
return modelName;
|
||||
},
|
||||
findBySlug: function(slug, dc) {
|
||||
return this._super(...arguments).then(node => {
|
||||
return get(this, 'coordinates')
|
||||
.findAllByDatacenter(dc)
|
||||
.then(function(res) {
|
||||
node.Coordinates = res;
|
||||
return node;
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
|
@ -1,18 +1,12 @@
|
|||
import Service, { inject as service } from '@ember/service';
|
||||
import RepositoryService from 'consul-ui/services/repository';
|
||||
import { get, set } from '@ember/object';
|
||||
|
||||
export default Service.extend({
|
||||
store: service('store'),
|
||||
findAllByDatacenter: function(dc) {
|
||||
return get(this, 'store').query('service', { dc: dc });
|
||||
const modelName = 'service';
|
||||
export default RepositoryService.extend({
|
||||
getModelName: function() {
|
||||
return modelName;
|
||||
},
|
||||
findBySlug: function(slug, dc) {
|
||||
return get(this, 'store')
|
||||
.queryRecord('service', {
|
||||
id: slug,
|
||||
dc: dc,
|
||||
})
|
||||
.then(function(item) {
|
||||
return this._super(...arguments).then(function(item) {
|
||||
const nodes = get(item, 'Nodes');
|
||||
const service = get(nodes, 'firstObject');
|
||||
const tags = nodes
|
|
@ -0,0 +1,21 @@
|
|||
import RepositoryService from 'consul-ui/services/repository';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { get } from '@ember/object';
|
||||
|
||||
const modelName = 'session';
|
||||
export default RepositoryService.extend({
|
||||
store: service('store'),
|
||||
getModelName: function() {
|
||||
return modelName;
|
||||
},
|
||||
findByNode: function(node, dc) {
|
||||
return get(this, 'store').query(this.getModelName(), {
|
||||
id: node,
|
||||
dc: dc,
|
||||
});
|
||||
},
|
||||
// TODO: Why Key? Probably should be findBySlug like the others
|
||||
findByKey: function(slug, dc) {
|
||||
return this.findBySlug(slug, dc);
|
||||
},
|
||||
});
|
|
@ -1,24 +0,0 @@
|
|||
import Service, { inject as service } from '@ember/service';
|
||||
import { get } from '@ember/object';
|
||||
|
||||
export default Service.extend({
|
||||
store: service('store'),
|
||||
findByNode: function(node, dc) {
|
||||
return get(this, 'store').query('session', {
|
||||
id: node,
|
||||
dc: dc,
|
||||
});
|
||||
},
|
||||
// TODO: Why Key? Probably should be findBySlug like the others
|
||||
findByKey: function(slug, dc) {
|
||||
return get(this, 'store').queryRecord('session', {
|
||||
id: slug,
|
||||
dc: dc,
|
||||
});
|
||||
},
|
||||
remove: function(item) {
|
||||
return item.destroyRecord().then(item => {
|
||||
return get(this, 'store').unloadRecord(item);
|
||||
});
|
||||
},
|
||||
});
|
|
@ -1,8 +1,9 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
import repo from 'consul-ui/tests/helpers/repo';
|
||||
moduleFor('service:acls', 'Integration | Service | acls', {
|
||||
const NAME = 'acl';
|
||||
moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: ['service:store', 'model:acl', 'adapter:acl', 'serializer:acl', 'service:settings'],
|
||||
integration: true
|
||||
});
|
||||
const dc = 'dc-1';
|
||||
const id = 'token-name';
|
|
@ -1,15 +1,9 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
import repo from 'consul-ui/tests/helpers/repo';
|
||||
const NAME = 'coordinate';
|
||||
moduleFor(`service:${NAME}s`, `Integration | Service | ${NAME}s`, {
|
||||
moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: [
|
||||
'service:settings',
|
||||
'service:store',
|
||||
`adapter:${NAME}`,
|
||||
`serializer:${NAME}`,
|
||||
`model:${NAME}`,
|
||||
],
|
||||
integration: true
|
||||
});
|
||||
|
||||
const dc = 'dc-1';
|
|
@ -2,18 +2,9 @@ import { moduleFor, test } from 'ember-qunit';
|
|||
import { skip } from 'qunit';
|
||||
import repo from 'consul-ui/tests/helpers/repo';
|
||||
const NAME = 'dc';
|
||||
moduleFor(`service:${NAME}`, `Integration | Service | ${NAME}s`, {
|
||||
moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: [
|
||||
'service:settings',
|
||||
'service:store',
|
||||
`adapter:${NAME}`,
|
||||
`serializer:${NAME}`,
|
||||
`model:${NAME}`,
|
||||
// relationships
|
||||
'model:service',
|
||||
'model:node',
|
||||
],
|
||||
integration: true,
|
||||
});
|
||||
skip("findBySlug (doesn't interact with the API) but still needs an int test");
|
||||
test('findAll returns the correct data for list endpoint', function(assert) {
|
|
@ -1,7 +1,7 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
import repo from 'consul-ui/tests/helpers/repo';
|
||||
const NAME = 'intention';
|
||||
moduleFor(`service:${NAME}s`, `Integration | Service | ${NAME}s`, {
|
||||
moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: [
|
||||
'service:settings',
|
|
@ -1,16 +1,9 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
import repo from 'consul-ui/tests/helpers/repo';
|
||||
const NAME = 'kv';
|
||||
moduleFor(`service:${NAME}`, `Integration | Service | ${NAME}s`, {
|
||||
moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: [
|
||||
'service:settings',
|
||||
'service:store',
|
||||
`adapter:${NAME}`,
|
||||
`serializer:${NAME}`,
|
||||
`model:${NAME}`,
|
||||
'service:atob',
|
||||
],
|
||||
integration: true,
|
||||
});
|
||||
const dc = 'dc-1';
|
||||
const id = 'key-name';
|
|
@ -1,19 +1,9 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
import repo from 'consul-ui/tests/helpers/repo';
|
||||
const NAME = 'node';
|
||||
moduleFor(`service:${NAME}s`, `Integration | Service | ${NAME}s`, {
|
||||
moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: [
|
||||
'service:settings',
|
||||
'service:store',
|
||||
`adapter:${NAME}`,
|
||||
`serializer:${NAME}`,
|
||||
`model:${NAME}`,
|
||||
'service:coordinates',
|
||||
'adapter:coordinate',
|
||||
'serializer:coordinate',
|
||||
'model:coordinate',
|
||||
],
|
||||
integration: true,
|
||||
});
|
||||
|
||||
const dc = 'dc-1';
|
|
@ -1,15 +1,10 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
import { skip } from 'qunit';
|
||||
import repo from 'consul-ui/tests/helpers/repo';
|
||||
moduleFor('service:services', 'Integration | Service | services', {
|
||||
const NAME = 'service';
|
||||
moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: [
|
||||
'service:store',
|
||||
'model:service',
|
||||
'adapter:service',
|
||||
'serializer:service',
|
||||
'service:settings',
|
||||
],
|
||||
integration: true,
|
||||
});
|
||||
const dc = 'dc-1';
|
||||
const id = 'token-name';
|
|
@ -1,15 +1,9 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
import repo from 'consul-ui/tests/helpers/repo';
|
||||
const NAME = 'session';
|
||||
moduleFor(`service:${NAME}`, `Integration | Service | ${NAME}s`, {
|
||||
moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: [
|
||||
'service:settings',
|
||||
'service:store',
|
||||
`adapter:${NAME}`,
|
||||
`serializer:${NAME}`,
|
||||
`model:${NAME}`,
|
||||
],
|
||||
integration: true,
|
||||
});
|
||||
|
||||
const dc = 'dc-1';
|
|
@ -1,8 +1,8 @@
|
|||
import { moduleFor } from 'ember-qunit';
|
||||
import test from 'ember-sinon-qunit/test-support/test';
|
||||
import { getOwner } from '@ember/application';
|
||||
import Route from 'consul-ui/routes/dc/acls/index';
|
||||
import Service from '@ember/service';
|
||||
import Route from 'consul-ui/routes/dc/acls/index';
|
||||
|
||||
import Mixin from 'consul-ui/mixins/acl/with-actions';
|
||||
|
||||
|
@ -14,7 +14,7 @@ moduleFor('mixin:acl/with-actions', 'Unit | Mixin | acl/with actions', {
|
|||
'service:flashMessages',
|
||||
'service:logger',
|
||||
'service:settings',
|
||||
'service:acls',
|
||||
'service:repository/acl',
|
||||
],
|
||||
subject: function() {
|
||||
const MixedIn = Route.extend(Mixin);
|
||||
|
@ -72,7 +72,7 @@ test('clone clones the token and calls afterDelete correctly', function(assert)
|
|||
);
|
||||
const expected = { ID: 'id' };
|
||||
this.register(
|
||||
'service:acls',
|
||||
'service:repository/acl',
|
||||
Service.extend({
|
||||
clone: function(actual) {
|
||||
assert.deepEqual(actual, expected);
|
||||
|
|
|
@ -2,7 +2,7 @@ import { moduleFor, test } from 'ember-qunit';
|
|||
|
||||
moduleFor('route:application', 'Unit | Route | application', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: ['service:dc'],
|
||||
needs: ['service:repository/dc'],
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
|
|
|
@ -3,7 +3,7 @@ import test from 'ember-sinon-qunit/test-support/test';
|
|||
|
||||
moduleFor('route:dc', 'Unit | Route | dc', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: ['service:dc', 'service:settings'],
|
||||
needs: ['service:repository/dc', 'service:settings'],
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
|
|
|
@ -3,7 +3,7 @@ import { moduleFor, test } from 'ember-qunit';
|
|||
moduleFor('route:dc/acls/create', 'Unit | Route | dc/acls/create', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: [
|
||||
'service:acls',
|
||||
'service:repository/acl',
|
||||
'service:feedback',
|
||||
'service:logger',
|
||||
'service:settings',
|
||||
|
|
|
@ -3,7 +3,7 @@ import { moduleFor, test } from 'ember-qunit';
|
|||
moduleFor('route:dc/acls/edit', 'Unit | Route | dc/acls/edit', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: [
|
||||
'service:acls',
|
||||
'service:repository/acl',
|
||||
'service:settings',
|
||||
'service:logger',
|
||||
'service:feedback',
|
||||
|
|
|
@ -3,7 +3,7 @@ import { moduleFor, test } from 'ember-qunit';
|
|||
moduleFor('route:dc/acls/index', 'Unit | Route | dc/acls/index', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: [
|
||||
'service:acls',
|
||||
'service:repository/acl',
|
||||
'service:feedback',
|
||||
'service:logger',
|
||||
'service:settings',
|
||||
|
|
|
@ -3,8 +3,8 @@ import { moduleFor, test } from 'ember-qunit';
|
|||
moduleFor('route:dc/intentions/create', 'Unit | Route | dc/intentions/create', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: [
|
||||
'service:services',
|
||||
'service:intentions',
|
||||
'service:repository/service',
|
||||
'service:repository/intention',
|
||||
'service:feedback',
|
||||
'service:logger',
|
||||
'service:flashMessages',
|
||||
|
|
|
@ -3,8 +3,8 @@ import { moduleFor, test } from 'ember-qunit';
|
|||
moduleFor('route:dc/intentions/edit', 'Unit | Route | dc/intentions/edit', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: [
|
||||
'service:services',
|
||||
'service:intentions',
|
||||
'service:repository/service',
|
||||
'service:repository/intention',
|
||||
'service:feedback',
|
||||
'service:logger',
|
||||
'service:flashMessages',
|
||||
|
|
|
@ -2,7 +2,12 @@ import { moduleFor, test } from 'ember-qunit';
|
|||
|
||||
moduleFor('route:dc/intentions/index', 'Unit | Route | dc/intentions/index', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: ['service:intentions', 'service:feedback', 'service:logger', 'service:flashMessages'],
|
||||
needs: [
|
||||
'service:repository/intention',
|
||||
'service:feedback',
|
||||
'service:logger',
|
||||
'service:flashMessages',
|
||||
],
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
|
|
|
@ -2,7 +2,7 @@ import { moduleFor, skip } from 'ember-qunit';
|
|||
|
||||
moduleFor('route:dc/kv/create', 'Unit | Route | dc/kv/create', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: ['service:kv', 'service:feedback', 'service:logger'],
|
||||
needs: ['service:repository/kv', 'service:feedback', 'service:logger'],
|
||||
});
|
||||
|
||||
skip('it exists', function(assert) {
|
||||
|
|
|
@ -3,8 +3,8 @@ import { moduleFor, test } from 'ember-qunit';
|
|||
moduleFor('route:dc/kv/edit', 'Unit | Route | dc/kv/edit', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: [
|
||||
'service:kv',
|
||||
'service:session',
|
||||
'service:repository/kv',
|
||||
'service:repository/session',
|
||||
'service:feedback',
|
||||
'service:logger',
|
||||
'service:flashMessages',
|
||||
|
|
|
@ -2,7 +2,7 @@ import { moduleFor, test } from 'ember-qunit';
|
|||
|
||||
moduleFor('route:dc/kv/index', 'Unit | Route | dc/kv/index', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: ['service:kv', 'service:feedback', 'service:logger', 'service:flashMessages'],
|
||||
needs: ['service:repository/kv', 'service:feedback', 'service:logger', 'service:flashMessages'],
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
|
|
|
@ -2,7 +2,7 @@ import { moduleFor, test } from 'ember-qunit';
|
|||
|
||||
moduleFor('route:dc/kv/root-create', 'Unit | Route | dc/kv/root create', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: ['service:kv', 'service:feedback', 'service:logger', 'service:flashMessages'],
|
||||
needs: ['service:repository/kv', 'service:feedback', 'service:logger', 'service:flashMessages'],
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
|
|
|
@ -2,7 +2,7 @@ import { moduleFor, test } from 'ember-qunit';
|
|||
|
||||
moduleFor('route:dc/nodes/index', 'Unit | Route | dc/nodes/index', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: ['service:nodes']
|
||||
needs: ['service:repository/node'],
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
|
|
|
@ -3,8 +3,8 @@ import { moduleFor, test } from 'ember-qunit';
|
|||
moduleFor('route:dc/nodes/show', 'Unit | Route | dc/nodes/show', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: [
|
||||
'service:nodes',
|
||||
'service:session',
|
||||
'service:repository/node',
|
||||
'service:repository/session',
|
||||
'service:feedback',
|
||||
'service:logger',
|
||||
'service:flashMessages',
|
||||
|
|
|
@ -2,7 +2,7 @@ import { moduleFor, test } from 'ember-qunit';
|
|||
|
||||
moduleFor('route:dc/services/index', 'Unit | Route | dc/services/index', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: ['service:services']
|
||||
needs: ['service:repository/service'],
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
|
|
|
@ -2,7 +2,7 @@ import { moduleFor, test } from 'ember-qunit';
|
|||
|
||||
moduleFor('route:dc/services/show', 'Unit | Route | dc/services/show', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: ['service:services'],
|
||||
needs: ['service:repository/service'],
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
|
|
|
@ -4,7 +4,7 @@ import test from 'ember-sinon-qunit/test-support/test';
|
|||
|
||||
moduleFor('route:index', 'Unit | Route | index', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: ['service:dc'],
|
||||
needs: ['service:repository/dc'],
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
|
|
|
@ -3,7 +3,7 @@ import { moduleFor, test } from 'ember-qunit';
|
|||
moduleFor('route:settings', 'Unit | Route | settings', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: [
|
||||
'service:dc',
|
||||
'service:repository/dc',
|
||||
'service:settings',
|
||||
'service:logger',
|
||||
'service:feedback',
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('service:nodes', 'Unit | Service | nodes', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: ['service:coordinates'],
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let service = this.subject();
|
||||
assert.ok(service);
|
||||
});
|
|
@ -1,6 +1,6 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('service:intentions', 'Unit | Service | intentions', {
|
||||
moduleFor('service:repository', 'Unit | Service | repository', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['service:foo']
|
||||
});
|
|
@ -1,6 +1,6 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('service:kv', 'Unit | Service | kv', {
|
||||
moduleFor('service:acl', 'Unit | Service | acl', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['service:foo']
|
||||
});
|
|
@ -1,6 +1,6 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('service:acls', 'Unit | Service | acls', {
|
||||
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/coordinate', 'Unit | Service | coordinate', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['service:foo']
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let service = this.subject();
|
||||
assert.ok(service);
|
||||
});
|
|
@ -1,6 +1,6 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('service:dc', 'Unit | Service | dc', {
|
||||
moduleFor('service:repository/dc', 'Unit | Service | dc', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: ['service:settings'],
|
||||
});
|
|
@ -0,0 +1,12 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('service:repository/intention', 'Unit | Service | intention', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['service:foo']
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let service = this.subject();
|
||||
assert.ok(service);
|
||||
});
|
|
@ -1,6 +1,6 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('service:session', 'Unit | Service | session', {
|
||||
moduleFor('service:repository/kv', 'Unit | Service | kv', {
|
||||
// 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/node', 'Unit | Service | node', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: ['service:repository/coordinate'],
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let service = this.subject();
|
||||
assert.ok(service);
|
||||
});
|
|
@ -1,6 +1,6 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('service:coordinates', 'Unit | Service | coordinates', {
|
||||
moduleFor('service:repository/service', 'Unit | Service | service', {
|
||||
// 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/session', 'Unit | Service | session', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['service:foo']
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let service = this.subject();
|
||||
assert.ok(service);
|
||||
});
|
|
@ -1,12 +0,0 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('service:services', 'Unit | Service | services', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['service:foo']
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let service = this.subject();
|
||||
assert.ok(service);
|
||||
});
|
Loading…
Reference in New Issue