mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 01:42:29 +03:00
e9486a8e87
no refs The `getAvailablePrices` method was removed from portal links as we no longer loop over prices for links but use monthly/yearly directly instead.
57 lines
1.6 KiB
JavaScript
57 lines
1.6 KiB
JavaScript
import Component from '@ember/component';
|
|
import copyTextToClipboard from 'ghost-admin/utils/copy-text-to-clipboard';
|
|
import {computed} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
import {task, timeout} from 'ember-concurrency';
|
|
|
|
export default Component.extend({
|
|
config: service(),
|
|
store: service(),
|
|
settings: service(),
|
|
tagName: '',
|
|
isLink: true,
|
|
prices: null,
|
|
copiedPrice: null,
|
|
|
|
toggleValue: computed('isLink', function () {
|
|
return this.isLink ? 'Data attributes' : 'Links';
|
|
}),
|
|
|
|
sectionHeaderLabel: computed('isLink', function () {
|
|
return this.isLink ? 'Link' : 'Data attribute';
|
|
}),
|
|
|
|
init() {
|
|
this._super(...arguments);
|
|
this.siteUrl = this.config.get('blogUrl');
|
|
},
|
|
|
|
actions: {
|
|
toggleShowLinks() {
|
|
this.toggleProperty('isLink');
|
|
}
|
|
},
|
|
copyStaticLink: task(function* (id) {
|
|
this.set('copiedPrice', id);
|
|
let data = '';
|
|
if (this.isLink) {
|
|
data = id ? `#/portal/${id}` : `#/portal/`;
|
|
} else {
|
|
data = id ? `data-portal="${id}"` : `data-portal`;
|
|
}
|
|
copyTextToClipboard(data);
|
|
yield timeout(this.isTesting ? 50 : 3000);
|
|
}),
|
|
copySignupLink: task(function* (price) {
|
|
this.set('copiedPrice', price.id);
|
|
let data = '';
|
|
if (this.isLink) {
|
|
data = `#/portal/signup/${price.id}`;
|
|
} else {
|
|
data = `data-portal="signup/${price.id}"`;
|
|
}
|
|
copyTextToClipboard(data);
|
|
yield timeout(this.isTesting ? 50 : 3000);
|
|
})
|
|
});
|