open-nomad/ui/app/components/copy-button.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
688 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { task, timeout } from 'ember-concurrency';
export default class CopyButton extends Component {
@tracked state = null;
get text() {
if (typeof this.args.clipboardText === 'function')
return this.args.clipboardText;
if (typeof this.args.clipboardText === 'string')
return this.args.clipboardText;
return String(this.args.clipboardText);
}
2021-12-28 14:45:20 +00:00
@(task(function* () {
this.state = 'success';
yield timeout(2000);
this.state = null;
}).restartable())
indicateSuccess;
}