mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 05:45:46 +00:00
a44541a91f
1. Remove ember-cli-clipboard dependency 2. Provide a new copy-button component implementing the same interface as ^ but make the clipboard functionality injectable 3. Provide 2 implementations of a Clipboard. One using clipboard.js (as previously) and an additional local storage 'clipboard'. 4. add a BDD step to assert whats in the clipboard (the fake one) Main reason here is that `document.exec` must be called by a user interaction
29 lines
733 B
JavaScript
29 lines
733 B
JavaScript
import Service from '@ember/service';
|
|
import { get } from '@ember/object';
|
|
|
|
import Clipboard from 'npm:clipboard';
|
|
|
|
class ClipboardCallback extends Clipboard {
|
|
constructor(trigger, cb) {
|
|
super(trigger);
|
|
this._cb = cb;
|
|
}
|
|
onClick(e) {
|
|
this._cb(this.text(e.delegateTarget || e.currentTarget));
|
|
// Clipboard uses/extends `tiny-emitter`
|
|
// TODO: We should probably fill this out to match the obj passed from
|
|
// os implementation
|
|
this.emit('success', {});
|
|
}
|
|
}
|
|
|
|
export default Service.extend({
|
|
storage: window.localStorage,
|
|
key: 'clipboard',
|
|
execute: function(trigger) {
|
|
return new ClipboardCallback(trigger, val => {
|
|
get(this, 'storage').setItem(get(this, 'key'), val);
|
|
});
|
|
},
|
|
});
|