From 7f2a1e8a544d057b6f8d91dcb23c252151497bbe Mon Sep 17 00:00:00 2001 From: John Cowen Date: Wed, 11 Dec 2019 11:02:27 +0000 Subject: [PATCH] ui: Remove some javascript files we no longer use (#6853) --- ui-v2/app/components/confirmation-dialog.js | 18 +--------- ui-v2/app/models/intention.js | 1 + ui-v2/app/models/policy.js | 1 + ui-v2/app/models/token.js | 1 + ui-v2/app/services/confirm.js | 8 ----- ui-v2/app/services/error.js | 8 ----- ui-v2/app/utils/confirm.js | 4 --- ui-v2/app/utils/error.js | 5 --- .../injectableRequestToJQueryAjaxHash.js | 33 ------------------- ui-v2/app/utils/makeAttrable.js | 9 ----- ui-v2/tests/unit/services/confirm-test.js | 12 ------- ui-v2/tests/unit/services/error-test.js | 12 ------- ui-v2/tests/unit/utils/confirm-test.js | 17 ---------- ui-v2/tests/unit/utils/makeAttrable-test.js | 14 -------- 14 files changed, 4 insertions(+), 139 deletions(-) delete mode 100644 ui-v2/app/services/confirm.js delete mode 100644 ui-v2/app/services/error.js delete mode 100644 ui-v2/app/utils/confirm.js delete mode 100644 ui-v2/app/utils/error.js delete mode 100644 ui-v2/app/utils/injectableRequestToJQueryAjaxHash.js delete mode 100644 ui-v2/app/utils/makeAttrable.js delete mode 100644 ui-v2/tests/unit/services/confirm-test.js delete mode 100644 ui-v2/tests/unit/services/error-test.js delete mode 100644 ui-v2/tests/unit/utils/confirm-test.js delete mode 100644 ui-v2/tests/unit/utils/makeAttrable-test.js diff --git a/ui-v2/app/components/confirmation-dialog.js b/ui-v2/app/components/confirmation-dialog.js index d52b4cfaf4..b53dcd68ed 100644 --- a/ui-v2/app/components/confirmation-dialog.js +++ b/ui-v2/app/components/confirmation-dialog.js @@ -3,7 +3,6 @@ import Component from '@ember/component'; import SlotsMixin from 'block-slots'; import { set } from '@ember/object'; -import { inject as service } from '@ember/service'; const cancel = function() { set(this, 'confirming', false); @@ -15,25 +14,10 @@ const confirm = function() { const [action, ...args] = arguments; set(this, 'actionName', action); set(this, 'arguments', args); - if (this._isRegistered('dialog')) { - set(this, 'confirming', true); - } else { - this._confirm - .execute(this.message) - .then(confirmed => { - if (confirmed) { - this.execute(); - } - }) - .catch(function() { - return this.error.execute(...arguments); - }); - } + set(this, 'confirming', true); }; export default Component.extend(SlotsMixin, { classNameBindings: ['confirming'], - _confirm: service('confirm'), - error: service('error'), classNames: ['with-confirmation'], message: 'Are you sure?', confirming: false, diff --git a/ui-v2/app/models/intention.js b/ui-v2/app/models/intention.js index 8e5b01515d..b0c4f033ea 100644 --- a/ui-v2/app/models/intention.js +++ b/ui-v2/app/models/intention.js @@ -24,6 +24,7 @@ const model = Model.extend({ CreateIndex: attr('number'), ModifyIndex: attr('number'), }); +// TODO: Remove this in favour of just specifying it in the Adapter export const ATTRS = writable(model, [ 'Action', 'SourceName', diff --git a/ui-v2/app/models/policy.js b/ui-v2/app/models/policy.js index d002d57cb8..9dfa92ed28 100644 --- a/ui-v2/app/models/policy.js +++ b/ui-v2/app/models/policy.js @@ -29,5 +29,6 @@ const model = Model.extend({ defaultValue: '', }), }); +// TODO: Remove this in favour of just specifying it in the Adapter export const ATTRS = writable(model, ['Name', 'Description', 'Rules', 'Datacenters']); export default model; diff --git a/ui-v2/app/models/token.js b/ui-v2/app/models/token.js index 117b6dc796..32625eab26 100644 --- a/ui-v2/app/models/token.js +++ b/ui-v2/app/models/token.js @@ -43,6 +43,7 @@ const model = Model.extend({ CreateIndex: attr('number'), ModifyIndex: attr('number'), }); +// TODO: Remove this in favour of just specifying it in the Adapter // Name and Rules is only for legacy tokens export const ATTRS = writable(model, [ 'Name', diff --git a/ui-v2/app/services/confirm.js b/ui-v2/app/services/confirm.js deleted file mode 100644 index a001a63ea0..0000000000 --- a/ui-v2/app/services/confirm.js +++ /dev/null @@ -1,8 +0,0 @@ -import Service from '@ember/service'; -import confirm from 'consul-ui/utils/confirm'; -// TODO: This can go? -export default Service.extend({ - execute: function(message) { - return confirm(message); - }, -}); diff --git a/ui-v2/app/services/error.js b/ui-v2/app/services/error.js deleted file mode 100644 index 87571178f8..0000000000 --- a/ui-v2/app/services/error.js +++ /dev/null @@ -1,8 +0,0 @@ -import Service from '@ember/service'; -// TODO: This can go? -import error from 'consul-ui/utils/error'; -export default Service.extend({ - execute: function(obj) { - return error(obj); - }, -}); diff --git a/ui-v2/app/utils/confirm.js b/ui-v2/app/utils/confirm.js deleted file mode 100644 index cb9bf7a9f1..0000000000 --- a/ui-v2/app/utils/confirm.js +++ /dev/null @@ -1,4 +0,0 @@ -import { Promise } from 'rsvp'; -export default function(message, confirmation = confirm) { - return Promise.resolve(confirmation(message)); -} diff --git a/ui-v2/app/utils/error.js b/ui-v2/app/utils/error.js deleted file mode 100644 index 76b62f9312..0000000000 --- a/ui-v2/app/utils/error.js +++ /dev/null @@ -1,5 +0,0 @@ -/* eslint no-console: "off" */ -export default function(e) { - /* istanbul ignore next */ - console.error(e); -} diff --git a/ui-v2/app/utils/injectableRequestToJQueryAjaxHash.js b/ui-v2/app/utils/injectableRequestToJQueryAjaxHash.js deleted file mode 100644 index 86faeb749d..0000000000 --- a/ui-v2/app/utils/injectableRequestToJQueryAjaxHash.js +++ /dev/null @@ -1,33 +0,0 @@ -// prettier-ignore -/* istanbul ignore file */ -export default function(JSON) { - // Has to be a property on an object so babel knocks the indentation in - return { - _requestToJQueryAjaxHash: function(request) { - let hash = {}; - - hash.type = request.method; - hash.url = request.url; - hash.dataType = 'json'; - hash.context = this; - - if (request.data) { - if (request.method !== 'GET') { - hash.contentType = 'application/json; charset=utf-8'; - hash.data = JSON.stringify(request.data); - } else { - hash.data = request.data; - } - } - - let headers = request.headers; - if (headers !== undefined) { - hash.beforeSend = function(xhr) { - Object.keys(headers).forEach((key) => xhr.setRequestHeader(key, headers[key])); - }; - } - - return hash; - } - }._requestToJQueryAjaxHash; -} diff --git a/ui-v2/app/utils/makeAttrable.js b/ui-v2/app/utils/makeAttrable.js deleted file mode 100644 index b6f6b85fd8..0000000000 --- a/ui-v2/app/utils/makeAttrable.js +++ /dev/null @@ -1,9 +0,0 @@ -// Used to make an pojo 'attr-able' -// i.e. you can call pojo.attr('key') on it -export default function(obj) { - return { - attr: function(prop) { - return obj[prop]; - }, - }; -} diff --git a/ui-v2/tests/unit/services/confirm-test.js b/ui-v2/tests/unit/services/confirm-test.js deleted file mode 100644 index c573fc2ed4..0000000000 --- a/ui-v2/tests/unit/services/confirm-test.js +++ /dev/null @@ -1,12 +0,0 @@ -import { module, test } from 'qunit'; -import { setupTest } from 'ember-qunit'; - -module('Unit | Service | confirm', function(hooks) { - setupTest(hooks); - - // Replace this with your real tests. - test('it exists', function(assert) { - let service = this.owner.lookup('service:confirm'); - assert.ok(service); - }); -}); diff --git a/ui-v2/tests/unit/services/error-test.js b/ui-v2/tests/unit/services/error-test.js deleted file mode 100644 index 4823754235..0000000000 --- a/ui-v2/tests/unit/services/error-test.js +++ /dev/null @@ -1,12 +0,0 @@ -import { module, test } from 'qunit'; -import { setupTest } from 'ember-qunit'; - -module('Unit | Service | error', function(hooks) { - setupTest(hooks); - - // Replace this with your real tests. - test('it exists', function(assert) { - let service = this.owner.lookup('service:error'); - assert.ok(service); - }); -}); diff --git a/ui-v2/tests/unit/utils/confirm-test.js b/ui-v2/tests/unit/utils/confirm-test.js deleted file mode 100644 index 48cd0d455a..0000000000 --- a/ui-v2/tests/unit/utils/confirm-test.js +++ /dev/null @@ -1,17 +0,0 @@ -import { module } from 'qunit'; -import test from 'ember-sinon-qunit/test-support/test'; -import confirm from 'consul-ui/utils/confirm'; - -module('Unit | Utils | confirm', function() { - test('it resolves the result of the confirmation', function(assert) { - const expected = 'message'; - // split this off into separate testing - const confirmation = function(actual) { - assert.equal(actual, expected); - return true; - }; - return confirm(expected, confirmation).then(function(res) { - assert.ok(res); - }); - }); -}); diff --git a/ui-v2/tests/unit/utils/makeAttrable-test.js b/ui-v2/tests/unit/utils/makeAttrable-test.js deleted file mode 100644 index 2bd426fcd9..0000000000 --- a/ui-v2/tests/unit/utils/makeAttrable-test.js +++ /dev/null @@ -1,14 +0,0 @@ -import { module } from 'qunit'; -import test from 'ember-sinon-qunit/test-support/test'; -import makeAttrable from 'consul-ui/utils/makeAttrable'; - -module('Unit | Utils | makeAttrable', function() { - test('it adds a `attr` method, which returns the value of the property', function(assert) { - const obj = { - prop: true, - }; - const actual = makeAttrable(obj); - assert.equal(typeof actual.attr, 'function'); - assert.ok(actual.attr('prop')); - }); -});