github.com/hernad/nomad@v1.6.112/ui/app/components/copy-button.js (about) 1 /** 2 * Copyright (c) HashiCorp, Inc. 3 * SPDX-License-Identifier: MPL-2.0 4 */ 5 6 import Component from '@glimmer/component'; 7 import { tracked } from '@glimmer/tracking'; 8 import { task, timeout } from 'ember-concurrency'; 9 10 export default class CopyButton extends Component { 11 @tracked state = null; 12 13 get text() { 14 if (typeof this.args.clipboardText === 'function') 15 return this.args.clipboardText; 16 if (typeof this.args.clipboardText === 'string') 17 return this.args.clipboardText; 18 19 return String(this.args.clipboardText); 20 } 21 22 @(task(function* () { 23 this.state = 'success'; 24 25 yield timeout(2000); 26 this.state = null; 27 }).restartable()) 28 indicateSuccess; 29 }