Ghost/ghost/admin/app/components/gh-portal-links.js
Rishabh e9486a8e87 Removed unused prices method in portal links
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.
2021-06-04 17:43:46 +05:30

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);
})
});