ui: Remove some javascript files we no longer use (#6853)

This commit is contained in:
John Cowen 2019-12-11 11:02:27 +00:00 committed by John Cowen
parent 421bbd9987
commit 572e3891fe
14 changed files with 4 additions and 139 deletions

View File

@ -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,

View File

@ -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',

View File

@ -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;

View File

@ -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',

View File

@ -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);
},
});

View File

@ -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);
},
});

View File

@ -1,4 +0,0 @@
import { Promise } from 'rsvp';
export default function(message, confirmation = confirm) {
return Promise.resolve(confirmation(message));
}

View File

@ -1,5 +0,0 @@
/* eslint no-console: "off" */
export default function(e) {
/* istanbul ignore next */
console.error(e);
}

View File

@ -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;
}

View File

@ -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];
},
};
}

View File

@ -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);
});
});

View File

@ -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);
});
});

View File

@ -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);
});
});
});

View File

@ -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'));
});
});