2021-10-07 12:21:53 +03:00
|
|
|
import Component from '@glimmer/component';
|
2021-10-08 06:58:17 +03:00
|
|
|
import config from 'ghost-admin/config/environment';
|
|
|
|
import copyTextToClipboard from 'ghost-admin/utils/copy-text-to-clipboard';
|
|
|
|
import {inject as service} from '@ember/service';
|
2022-02-09 13:49:38 +03:00
|
|
|
import {task, timeout} from 'ember-concurrency';
|
2021-10-07 12:21:53 +03:00
|
|
|
|
2022-03-14 13:52:04 +03:00
|
|
|
export default class LinkOfferModal extends Component {
|
2021-10-08 06:58:17 +03:00
|
|
|
@service config;
|
|
|
|
|
2021-10-07 12:21:53 +03:00
|
|
|
constructor() {
|
|
|
|
super(...arguments);
|
2021-10-08 06:58:17 +03:00
|
|
|
if (this.isTesting === undefined) {
|
|
|
|
this.isTesting = config.environment === 'test';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
get offerUrl() {
|
|
|
|
const code = this.args.data.offer?.code || '';
|
|
|
|
if (code) {
|
2022-10-07 17:24:03 +03:00
|
|
|
const siteUrl = this.config.blogUrl;
|
2021-10-08 06:58:17 +03:00
|
|
|
return `${siteUrl}/${code}`;
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
@task({drop: true})
|
|
|
|
*copyOfferUrl() {
|
|
|
|
copyTextToClipboard(this.offerUrl);
|
|
|
|
yield timeout(this.isTesting ? 50 : 500);
|
|
|
|
return true;
|
2021-10-07 12:21:53 +03:00
|
|
|
}
|
2021-10-08 06:58:17 +03:00
|
|
|
}
|