From a7228cf83dba43fbe938ac5ef81aaf2d0920911a Mon Sep 17 00:00:00 2001 From: John Cowen Date: Fri, 26 Oct 2018 17:36:15 +0100 Subject: [PATCH] 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 --- ui-v2/app/routes/application.js | 2 +- ui-v2/app/routes/dc.js | 2 +- ui-v2/app/routes/dc/acls/create.js | 2 +- ui-v2/app/routes/dc/acls/edit.js | 2 +- ui-v2/app/routes/dc/acls/index.js | 2 +- ui-v2/app/routes/dc/intentions/create.js | 4 +- ui-v2/app/routes/dc/intentions/edit.js | 4 +- ui-v2/app/routes/dc/intentions/index.js | 2 +- ui-v2/app/routes/dc/kv/create.js | 2 +- ui-v2/app/routes/dc/kv/edit.js | 4 +- ui-v2/app/routes/dc/kv/index.js | 2 +- ui-v2/app/routes/dc/nodes/index.js | 2 +- ui-v2/app/routes/dc/nodes/show.js | 4 +- ui-v2/app/routes/dc/services/index.js | 2 +- ui-v2/app/routes/dc/services/show.js | 2 +- ui-v2/app/routes/index.js | 2 +- ui-v2/app/routes/settings.js | 2 +- ui-v2/app/services/acls.js | 42 ---------------- ui-v2/app/services/coordinates.js | 9 ---- ui-v2/app/services/intentions.js | 37 -------------- ui-v2/app/services/nodes.js | 24 --------- ui-v2/app/services/repository.js | 50 +++++++++++++++++++ ui-v2/app/services/repository/acl.js | 15 ++++++ ui-v2/app/services/repository/coordinate.js | 8 +++ ui-v2/app/services/{ => repository}/dc.js | 24 +++++---- ui-v2/app/services/repository/intention.js | 11 ++++ ui-v2/app/services/{ => repository}/kv.js | 42 +++++----------- ui-v2/app/services/repository/node.js | 20 ++++++++ .../{services.js => repository/service.js} | 18 +++---- ui-v2/app/services/repository/session.js | 21 ++++++++ ui-v2/app/services/session.js | 24 --------- .../{acls-test.js => repository/acl-test.js} | 5 +- .../coordinate-test.js} | 10 +--- .../services/{ => repository}/dc-test.js | 13 +---- .../intention-test.js} | 2 +- .../{kvs-test.js => repository/kv-test.js} | 11 +--- .../node-test.js} | 14 +----- .../service-test.js} | 11 ++-- .../session-test.js} | 10 +--- .../unit/mixins/acl/with-actions-test.js | 6 +-- ui-v2/tests/unit/routes/application-test.js | 2 +- ui-v2/tests/unit/routes/dc-test.js | 2 +- .../tests/unit/routes/dc/acls/create-test.js | 2 +- ui-v2/tests/unit/routes/dc/acls/edit-test.js | 2 +- ui-v2/tests/unit/routes/dc/acls/index-test.js | 2 +- .../unit/routes/dc/intentions/create-test.js | 4 +- .../unit/routes/dc/intentions/edit-test.js | 4 +- .../unit/routes/dc/intentions/index-test.js | 7 ++- ui-v2/tests/unit/routes/dc/kv/create-test.js | 2 +- ui-v2/tests/unit/routes/dc/kv/edit-test.js | 4 +- ui-v2/tests/unit/routes/dc/kv/index-test.js | 2 +- .../unit/routes/dc/kv/root-create-test.js | 2 +- .../tests/unit/routes/dc/nodes/index-test.js | 2 +- ui-v2/tests/unit/routes/dc/nodes/show-test.js | 4 +- .../unit/routes/dc/services/index-test.js | 2 +- .../unit/routes/dc/services/show-test.js | 2 +- ui-v2/tests/unit/routes/index-test.js | 2 +- ui-v2/tests/unit/routes/settings-test.js | 2 +- ui-v2/tests/unit/services/nodes-test.js | 12 ----- ...{intentions-test.js => repository-test.js} | 2 +- .../{kv-test.js => repository/acl-test.js} | 2 +- .../services/{ => repository}/acls-test.js | 2 +- .../services/repository/coordinate-test.js | 12 +++++ .../unit/services/{ => repository}/dc-test.js | 2 +- .../services/repository/intention-test.js | 12 +++++ .../kv-test.js} | 2 +- .../unit/services/repository/node-test.js | 12 +++++ .../service-test.js} | 2 +- .../unit/services/repository/session-test.js | 12 +++++ ui-v2/tests/unit/services/services-test.js | 12 ----- 70 files changed, 280 insertions(+), 322 deletions(-) delete mode 100644 ui-v2/app/services/acls.js delete mode 100644 ui-v2/app/services/coordinates.js delete mode 100644 ui-v2/app/services/intentions.js delete mode 100644 ui-v2/app/services/nodes.js create mode 100644 ui-v2/app/services/repository.js create mode 100644 ui-v2/app/services/repository/acl.js create mode 100644 ui-v2/app/services/repository/coordinate.js rename ui-v2/app/services/{ => repository}/dc.js (82%) create mode 100644 ui-v2/app/services/repository/intention.js rename ui-v2/app/services/{ => repository}/kv.js (56%) create mode 100644 ui-v2/app/services/repository/node.js rename ui-v2/app/services/{services.js => repository/service.js} (56%) create mode 100644 ui-v2/app/services/repository/session.js delete mode 100644 ui-v2/app/services/session.js rename ui-v2/tests/integration/services/{acls-test.js => repository/acl-test.js} (91%) rename ui-v2/tests/integration/services/{coordinates-test.js => repository/coordinate-test.js} (82%) rename ui-v2/tests/integration/services/{ => repository}/dc-test.js (79%) rename ui-v2/tests/integration/services/{intentions-test.js => repository/intention-test.js} (96%) rename ui-v2/tests/integration/services/{kvs-test.js => repository/kv-test.js} (87%) rename ui-v2/tests/integration/services/{nodes-test.js => repository/node-test.js} (83%) rename ui-v2/tests/integration/services/{services-test.js => repository/service-test.js} (91%) rename ui-v2/tests/integration/services/{sessions-test.js => repository/session-test.js} (88%) delete mode 100644 ui-v2/tests/unit/services/nodes-test.js rename ui-v2/tests/unit/services/{intentions-test.js => repository-test.js} (81%) rename ui-v2/tests/unit/services/{kv-test.js => repository/acl-test.js} (84%) rename ui-v2/tests/unit/services/{ => repository}/acls-test.js (81%) create mode 100644 ui-v2/tests/unit/services/repository/coordinate-test.js rename ui-v2/tests/unit/services/{ => repository}/dc-test.js (82%) create mode 100644 ui-v2/tests/unit/services/repository/intention-test.js rename ui-v2/tests/unit/services/{session-test.js => repository/kv-test.js} (82%) create mode 100644 ui-v2/tests/unit/services/repository/node-test.js rename ui-v2/tests/unit/services/{coordinates-test.js => repository/service-test.js} (79%) create mode 100644 ui-v2/tests/unit/services/repository/session-test.js delete mode 100644 ui-v2/tests/unit/services/services-test.js diff --git a/ui-v2/app/routes/application.js b/ui-v2/app/routes/application.js index 2f17c18c4..662ea9a66 100644 --- a/ui-v2/app/routes/application.js +++ b/ui-v2/app/routes/application.js @@ -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; diff --git a/ui-v2/app/routes/dc.js b/ui-v2/app/routes/dc.js index 5d51eb057..6b8f466a4 100644 --- a/ui-v2/app/routes/dc.js +++ b/ui-v2/app/routes/dc.js @@ -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'); diff --git a/ui-v2/app/routes/dc/acls/create.js b/ui-v2/app/routes/dc/acls/create.js index ee36d0603..315a07fb6 100644 --- a/ui-v2/app/routes/dc/acls/create.js +++ b/ui-v2/app/routes/dc/acls/create.js @@ -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(); }, diff --git a/ui-v2/app/routes/dc/acls/edit.js b/ui-v2/app/routes/dc/acls/edit.js index 078aa4afc..565f90bbe 100644 --- a/ui-v2/app/routes/dc/acls/edit.js +++ b/ui-v2/app/routes/dc/acls/edit.js @@ -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({ diff --git a/ui-v2/app/routes/dc/acls/index.js b/ui-v2/app/routes/dc/acls/index.js index 6e7804d6b..a2fa9d363 100644 --- a/ui-v2/app/routes/dc/acls/index.js +++ b/ui-v2/app/routes/dc/acls/index.js @@ -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', diff --git a/ui-v2/app/routes/dc/intentions/create.js b/ui-v2/app/routes/dc/intentions/create.js index e2e57dc8f..a52a8429d 100644 --- a/ui-v2/app/routes/dc/intentions/create.js +++ b/ui-v2/app/routes/dc/intentions/create.js @@ -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(); }, diff --git a/ui-v2/app/routes/dc/intentions/edit.js b/ui-v2/app/routes/dc/intentions/edit.js index 91c6b9f09..16b085dbe 100644 --- a/ui-v2/app/routes/dc/intentions/edit.js +++ b/ui-v2/app/routes/dc/intentions/edit.js @@ -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, diff --git a/ui-v2/app/routes/dc/intentions/index.js b/ui-v2/app/routes/dc/intentions/index.js index cffb06830..ec41bf54a 100644 --- a/ui-v2/app/routes/dc/intentions/index.js +++ b/ui-v2/app/routes/dc/intentions/index.js @@ -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', diff --git a/ui-v2/app/routes/dc/kv/create.js b/ui-v2/app/routes/dc/kv/create.js index 37ab4e038..44ec169e5 100644 --- a/ui-v2/app/routes/dc/kv/create.js +++ b/ui-v2/app/routes/dc/kv/create.js @@ -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(); }, diff --git a/ui-v2/app/routes/dc/kv/edit.js b/ui-v2/app/routes/dc/kv/edit.js index 2cae40954..170e512f6 100644 --- a/ui-v2/app/routes/dc/kv/edit.js +++ b/ui-v2/app/routes/dc/kv/edit.js @@ -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; diff --git a/ui-v2/app/routes/dc/kv/index.js b/ui-v2/app/routes/dc/kv/index.js index 10ce8ae1c..21ef89dc0 100644 --- a/ui-v2/app/routes/dc/kv/index.js +++ b/ui-v2/app/routes/dc/kv/index.js @@ -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 diff --git a/ui-v2/app/routes/dc/nodes/index.js b/ui-v2/app/routes/dc/nodes/index.js index 6b71d287a..548839745 100644 --- a/ui-v2/app/routes/dc/nodes/index.js +++ b/ui-v2/app/routes/dc/nodes/index.js @@ -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', diff --git a/ui-v2/app/routes/dc/nodes/show.js b/ui-v2/app/routes/dc/nodes/show.js index b13402edc..9d9f34458 100644 --- a/ui-v2/app/routes/dc/nodes/show.js +++ b/ui-v2/app/routes/dc/nodes/show.js @@ -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', diff --git a/ui-v2/app/routes/dc/services/index.js b/ui-v2/app/routes/dc/services/index.js index 22fcad990..7b74816db 100644 --- a/ui-v2/app/routes/dc/services/index.js +++ b/ui-v2/app/routes/dc/services/index.js @@ -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', diff --git a/ui-v2/app/routes/dc/services/show.js b/ui-v2/app/routes/dc/services/show.js index 2fa74c8dd..bf5fa0d65 100644 --- a/ui-v2/app/routes/dc/services/show.js +++ b/ui-v2/app/routes/dc/services/show.js @@ -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', diff --git a/ui-v2/app/routes/index.js b/ui-v2/app/routes/index.js index 05776118e..022551c4e 100644 --- a/ui-v2/app/routes/index.js +++ b/ui-v2/app/routes/index.js @@ -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(), diff --git a/ui-v2/app/routes/settings.js b/ui-v2/app/routes/settings.js index e7b07115c..c5f9701b6 100644 --- a/ui-v2/app/routes/settings.js +++ b/ui-v2/app/routes/settings.js @@ -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(), diff --git a/ui-v2/app/services/acls.js b/ui-v2/app/services/acls.js deleted file mode 100644 index 5249f1d74..000000000 --- a/ui-v2/app/services/acls.js +++ /dev/null @@ -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'); - }, -}); diff --git a/ui-v2/app/services/coordinates.js b/ui-v2/app/services/coordinates.js deleted file mode 100644 index 85dea8ea6..000000000 --- a/ui-v2/app/services/coordinates.js +++ /dev/null @@ -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 }); - }, -}); diff --git a/ui-v2/app/services/intentions.js b/ui-v2/app/services/intentions.js deleted file mode 100644 index 5d87bdfcd..000000000 --- a/ui-v2/app/services/intentions.js +++ /dev/null @@ -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'); - }, -}); diff --git a/ui-v2/app/services/nodes.js b/ui-v2/app/services/nodes.js deleted file mode 100644 index e7ed82fac..000000000 --- a/ui-v2/app/services/nodes.js +++ /dev/null @@ -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; - }); - }); - }, -}); diff --git a/ui-v2/app/services/repository.js b/ui-v2/app/services/repository.js new file mode 100644 index 000000000..f7fe5ac0e --- /dev/null +++ b/ui-v2/app/services/repository.js @@ -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()); + }, +}); diff --git a/ui-v2/app/services/repository/acl.js b/ui-v2/app/services/repository/acl.js new file mode 100644 index 000000000..0fc28ae6a --- /dev/null +++ b/ui-v2/app/services/repository/acl.js @@ -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())); + }, +}); diff --git a/ui-v2/app/services/repository/coordinate.js b/ui-v2/app/services/repository/coordinate.js new file mode 100644 index 000000000..f6f5c1d8e --- /dev/null +++ b/ui-v2/app/services/repository/coordinate.js @@ -0,0 +1,8 @@ +import RepositoryService from 'consul-ui/services/repository'; + +const modelName = 'coordinate'; +export default RepositoryService.extend({ + getModelName: function() { + return modelName; + }, +}); diff --git a/ui-v2/app/services/dc.js b/ui-v2/app/services/repository/dc.js similarity index 82% rename from ui-v2/app/services/dc.js rename to ui-v2/app/services/repository/dc.js index 43e96c99b..f2e5f3e59 100644 --- a/ui-v2/app/services/dc.js +++ b/ui-v2/app/services/repository/dc.js @@ -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'); - }); - }, }); diff --git a/ui-v2/app/services/repository/intention.js b/ui-v2/app/services/repository/intention.js new file mode 100644 index 000000000..7df0cb8a5 --- /dev/null +++ b/ui-v2/app/services/repository/intention.js @@ -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; + }, +}); diff --git a/ui-v2/app/services/kv.js b/ui-v2/app/services/repository/kv.js similarity index 56% rename from ui-v2/app/services/kv.js rename to ui-v2/app/services/repository/kv.js index 0f903b537..6185c9022 100644 --- a/ui-v2/app/services/kv.js +++ b/ui-v2/app/services/repository/kv.js @@ -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'); - }, }); diff --git a/ui-v2/app/services/repository/node.js b/ui-v2/app/services/repository/node.js new file mode 100644 index 000000000..0d7eb5734 --- /dev/null +++ b/ui-v2/app/services/repository/node.js @@ -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; + }); + }); + }, +}); diff --git a/ui-v2/app/services/services.js b/ui-v2/app/services/repository/service.js similarity index 56% rename from ui-v2/app/services/services.js rename to ui-v2/app/services/repository/service.js index 254008c62..5654c3a61 100644 --- a/ui-v2/app/services/services.js +++ b/ui-v2/app/services/repository/service.js @@ -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 diff --git a/ui-v2/app/services/repository/session.js b/ui-v2/app/services/repository/session.js new file mode 100644 index 000000000..9dace862d --- /dev/null +++ b/ui-v2/app/services/repository/session.js @@ -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); + }, +}); diff --git a/ui-v2/app/services/session.js b/ui-v2/app/services/session.js deleted file mode 100644 index 9260bd003..000000000 --- a/ui-v2/app/services/session.js +++ /dev/null @@ -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); - }); - }, -}); diff --git a/ui-v2/tests/integration/services/acls-test.js b/ui-v2/tests/integration/services/repository/acl-test.js similarity index 91% rename from ui-v2/tests/integration/services/acls-test.js rename to ui-v2/tests/integration/services/repository/acl-test.js index 4902b55ef..f5b707e0b 100644 --- a/ui-v2/tests/integration/services/acls-test.js +++ b/ui-v2/tests/integration/services/repository/acl-test.js @@ -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'; diff --git a/ui-v2/tests/integration/services/coordinates-test.js b/ui-v2/tests/integration/services/repository/coordinate-test.js similarity index 82% rename from ui-v2/tests/integration/services/coordinates-test.js rename to ui-v2/tests/integration/services/repository/coordinate-test.js index 2fbf162f0..1c0f07f7f 100644 --- a/ui-v2/tests/integration/services/coordinates-test.js +++ b/ui-v2/tests/integration/services/repository/coordinate-test.js @@ -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'; diff --git a/ui-v2/tests/integration/services/dc-test.js b/ui-v2/tests/integration/services/repository/dc-test.js similarity index 79% rename from ui-v2/tests/integration/services/dc-test.js rename to ui-v2/tests/integration/services/repository/dc-test.js index 6a296b7cb..7333fab6b 100644 --- a/ui-v2/tests/integration/services/dc-test.js +++ b/ui-v2/tests/integration/services/repository/dc-test.js @@ -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) { diff --git a/ui-v2/tests/integration/services/intentions-test.js b/ui-v2/tests/integration/services/repository/intention-test.js similarity index 96% rename from ui-v2/tests/integration/services/intentions-test.js rename to ui-v2/tests/integration/services/repository/intention-test.js index fa04fa4b4..bedfbb9f2 100644 --- a/ui-v2/tests/integration/services/intentions-test.js +++ b/ui-v2/tests/integration/services/repository/intention-test.js @@ -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', diff --git a/ui-v2/tests/integration/services/kvs-test.js b/ui-v2/tests/integration/services/repository/kv-test.js similarity index 87% rename from ui-v2/tests/integration/services/kvs-test.js rename to ui-v2/tests/integration/services/repository/kv-test.js index 3926fae5c..a1b48badc 100644 --- a/ui-v2/tests/integration/services/kvs-test.js +++ b/ui-v2/tests/integration/services/repository/kv-test.js @@ -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'; diff --git a/ui-v2/tests/integration/services/nodes-test.js b/ui-v2/tests/integration/services/repository/node-test.js similarity index 83% rename from ui-v2/tests/integration/services/nodes-test.js rename to ui-v2/tests/integration/services/repository/node-test.js index b438eea4d..8a6b4816d 100644 --- a/ui-v2/tests/integration/services/nodes-test.js +++ b/ui-v2/tests/integration/services/repository/node-test.js @@ -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'; diff --git a/ui-v2/tests/integration/services/services-test.js b/ui-v2/tests/integration/services/repository/service-test.js similarity index 91% rename from ui-v2/tests/integration/services/services-test.js rename to ui-v2/tests/integration/services/repository/service-test.js index 7e8b69ccb..630aa38e4 100644 --- a/ui-v2/tests/integration/services/services-test.js +++ b/ui-v2/tests/integration/services/repository/service-test.js @@ -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'; diff --git a/ui-v2/tests/integration/services/sessions-test.js b/ui-v2/tests/integration/services/repository/session-test.js similarity index 88% rename from ui-v2/tests/integration/services/sessions-test.js rename to ui-v2/tests/integration/services/repository/session-test.js index dadac1df6..cdc3fcc0a 100644 --- a/ui-v2/tests/integration/services/sessions-test.js +++ b/ui-v2/tests/integration/services/repository/session-test.js @@ -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'; diff --git a/ui-v2/tests/unit/mixins/acl/with-actions-test.js b/ui-v2/tests/unit/mixins/acl/with-actions-test.js index ade74b60f..7dba82823 100644 --- a/ui-v2/tests/unit/mixins/acl/with-actions-test.js +++ b/ui-v2/tests/unit/mixins/acl/with-actions-test.js @@ -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); diff --git a/ui-v2/tests/unit/routes/application-test.js b/ui-v2/tests/unit/routes/application-test.js index 386b5f1fc..1831cd9b8 100644 --- a/ui-v2/tests/unit/routes/application-test.js +++ b/ui-v2/tests/unit/routes/application-test.js @@ -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) { diff --git a/ui-v2/tests/unit/routes/dc-test.js b/ui-v2/tests/unit/routes/dc-test.js index 16c9f1881..7dc45ae66 100644 --- a/ui-v2/tests/unit/routes/dc-test.js +++ b/ui-v2/tests/unit/routes/dc-test.js @@ -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) { diff --git a/ui-v2/tests/unit/routes/dc/acls/create-test.js b/ui-v2/tests/unit/routes/dc/acls/create-test.js index 0edf28c51..1c7009f32 100644 --- a/ui-v2/tests/unit/routes/dc/acls/create-test.js +++ b/ui-v2/tests/unit/routes/dc/acls/create-test.js @@ -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', diff --git a/ui-v2/tests/unit/routes/dc/acls/edit-test.js b/ui-v2/tests/unit/routes/dc/acls/edit-test.js index e503f3ebb..c58806da0 100644 --- a/ui-v2/tests/unit/routes/dc/acls/edit-test.js +++ b/ui-v2/tests/unit/routes/dc/acls/edit-test.js @@ -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', diff --git a/ui-v2/tests/unit/routes/dc/acls/index-test.js b/ui-v2/tests/unit/routes/dc/acls/index-test.js index 07be1d769..5038879f8 100644 --- a/ui-v2/tests/unit/routes/dc/acls/index-test.js +++ b/ui-v2/tests/unit/routes/dc/acls/index-test.js @@ -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', diff --git a/ui-v2/tests/unit/routes/dc/intentions/create-test.js b/ui-v2/tests/unit/routes/dc/intentions/create-test.js index 97b24ee22..46a7339ae 100644 --- a/ui-v2/tests/unit/routes/dc/intentions/create-test.js +++ b/ui-v2/tests/unit/routes/dc/intentions/create-test.js @@ -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', diff --git a/ui-v2/tests/unit/routes/dc/intentions/edit-test.js b/ui-v2/tests/unit/routes/dc/intentions/edit-test.js index 50ce0ca78..97c44e72d 100644 --- a/ui-v2/tests/unit/routes/dc/intentions/edit-test.js +++ b/ui-v2/tests/unit/routes/dc/intentions/edit-test.js @@ -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', diff --git a/ui-v2/tests/unit/routes/dc/intentions/index-test.js b/ui-v2/tests/unit/routes/dc/intentions/index-test.js index 1d4d6c3e8..afc181fa3 100644 --- a/ui-v2/tests/unit/routes/dc/intentions/index-test.js +++ b/ui-v2/tests/unit/routes/dc/intentions/index-test.js @@ -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) { diff --git a/ui-v2/tests/unit/routes/dc/kv/create-test.js b/ui-v2/tests/unit/routes/dc/kv/create-test.js index 93d06f4ab..df313ef5d 100644 --- a/ui-v2/tests/unit/routes/dc/kv/create-test.js +++ b/ui-v2/tests/unit/routes/dc/kv/create-test.js @@ -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) { diff --git a/ui-v2/tests/unit/routes/dc/kv/edit-test.js b/ui-v2/tests/unit/routes/dc/kv/edit-test.js index d687faa9b..024e84d32 100644 --- a/ui-v2/tests/unit/routes/dc/kv/edit-test.js +++ b/ui-v2/tests/unit/routes/dc/kv/edit-test.js @@ -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', diff --git a/ui-v2/tests/unit/routes/dc/kv/index-test.js b/ui-v2/tests/unit/routes/dc/kv/index-test.js index fa035ccb3..d1719b2ae 100644 --- a/ui-v2/tests/unit/routes/dc/kv/index-test.js +++ b/ui-v2/tests/unit/routes/dc/kv/index-test.js @@ -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) { diff --git a/ui-v2/tests/unit/routes/dc/kv/root-create-test.js b/ui-v2/tests/unit/routes/dc/kv/root-create-test.js index ca367e1f2..963a04df3 100644 --- a/ui-v2/tests/unit/routes/dc/kv/root-create-test.js +++ b/ui-v2/tests/unit/routes/dc/kv/root-create-test.js @@ -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) { diff --git a/ui-v2/tests/unit/routes/dc/nodes/index-test.js b/ui-v2/tests/unit/routes/dc/nodes/index-test.js index b41bf938e..5ee1eaa78 100644 --- a/ui-v2/tests/unit/routes/dc/nodes/index-test.js +++ b/ui-v2/tests/unit/routes/dc/nodes/index-test.js @@ -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) { diff --git a/ui-v2/tests/unit/routes/dc/nodes/show-test.js b/ui-v2/tests/unit/routes/dc/nodes/show-test.js index fa5b15455..e6f486e6b 100644 --- a/ui-v2/tests/unit/routes/dc/nodes/show-test.js +++ b/ui-v2/tests/unit/routes/dc/nodes/show-test.js @@ -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', diff --git a/ui-v2/tests/unit/routes/dc/services/index-test.js b/ui-v2/tests/unit/routes/dc/services/index-test.js index 9fe5f2c7a..8b0f91513 100644 --- a/ui-v2/tests/unit/routes/dc/services/index-test.js +++ b/ui-v2/tests/unit/routes/dc/services/index-test.js @@ -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) { diff --git a/ui-v2/tests/unit/routes/dc/services/show-test.js b/ui-v2/tests/unit/routes/dc/services/show-test.js index cf6d08da9..773bf7326 100644 --- a/ui-v2/tests/unit/routes/dc/services/show-test.js +++ b/ui-v2/tests/unit/routes/dc/services/show-test.js @@ -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) { diff --git a/ui-v2/tests/unit/routes/index-test.js b/ui-v2/tests/unit/routes/index-test.js index c63d14762..c6574dd70 100644 --- a/ui-v2/tests/unit/routes/index-test.js +++ b/ui-v2/tests/unit/routes/index-test.js @@ -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) { diff --git a/ui-v2/tests/unit/routes/settings-test.js b/ui-v2/tests/unit/routes/settings-test.js index 1101d1757..52f71ebce 100644 --- a/ui-v2/tests/unit/routes/settings-test.js +++ b/ui-v2/tests/unit/routes/settings-test.js @@ -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', diff --git a/ui-v2/tests/unit/services/nodes-test.js b/ui-v2/tests/unit/services/nodes-test.js deleted file mode 100644 index fa03f80f8..000000000 --- a/ui-v2/tests/unit/services/nodes-test.js +++ /dev/null @@ -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); -}); diff --git a/ui-v2/tests/unit/services/intentions-test.js b/ui-v2/tests/unit/services/repository-test.js similarity index 81% rename from ui-v2/tests/unit/services/intentions-test.js rename to ui-v2/tests/unit/services/repository-test.js index fc2050c9c..ec5ce314c 100644 --- a/ui-v2/tests/unit/services/intentions-test.js +++ b/ui-v2/tests/unit/services/repository-test.js @@ -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'] }); diff --git a/ui-v2/tests/unit/services/kv-test.js b/ui-v2/tests/unit/services/repository/acl-test.js similarity index 84% rename from ui-v2/tests/unit/services/kv-test.js rename to ui-v2/tests/unit/services/repository/acl-test.js index aff16d72d..2edab4527 100644 --- a/ui-v2/tests/unit/services/kv-test.js +++ b/ui-v2/tests/unit/services/repository/acl-test.js @@ -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'] }); diff --git a/ui-v2/tests/unit/services/acls-test.js b/ui-v2/tests/unit/services/repository/acls-test.js similarity index 81% rename from ui-v2/tests/unit/services/acls-test.js rename to ui-v2/tests/unit/services/repository/acls-test.js index 579d6ebde..4ee3a64f5 100644 --- a/ui-v2/tests/unit/services/acls-test.js +++ b/ui-v2/tests/unit/services/repository/acls-test.js @@ -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'] }); diff --git a/ui-v2/tests/unit/services/repository/coordinate-test.js b/ui-v2/tests/unit/services/repository/coordinate-test.js new file mode 100644 index 000000000..738eb3893 --- /dev/null +++ b/ui-v2/tests/unit/services/repository/coordinate-test.js @@ -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); +}); diff --git a/ui-v2/tests/unit/services/dc-test.js b/ui-v2/tests/unit/services/repository/dc-test.js similarity index 82% rename from ui-v2/tests/unit/services/dc-test.js rename to ui-v2/tests/unit/services/repository/dc-test.js index 529881ce5..7d0299504 100644 --- a/ui-v2/tests/unit/services/dc-test.js +++ b/ui-v2/tests/unit/services/repository/dc-test.js @@ -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'], }); diff --git a/ui-v2/tests/unit/services/repository/intention-test.js b/ui-v2/tests/unit/services/repository/intention-test.js new file mode 100644 index 000000000..934379ad8 --- /dev/null +++ b/ui-v2/tests/unit/services/repository/intention-test.js @@ -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); +}); diff --git a/ui-v2/tests/unit/services/session-test.js b/ui-v2/tests/unit/services/repository/kv-test.js similarity index 82% rename from ui-v2/tests/unit/services/session-test.js rename to ui-v2/tests/unit/services/repository/kv-test.js index a027c0537..ac9994a8b 100644 --- a/ui-v2/tests/unit/services/session-test.js +++ b/ui-v2/tests/unit/services/repository/kv-test.js @@ -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'] }); diff --git a/ui-v2/tests/unit/services/repository/node-test.js b/ui-v2/tests/unit/services/repository/node-test.js new file mode 100644 index 000000000..cbf02f1c4 --- /dev/null +++ b/ui-v2/tests/unit/services/repository/node-test.js @@ -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); +}); diff --git a/ui-v2/tests/unit/services/coordinates-test.js b/ui-v2/tests/unit/services/repository/service-test.js similarity index 79% rename from ui-v2/tests/unit/services/coordinates-test.js rename to ui-v2/tests/unit/services/repository/service-test.js index 745267dfb..40caf2b7d 100644 --- a/ui-v2/tests/unit/services/coordinates-test.js +++ b/ui-v2/tests/unit/services/repository/service-test.js @@ -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'] }); diff --git a/ui-v2/tests/unit/services/repository/session-test.js b/ui-v2/tests/unit/services/repository/session-test.js new file mode 100644 index 000000000..0ef922864 --- /dev/null +++ b/ui-v2/tests/unit/services/repository/session-test.js @@ -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); +}); diff --git a/ui-v2/tests/unit/services/services-test.js b/ui-v2/tests/unit/services/services-test.js deleted file mode 100644 index 3d8485cc9..000000000 --- a/ui-v2/tests/unit/services/services-test.js +++ /dev/null @@ -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); -});