diff --git a/ui-v2/app/mixins/with-feedback.js b/ui-v2/app/mixins/with-feedback.js index 2aaeaa7cfe..4038e70c6e 100644 --- a/ui-v2/app/mixins/with-feedback.js +++ b/ui-v2/app/mixins/with-feedback.js @@ -3,11 +3,15 @@ import { inject as service } from '@ember/service'; import { get, set } from '@ember/object'; export default Mixin.create({ - feedback: service('feedback'), + _feedback: service('feedback'), init: function() { this._super(...arguments); + const feedback = get(this, '_feedback'); + const route = this; set(this, 'feedback', { - execute: get(this, 'feedback').execute.bind(this), + execute: function() { + feedback.execute(...[...arguments, route.controller]); + }, }); }, }); diff --git a/ui-v2/app/services/feedback.js b/ui-v2/app/services/feedback.js index 09bfaf51d4..db50268837 100644 --- a/ui-v2/app/services/feedback.js +++ b/ui-v2/app/services/feedback.js @@ -1,35 +1,35 @@ -import Service from '@ember/service'; -import { inject as service } from '@ember/service'; -import { get } from '@ember/object'; +import Service, { inject as service } from '@ember/service'; +import { get, set } from '@ember/object'; export default Service.extend({ - // TODO: Why can't I name this `notify`? - flashMessages: service('flashMessages'), - execute: function(handle, success, error) { - const controller = this.controller; - controller.set('isLoading', true); + notify: service('flashMessages'), + logger: service('logger'), + execute: function(handle, success, error, controller) { + set(controller, 'isLoading', true); + const notify = get(this, 'notify'); return handle() .then(() => { - get(this, 'flashMessages').add({ + notify.add({ type: 'success', message: success, }); }) .catch(e => { + get(this, 'logger').execute(e); if (e.name === 'TransitionAborted') { - get(this, 'flashMessages').add({ + notify.add({ type: 'success', message: success, }); } else { - get(this, 'flashMessages').add({ + notify.add({ type: 'error', message: error, }); } }) .finally(function() { - controller.set('isLoading', false); + set(controller, 'isLoading', false); }); }, }); diff --git a/ui-v2/app/services/logger.js b/ui-v2/app/services/logger.js new file mode 100644 index 0000000000..c8e80171bf --- /dev/null +++ b/ui-v2/app/services/logger.js @@ -0,0 +1,5 @@ +import Service from '@ember/service'; + +export default Service.extend({ + execute: function(obj) {}, +}); 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 9488d05a74..0edf28c51e 100644 --- a/ui-v2/tests/unit/routes/dc/acls/create-test.js +++ b/ui-v2/tests/unit/routes/dc/acls/create-test.js @@ -2,7 +2,13 @@ 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:feedback', 'service:settings', 'service:flashMessages'], + needs: [ + 'service:acls', + 'service:feedback', + 'service:logger', + 'service:settings', + 'service:flashMessages', + ], }); test('it exists', function(assert) { 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 c6df83594b..e503f3ebb5 100644 --- a/ui-v2/tests/unit/routes/dc/acls/edit-test.js +++ b/ui-v2/tests/unit/routes/dc/acls/edit-test.js @@ -2,7 +2,13 @@ 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:settings', 'service:feedback', 'service:flashMessages'], + needs: [ + 'service:acls', + 'service:settings', + 'service:logger', + 'service:feedback', + 'service:flashMessages', + ], }); test('it exists', function(assert) { 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 7ab2ac7d88..07be1d7694 100644 --- a/ui-v2/tests/unit/routes/dc/acls/index-test.js +++ b/ui-v2/tests/unit/routes/dc/acls/index-test.js @@ -2,7 +2,13 @@ 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:feedback', 'service:settings', 'service:flashMessages'], + needs: [ + 'service:acls', + 'service:feedback', + 'service:logger', + 'service:settings', + '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 4c8ce699a6..93d06f4ab3 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'] + needs: ['service: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 3839b4452a..d687faa9bd 100644 --- a/ui-v2/tests/unit/routes/dc/kv/edit-test.js +++ b/ui-v2/tests/unit/routes/dc/kv/edit-test.js @@ -2,7 +2,13 @@ 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:feedback', 'service:flashMessages'], + needs: [ + 'service:kv', + 'service:session', + 'service:feedback', + 'service:logger', + 'service:flashMessages', + ], }); test('it exists', function(assert) { 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 bf82dd2b2d..fa035ccb3c 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:flashMessages'], + needs: ['service: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 97b7391a09..ca367e1f22 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:flashMessages'], + needs: ['service:kv', 'service:feedback', 'service:logger', 'service:flashMessages'], }); 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 ce848211f2..fa5b154558 100644 --- a/ui-v2/tests/unit/routes/dc/nodes/show-test.js +++ b/ui-v2/tests/unit/routes/dc/nodes/show-test.js @@ -2,7 +2,13 @@ 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:feedback', 'service:flashMessages'], + needs: [ + 'service:nodes', + 'service:session', + 'service:feedback', + 'service:logger', + 'service:flashMessages', + ], }); 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 3cb8801efa..1101d17576 100644 --- a/ui-v2/tests/unit/routes/settings-test.js +++ b/ui-v2/tests/unit/routes/settings-test.js @@ -2,7 +2,13 @@ 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:settings', 'service:feedback', 'service:flashMessages'], + needs: [ + 'service:dc', + 'service:settings', + 'service:logger', + 'service:feedback', + 'service:flashMessages', + ], }); test('it exists', function(assert) { diff --git a/ui-v2/tests/unit/services/feedback-test.js b/ui-v2/tests/unit/services/feedback-test.js index fc652d97c8..d9a937fdb7 100644 --- a/ui-v2/tests/unit/services/feedback-test.js +++ b/ui-v2/tests/unit/services/feedback-test.js @@ -2,7 +2,7 @@ import { moduleFor, test } from 'ember-qunit'; moduleFor('service:feedback', 'Unit | Service | feedback', { // Specify the other units that are required for this test. - needs: ['service:flashMessages'], + needs: ['service:logger', 'service:flashMessages'], }); // Replace this with your real tests.