open-nomad/ui/app/components/copy-button.js
Jai 27f0d104e5
16664/upgrade (#17158)
* chore:  upgrade

Upgrade @babel/helper-string-parserprop-types

* chore: add resolution

* chore: update component API for breaking changes

* chore: update arguments

* api: forgive user for pass wrong args

* chore:  update tests

* chore: update yarn lock

* chore: upgrade to Glimmer component

* styling: add properties to component invocation

* chore: add inset styles
2023-05-12 09:54:13 -04:00

30 lines
688 B
JavaScript

/**
* 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);
}
@(task(function* () {
this.state = 'success';
yield timeout(2000);
this.state = null;
}).restartable())
indicateSuccess;
}