mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-27 04:43:12 +03:00
267889993f
refs https://github.com/TryGhost/Team/issues/1084 - updates shareable offer link UI to to open directly instead of route - calculates offer url from code and updates in link modal - wires copy button on link modal - removes route based link code for modal
34 lines
975 B
JavaScript
34 lines
975 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} from 'ember-concurrency-decorators';
|
|
import {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;
|
|
}
|
|
}
|