mirror of https://github.com/status-im/consul.git
ui: remove some components/javascript we are no longer using (#7941)
This commit is contained in:
parent
91b22f21ba
commit
7e1e6e44c3
|
@ -1,14 +0,0 @@
|
|||
{{! action groups are block only components, you MUST specify a list of actions in the component body }}
|
||||
{{! therefore if you call this component as an inline component, nothing is produced }}
|
||||
{{#if hasBlock }}
|
||||
<input type="radio" name="actions" id="actions_{{index}}" checked={{if (eq checked 'checked') 'checked'}} onchange={{action onchange}} value={{index}} />
|
||||
<label for="actions_{{index}}">
|
||||
<span>Open</span>
|
||||
</label>
|
||||
<label for="actions_close">
|
||||
<span>Close</span>
|
||||
</label>
|
||||
<div>
|
||||
{{yield}}
|
||||
</div>
|
||||
{{/if}}
|
|
@ -1,6 +0,0 @@
|
|||
import Component from '@ember/component';
|
||||
|
||||
export default Component.extend({
|
||||
classNames: ['action-group'],
|
||||
onchange: function() {},
|
||||
});
|
|
@ -1,11 +0,0 @@
|
|||
<ul>
|
||||
{{#each value as |item index|}}
|
||||
<li>
|
||||
<button type="button" {{action 'remove' index}}>Remove</button>{{item}}
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
<label class="type-search">
|
||||
<span>Search</span>
|
||||
<input {{ref this "input"}} onchange={{action 'add'}} onsearch={{action 'add'}} oninput={{action 'input'}} onkeydown={{action 'keydown'}} placeholder={{if (eq value.length 0) placeholder}} value={{item}} type="search" name="s" autofocus="autofocus" />
|
||||
</label>
|
|
@ -1,62 +0,0 @@
|
|||
import Component from '@ember/component';
|
||||
import { set } from '@ember/object';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default Component.extend({
|
||||
dom: service('dom'),
|
||||
classNames: ['phrase-editor'],
|
||||
item: '',
|
||||
onchange: function(e) {},
|
||||
search: function(e) {
|
||||
// TODO: Temporarily continue supporting `searchable`
|
||||
let searchable = this.searchable;
|
||||
if (searchable) {
|
||||
if (!Array.isArray(searchable)) {
|
||||
searchable = [searchable];
|
||||
}
|
||||
searchable.forEach(item => {
|
||||
item.search(this.value);
|
||||
});
|
||||
}
|
||||
this.onchange(e);
|
||||
},
|
||||
oninput: function(e) {},
|
||||
onkeydown: function(e) {},
|
||||
actions: {
|
||||
keydown: function(e) {
|
||||
switch (e.keyCode) {
|
||||
case 8: // backspace
|
||||
if (e.target.value == '' && this.value.length > 0) {
|
||||
this.actions.remove.bind(this)(this.value.length - 1);
|
||||
}
|
||||
break;
|
||||
case 27: // escape
|
||||
set(this, 'value', []);
|
||||
this.search({ target: this });
|
||||
break;
|
||||
}
|
||||
this.onkeydown({ target: this });
|
||||
},
|
||||
input: function(e) {
|
||||
set(this, 'item', e.target.value);
|
||||
this.oninput({ target: this });
|
||||
},
|
||||
remove: function(index, e) {
|
||||
this.value.removeAt(index, 1);
|
||||
this.search({ target: this });
|
||||
this.input.focus();
|
||||
},
|
||||
add: function(e) {
|
||||
const item = this.item.trim();
|
||||
if (item !== '') {
|
||||
set(this, 'item', '');
|
||||
const currentItems = this.value || [];
|
||||
const items = new Set(currentItems).add(item);
|
||||
if (items.size > currentItems.length) {
|
||||
set(this, 'value', [...items]);
|
||||
this.search({ target: this });
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
|
@ -1,38 +1,3 @@
|
|||
import Route from '@ember/routing/route';
|
||||
import { get } from '@ember/object';
|
||||
import { inject as service } from '@ember/service';
|
||||
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions';
|
||||
export default Route.extend(WithBlockingActions, {
|
||||
router: service('router'),
|
||||
settings: service('settings'),
|
||||
feedback: service('feedback'),
|
||||
repo: service('repository/token'),
|
||||
actions: {
|
||||
authorize: function(secret, nspace) {
|
||||
const dc = this.modelFor('dc').dc.Name;
|
||||
return this.repo
|
||||
.self(secret, dc)
|
||||
.then(item => {
|
||||
return this.settings.persist({
|
||||
token: {
|
||||
Namespace: get(item, 'Namespace'),
|
||||
AccessorID: get(item, 'AccessorID'),
|
||||
SecretID: secret,
|
||||
},
|
||||
});
|
||||
})
|
||||
.catch(e => {
|
||||
this.feedback.execute(
|
||||
() => {
|
||||
return Promise.resolve();
|
||||
},
|
||||
'authorize',
|
||||
function(type, e) {
|
||||
return 'error';
|
||||
},
|
||||
{}
|
||||
);
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
export default Route.extend(WithBlockingActions, {});
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
export default function(model, props, attr = {}) {
|
||||
model.eachAttribute(function(item) {
|
||||
attr[item] = {
|
||||
...attr[item],
|
||||
...{
|
||||
serialize: props.indexOf(item) !== -1,
|
||||
},
|
||||
};
|
||||
});
|
||||
return attr;
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
import { render, find } from '@ember/test-helpers';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
|
||||
module('Integration | Component | action group', function(hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test("it doesn't render anything when used inline", async function(assert) {
|
||||
await render(hbs`{{action-group}}`);
|
||||
|
||||
assert.dom('*').hasText('');
|
||||
});
|
||||
test('it renders', async function(assert) {
|
||||
// Set any properties with this.set('myProperty', 'value');
|
||||
// Handle any actions with this.on('myAction', function(val) { ... });
|
||||
|
||||
// this.render(hbs`{{action-group}}`);
|
||||
|
||||
// assert.equal(
|
||||
// this.$()
|
||||
// .text()
|
||||
// .trim(),
|
||||
// ''
|
||||
// );
|
||||
|
||||
// Template block usage:
|
||||
await render(hbs`
|
||||
{{#action-group}}{{/action-group}}
|
||||
`);
|
||||
|
||||
assert.notEqual(
|
||||
find('*')
|
||||
.textContent.trim()
|
||||
.indexOf('Open'),
|
||||
-1
|
||||
);
|
||||
});
|
||||
});
|
|
@ -1,54 +0,0 @@
|
|||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
import { render, find } from '@ember/test-helpers';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
|
||||
module('Integration | Component | phrase editor', function(hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function() {
|
||||
this.actions = {};
|
||||
this.send = (actionName, ...args) => this.actions[actionName].apply(this, args);
|
||||
});
|
||||
|
||||
test('it renders a phrase', async function(assert) {
|
||||
this.set('value', ['phrase']);
|
||||
await render(hbs`{{phrase-editor value=value}}`);
|
||||
assert.notEqual(
|
||||
find('*')
|
||||
.textContent.trim()
|
||||
.indexOf('phrase'),
|
||||
-1
|
||||
);
|
||||
});
|
||||
test('it calls onchange when a phrase is removed by clicking the phrase remove button and refocuses', async function(assert) {
|
||||
assert.expect(3);
|
||||
this.set('value', ['phrase']);
|
||||
this.actions.change = function(e) {
|
||||
assert.equal(e.target.value.length, 0);
|
||||
};
|
||||
await render(hbs`{{phrase-editor value=value onchange=(action 'change')}}`);
|
||||
assert.notEqual(
|
||||
find('*')
|
||||
.textContent.trim()
|
||||
.indexOf('phrase'),
|
||||
-1
|
||||
);
|
||||
const $input = this.$('input');
|
||||
const $button = this.$('button');
|
||||
$button.trigger('click');
|
||||
assert.equal(document.activeElement, $input.get(0));
|
||||
});
|
||||
test('it calls onchange when a phrase is added', async function(assert) {
|
||||
assert.expect(1);
|
||||
this.actions.change = function(e) {
|
||||
assert.equal(e.target.value.length, 2);
|
||||
};
|
||||
this.set('value', ['phrase']);
|
||||
await render(hbs`{{phrase-editor value=value onchange=(action 'change')}}`);
|
||||
const $input = this.$('input');
|
||||
$input.get(0).value = 'phrase 2';
|
||||
$input.trigger('input');
|
||||
$input.trigger('search');
|
||||
});
|
||||
});
|
|
@ -1,43 +0,0 @@
|
|||
import writable from 'consul-ui/utils/model/writable';
|
||||
import { module, test } from 'qunit';
|
||||
|
||||
module('Unit | Utility | model/writable', function() {
|
||||
test('it correctly marks attrs as serialize:true|false', function(assert) {
|
||||
const yes = {
|
||||
Props: true,
|
||||
That: true,
|
||||
Should: true,
|
||||
Be: true,
|
||||
Writable: true,
|
||||
};
|
||||
const no = {
|
||||
Others: true,
|
||||
Read: true,
|
||||
Only: true,
|
||||
};
|
||||
const expectedYes = Object.keys(yes);
|
||||
const expectedNo = Object.keys(no);
|
||||
const model = {
|
||||
eachAttribute: function(cb) {
|
||||
expectedYes.concat(expectedNo).forEach(function(item) {
|
||||
cb(item, {}); // we aren't testing the meta here, just use the same api
|
||||
});
|
||||
},
|
||||
};
|
||||
let attrs = writable(model, Object.keys(yes));
|
||||
const actualYes = Object.keys(attrs).filter(item => attrs[item].serialize);
|
||||
const actualNo = Object.keys(attrs).filter(item => !attrs[item].serialize);
|
||||
assert.deepEqual(actualYes, expectedYes, 'writable props are marked as serializable');
|
||||
assert.deepEqual(actualNo, expectedNo, 'writable props are marked as not serializable');
|
||||
attrs = writable(model, Object.keys(yes), {
|
||||
Props: {
|
||||
another: 'property',
|
||||
},
|
||||
});
|
||||
assert.equal(
|
||||
attrs.Props.another,
|
||||
'property',
|
||||
'previous attrs objects can be passed without being overwritten'
|
||||
);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue