mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-20 17:32:15 +03:00
8cc4c6c4a1
no issue - since `ember-concurrency@2.0` it's possible to use the standard imports as decorators removing the need for the extra `ember-concurrency-decorators` dependency and imports
33 lines
930 B
JavaScript
33 lines
930 B
JavaScript
import Component from '@glimmer/component';
|
|
import config from 'ghost-admin/config/environment';
|
|
import copyTextToClipboard from 'ghost-admin/utils/copy-text-to-clipboard';
|
|
import {inject as service} from '@ember/service';
|
|
import {task, timeout} from 'ember-concurrency';
|
|
|
|
export default class ModalsOffersLinkComponent extends Component {
|
|
@service config;
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
if (this.isTesting === undefined) {
|
|
this.isTesting = config.environment === 'test';
|
|
}
|
|
}
|
|
|
|
get offerUrl() {
|
|
const code = this.args.data.offer?.code || '';
|
|
if (code) {
|
|
const siteUrl = this.config.get('blogUrl');
|
|
return `${siteUrl}/${code}`;
|
|
}
|
|
return '';
|
|
}
|
|
|
|
@task({drop: true})
|
|
*copyOfferUrl() {
|
|
copyTextToClipboard(this.offerUrl);
|
|
yield timeout(this.isTesting ? 50 : 500);
|
|
return true;
|
|
}
|
|
}
|