2020-06-19 19:06:49 +03:00
|
|
|
import ModalComponent from 'ghost-admin/components/modal-base';
|
2020-07-07 07:22:42 +03:00
|
|
|
import copyTextToClipboard from 'ghost-admin/utils/copy-text-to-clipboard';
|
2021-05-19 17:36:46 +03:00
|
|
|
import {action, computed} from '@ember/object';
|
2021-05-12 14:33:36 +03:00
|
|
|
import {htmlSafe} from '@ember/template';
|
2020-06-19 19:06:49 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
2020-07-07 07:22:42 +03:00
|
|
|
import {task, timeout} from 'ember-concurrency';
|
2020-07-21 20:12:55 +03:00
|
|
|
const ICON_EXTENSIONS = ['gif', 'jpg', 'jpeg', 'png', 'svg'];
|
|
|
|
|
2020-06-19 19:06:49 +03:00
|
|
|
export default ModalComponent.extend({
|
2020-06-25 23:45:47 +03:00
|
|
|
config: service(),
|
2021-01-28 20:28:19 +03:00
|
|
|
membersUtils: service(),
|
|
|
|
settings: service(),
|
2021-05-04 18:43:31 +03:00
|
|
|
store: service(),
|
2021-08-17 13:03:29 +03:00
|
|
|
session: service(),
|
2021-08-23 13:54:33 +03:00
|
|
|
feature: service(),
|
2022-01-27 14:40:11 +03:00
|
|
|
ghostPaths: service(),
|
|
|
|
ajax: service(),
|
2021-01-28 20:28:19 +03:00
|
|
|
|
2020-06-25 23:45:47 +03:00
|
|
|
page: 'signup',
|
2020-07-07 07:22:42 +03:00
|
|
|
iconExtensions: null,
|
|
|
|
isShowModalLink: true,
|
|
|
|
customIcon: null,
|
2020-07-30 16:12:44 +03:00
|
|
|
showLinksPage: false,
|
2020-07-30 13:56:07 +03:00
|
|
|
showLeaveSettingsModal: false,
|
2021-05-19 17:36:46 +03:00
|
|
|
isPreloading: true,
|
2022-05-11 20:11:54 +03:00
|
|
|
changedTiers: null,
|
2022-04-28 11:24:12 +03:00
|
|
|
openSection: null,
|
2021-05-19 22:24:13 +03:00
|
|
|
portalPreviewGuid: 'modal-portal-settings',
|
2021-01-28 20:28:19 +03:00
|
|
|
|
2020-06-25 23:45:47 +03:00
|
|
|
confirm() {},
|
2020-06-29 20:37:11 +03:00
|
|
|
|
2020-07-07 07:22:42 +03:00
|
|
|
backgroundStyle: computed('settings.accentColor', function () {
|
2021-05-18 15:59:47 +03:00
|
|
|
let color = this.settings.get('accentColor') || '#ffffff';
|
2020-07-07 07:22:42 +03:00
|
|
|
return htmlSafe(`background-color: ${color}`);
|
|
|
|
}),
|
|
|
|
|
2022-01-27 14:40:11 +03:00
|
|
|
disableUpdateSupportAddressButton: computed('supportAddress', function () {
|
|
|
|
const savedSupportAddress = this.get('settings.membersSupportAddress') || '';
|
|
|
|
if (!savedSupportAddress.includes('@') && this.config.emailDomain) {
|
|
|
|
return !this.supportAddress || (this.supportAddress === `${savedSupportAddress}@${this.config.emailDomain}`);
|
|
|
|
}
|
|
|
|
return !this.supportAddress || (this.supportAddress === savedSupportAddress);
|
|
|
|
}),
|
|
|
|
|
2020-07-07 07:22:42 +03:00
|
|
|
showModalLinkOrAttribute: computed('isShowModalLink', function () {
|
|
|
|
if (this.isShowModalLink) {
|
2020-10-12 14:56:37 +03:00
|
|
|
return `#/portal`;
|
2020-07-07 07:22:42 +03:00
|
|
|
}
|
|
|
|
return `data-portal`;
|
|
|
|
}),
|
|
|
|
|
2022-05-11 20:11:54 +03:00
|
|
|
portalPreviewUrl: computed('page', 'model.tiers.[]', 'changedTiers.[]', 'membersUtils.{isFreeChecked,isMonthlyChecked,isYearlyChecked}', 'settings.{portalName,portalButton,portalButtonIcon,portalButtonSignupText,portalButtonStyle,accentColor,portalPlans.[]}', function () {
|
2021-05-18 15:59:47 +03:00
|
|
|
const options = this.getProperties(['page']);
|
2022-05-11 20:11:54 +03:00
|
|
|
options.portalTiers = this.model.tiers?.filter((tier) => {
|
|
|
|
return tier.get('visibility') === 'public'
|
|
|
|
&& tier.get('active') === true
|
|
|
|
&& tier.get('type') === 'paid';
|
|
|
|
}).map((tier) => {
|
|
|
|
return tier.id;
|
2022-03-08 10:30:31 +03:00
|
|
|
});
|
2022-05-11 20:11:54 +03:00
|
|
|
const freeTier = this.model.tiers?.find((tier) => {
|
|
|
|
return tier.type === 'free';
|
2022-03-08 10:30:31 +03:00
|
|
|
});
|
2022-05-11 20:11:54 +03:00
|
|
|
options.isFreeChecked = freeTier?.visibility === 'public';
|
2021-01-28 21:41:03 +03:00
|
|
|
return this.membersUtils.getPortalPreviewUrl(options);
|
2020-06-25 23:45:47 +03:00
|
|
|
}),
|
|
|
|
|
2020-07-07 07:22:42 +03:00
|
|
|
showIconSetting: computed('selectedButtonStyle', function () {
|
|
|
|
const selectedButtonStyle = this.get('selectedButtonStyle.name') || '';
|
|
|
|
return selectedButtonStyle.includes('icon');
|
|
|
|
}),
|
|
|
|
|
2020-07-16 16:21:14 +03:00
|
|
|
showButtonTextSetting: computed('selectedButtonStyle', function () {
|
|
|
|
const selectedButtonStyle = this.get('selectedButtonStyle.name') || '';
|
|
|
|
return selectedButtonStyle.includes('text');
|
|
|
|
}),
|
|
|
|
|
2020-07-07 07:22:42 +03:00
|
|
|
selectedButtonStyle: computed('settings.portalButtonStyle', function () {
|
|
|
|
return this.buttonStyleOptions.find((buttonStyle) => {
|
|
|
|
return (buttonStyle.name === this.settings.get('portalButtonStyle'));
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
|
2021-06-04 10:45:49 +03:00
|
|
|
isFreeChecked: computed('settings.{portalPlans.[],membersSignupAccess}', function () {
|
|
|
|
const allowedPlans = this.settings.get('portalPlans') || [];
|
|
|
|
return (this.settings.get('membersSignupAccess') === 'all' && allowedPlans.includes('free'));
|
|
|
|
}),
|
2022-05-24 17:53:03 +03:00
|
|
|
isMonthlyChecked: computed('settings.portalPlans.[]', 'membersUtils.paidMembersEnabled', function () {
|
2021-06-04 10:45:49 +03:00
|
|
|
const allowedPlans = this.settings.get('portalPlans') || [];
|
2022-05-24 17:53:03 +03:00
|
|
|
return (this.membersUtils.paidMembersEnabled && allowedPlans.includes('monthly'));
|
2021-06-04 10:45:49 +03:00
|
|
|
}),
|
2022-05-24 17:53:03 +03:00
|
|
|
isYearlyChecked: computed('settings.portalPlans.[]', 'membersUtils.paidMembersEnabled', function () {
|
2021-06-04 10:45:49 +03:00
|
|
|
const allowedPlans = this.settings.get('portalPlans') || [];
|
2022-05-24 17:53:03 +03:00
|
|
|
return (this.membersUtils.paidMembersEnabled && allowedPlans.includes('yearly'));
|
2021-06-04 10:45:49 +03:00
|
|
|
}),
|
2022-05-11 20:11:54 +03:00
|
|
|
tiers: computed('model.tiers.[]', 'changedTiers.[]', 'isPreloading', function () {
|
|
|
|
const paidTiers = this.model.tiers?.filter(tier => tier.type === 'paid' && tier.active === true);
|
|
|
|
if (this.isPreloading || !paidTiers?.length) {
|
2021-06-21 11:51:48 +03:00
|
|
|
return [];
|
|
|
|
}
|
2022-03-08 10:30:31 +03:00
|
|
|
|
2022-05-11 20:11:54 +03:00
|
|
|
const tiers = paidTiers.map((tier) => {
|
2021-06-21 11:51:48 +03:00
|
|
|
return {
|
2022-05-11 20:11:54 +03:00
|
|
|
id: tier.id,
|
|
|
|
name: tier.name,
|
|
|
|
checked: tier.visibility === 'public'
|
2021-06-21 11:51:48 +03:00
|
|
|
};
|
|
|
|
});
|
2022-05-11 20:11:54 +03:00
|
|
|
return tiers;
|
2021-06-21 11:51:48 +03:00
|
|
|
}),
|
2021-06-04 10:45:49 +03:00
|
|
|
|
2022-05-16 18:25:03 +03:00
|
|
|
showPortalPrices: computed('tiers', function () {
|
2022-05-11 20:11:54 +03:00
|
|
|
const visibleTiers = this.model.tiers?.filter((tier) => {
|
|
|
|
return tier.visibility === 'public' && tier.type === 'paid';
|
2022-03-08 10:30:31 +03:00
|
|
|
});
|
|
|
|
|
2022-05-11 20:11:54 +03:00
|
|
|
return !!visibleTiers?.length;
|
2021-08-23 09:56:12 +03:00
|
|
|
}),
|
|
|
|
|
2020-06-19 19:06:49 +03:00
|
|
|
init() {
|
|
|
|
this._super(...arguments);
|
2020-07-07 07:22:42 +03:00
|
|
|
this.buttonStyleOptions = [
|
|
|
|
{name: 'icon-and-text', label: 'Icon and text'},
|
|
|
|
{name: 'icon-only', label: 'Icon only'},
|
|
|
|
{name: 'text-only', label: 'Text only'}
|
|
|
|
];
|
2022-04-28 11:24:12 +03:00
|
|
|
this.availablePages = [{
|
|
|
|
name: 'signup',
|
|
|
|
label: 'Signup'
|
|
|
|
}, {
|
|
|
|
name: 'accountHome',
|
|
|
|
label: 'Account'
|
|
|
|
}, {
|
|
|
|
name: 'links',
|
|
|
|
label: 'Links'
|
|
|
|
}];
|
2020-07-07 07:22:42 +03:00
|
|
|
this.iconExtensions = ICON_EXTENSIONS;
|
2022-05-11 20:11:54 +03:00
|
|
|
this.changedTiers = [];
|
2022-01-27 14:40:11 +03:00
|
|
|
this.set('supportAddress', this.parseEmailAddress(this.settings.get('membersSupportAddress')));
|
2020-06-19 19:06:49 +03:00
|
|
|
},
|
|
|
|
|
2020-08-11 09:34:42 +03:00
|
|
|
didInsertElement() {
|
|
|
|
this._super(...arguments);
|
2021-05-18 15:59:47 +03:00
|
|
|
this.settings.get('errors').clear();
|
2020-08-11 09:34:42 +03:00
|
|
|
},
|
|
|
|
|
2020-06-19 19:06:49 +03:00
|
|
|
actions: {
|
|
|
|
toggleFreePlan(isChecked) {
|
|
|
|
this.updateAllowedPlan('free', isChecked);
|
|
|
|
},
|
2021-06-04 10:45:49 +03:00
|
|
|
togglePlan(plan, event) {
|
|
|
|
this.updateAllowedPlan(plan, event.target.checked);
|
2021-05-04 18:43:31 +03:00
|
|
|
},
|
2022-05-11 20:11:54 +03:00
|
|
|
toggleTier(tierId, event) {
|
|
|
|
this.updateAllowedTier(tierId, event.target.checked);
|
2021-06-21 11:51:48 +03:00
|
|
|
},
|
2020-07-07 07:22:42 +03:00
|
|
|
togglePortalButton(showButton) {
|
|
|
|
this.settings.set('portalButton', showButton);
|
2020-06-19 19:06:49 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
togglePortalName(showSignupName) {
|
|
|
|
this.settings.set('portalName', showSignupName);
|
|
|
|
},
|
2022-04-28 11:24:12 +03:00
|
|
|
toggleSection(section) {
|
|
|
|
if (this.get('openSection') === section) {
|
|
|
|
this.set('openSection', null);
|
|
|
|
} else {
|
|
|
|
this.set('openSection', section);
|
|
|
|
}
|
|
|
|
},
|
2020-06-19 19:06:49 +03:00
|
|
|
|
|
|
|
confirm() {
|
|
|
|
return this.saveTask.perform();
|
|
|
|
},
|
|
|
|
|
|
|
|
isPlanSelected(plan) {
|
|
|
|
const allowedPlans = this.settings.get('portalPlans');
|
|
|
|
return allowedPlans.includes(plan);
|
2020-06-25 23:45:47 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
switchPreviewPage(page) {
|
2022-04-28 11:24:12 +03:00
|
|
|
if (page.name === 'links') {
|
2020-07-30 16:12:44 +03:00
|
|
|
this.set('showLinksPage', true);
|
|
|
|
this.set('page', '');
|
|
|
|
} else {
|
|
|
|
this.set('showLinksPage', false);
|
2022-04-28 11:24:12 +03:00
|
|
|
this.set('page', page.name);
|
2020-07-30 16:12:44 +03:00
|
|
|
}
|
2020-07-07 07:22:42 +03:00
|
|
|
},
|
|
|
|
|
2020-10-16 16:34:22 +03:00
|
|
|
switchToSignupPage() {
|
|
|
|
if (this.showLinksPage) {
|
|
|
|
this.set('showLinksPage', false);
|
|
|
|
this.set('page', 'signup');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-07-07 07:22:42 +03:00
|
|
|
setButtonStyle(buttonStyle) {
|
2020-07-30 13:56:07 +03:00
|
|
|
this.settings.set('portalButtonStyle', buttonStyle.name);
|
2020-07-07 07:22:42 +03:00
|
|
|
},
|
2022-01-27 14:40:11 +03:00
|
|
|
|
2020-07-07 07:22:42 +03:00
|
|
|
setSignupButtonText(event) {
|
2020-07-30 13:56:07 +03:00
|
|
|
this.settings.set('portalButtonSignupText', event.target.value);
|
2020-07-07 07:22:42 +03:00
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Fired after an image upload completes
|
|
|
|
* @param {string} property - Property name to be set on `this.settings`
|
|
|
|
* @param {UploadResult[]} results - Array of UploadResult objects
|
|
|
|
* @return {string} The URL that was set on `this.settings.property`
|
|
|
|
*/
|
|
|
|
imageUploaded(property, results) {
|
|
|
|
if (results[0]) {
|
|
|
|
this.set('customIcon', results[0].url);
|
2020-07-30 13:56:07 +03:00
|
|
|
this.settings.set('portalButtonIcon', results[0].url);
|
2020-07-07 07:22:42 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Opens a file selection dialog - Triggered by "Upload Image" buttons,
|
|
|
|
* searches for the hidden file input within the .gh-setting element
|
|
|
|
* containing the clicked button then simulates a click
|
|
|
|
* @param {MouseEvent} event - MouseEvent fired by the button click
|
|
|
|
*/
|
|
|
|
triggerFileDialog(event) {
|
2022-05-29 13:18:49 +03:00
|
|
|
event?.target.closest('.gh-setting-action')?.querySelector('input[type="file"]')?.click();
|
2020-07-07 07:22:42 +03:00
|
|
|
},
|
|
|
|
|
2020-08-19 18:00:06 +03:00
|
|
|
deleteCustomIcon() {
|
|
|
|
this.set('customIcon', null);
|
2021-05-18 15:59:47 +03:00
|
|
|
this.settings.set('portalButtonIcon', this.membersUtils.defaultIconKeys[0]);
|
2020-08-19 18:00:06 +03:00
|
|
|
},
|
|
|
|
|
2020-07-07 07:22:42 +03:00
|
|
|
selectDefaultIcon(icon) {
|
2020-07-30 13:56:07 +03:00
|
|
|
this.settings.set('portalButtonIcon', icon);
|
|
|
|
},
|
|
|
|
|
|
|
|
closeLeaveSettingsModal() {
|
|
|
|
this.set('showLeaveSettingsModal', false);
|
|
|
|
},
|
|
|
|
|
2022-05-24 17:53:03 +03:00
|
|
|
openStripeConnect() {
|
2021-05-19 22:24:13 +03:00
|
|
|
this.isWaitingForStripeConnection = true;
|
2022-05-24 17:53:03 +03:00
|
|
|
this.model.openStripeConnect();
|
2020-10-22 13:39:00 +03:00
|
|
|
},
|
|
|
|
|
2020-07-30 13:56:07 +03:00
|
|
|
leaveSettings() {
|
|
|
|
this.closeModal();
|
2020-11-23 12:38:29 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
validateFreeSignupRedirect() {
|
2022-01-21 22:25:47 +03:00
|
|
|
return this._validateSignupRedirect(this.freeSignupRedirect, 'membersFreeSignupRedirect');
|
2020-11-23 12:38:29 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
validatePaidSignupRedirect() {
|
2022-01-21 22:25:47 +03:00
|
|
|
return this._validateSignupRedirect(this.paidSignupRedirect, 'membersPaidSignupRedirect');
|
2022-01-27 14:40:11 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
setSupportAddress(supportAddress) {
|
|
|
|
this.set('supportAddress', supportAddress);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
parseEmailAddress(address) {
|
|
|
|
const emailAddress = address || 'noreply';
|
|
|
|
// Adds default domain as site domain
|
|
|
|
if (emailAddress.indexOf('@') < 0 && this.config.emailDomain) {
|
|
|
|
return `${emailAddress}@${this.config.emailDomain}`;
|
2020-06-19 19:06:49 +03:00
|
|
|
}
|
2022-01-27 14:40:11 +03:00
|
|
|
return emailAddress;
|
2020-06-19 19:06:49 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
updateAllowedPlan(plan, isChecked) {
|
2021-04-27 20:03:13 +03:00
|
|
|
const portalPlans = this.settings.get('portalPlans') || [];
|
|
|
|
const allowedPlans = [...portalPlans];
|
2022-05-11 20:11:54 +03:00
|
|
|
const freeTier = this.model.tiers.find(p => p.type === 'free');
|
2020-06-19 19:06:49 +03:00
|
|
|
|
|
|
|
if (!isChecked) {
|
|
|
|
this.settings.set('portalPlans', allowedPlans.filter(p => p !== plan));
|
2022-03-08 10:30:31 +03:00
|
|
|
if (plan === 'free') {
|
2022-05-11 20:11:54 +03:00
|
|
|
freeTier.set('visibility', 'none');
|
2022-03-08 10:30:31 +03:00
|
|
|
}
|
2020-06-19 19:06:49 +03:00
|
|
|
} else {
|
|
|
|
allowedPlans.push(plan);
|
2021-04-27 20:03:13 +03:00
|
|
|
this.settings.set('portalPlans', allowedPlans);
|
2022-03-08 10:30:31 +03:00
|
|
|
if (plan === 'free') {
|
2022-05-11 20:11:54 +03:00
|
|
|
freeTier.set('visibility', 'public');
|
2022-03-08 10:30:31 +03:00
|
|
|
}
|
2020-06-19 19:06:49 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2022-05-11 20:11:54 +03:00
|
|
|
updateAllowedTier(tierId, isChecked) {
|
|
|
|
const tier = this.model.tiers.find(p => p.id === tierId);
|
2021-06-21 11:51:48 +03:00
|
|
|
if (!isChecked) {
|
2022-05-11 20:11:54 +03:00
|
|
|
tier.set('visibility', 'none');
|
2021-06-21 11:51:48 +03:00
|
|
|
} else {
|
2022-05-11 20:11:54 +03:00
|
|
|
tier.set('visibility', 'public');
|
2021-06-21 11:51:48 +03:00
|
|
|
}
|
2022-05-11 20:11:54 +03:00
|
|
|
let portalTiers = this.model.tiers.filter((p) => {
|
2022-03-08 10:30:31 +03:00
|
|
|
return p.visibility === 'public';
|
|
|
|
}).map(p => p.id);
|
2022-05-11 20:11:54 +03:00
|
|
|
this.set('changedTiers', portalTiers);
|
2021-06-21 11:51:48 +03:00
|
|
|
},
|
|
|
|
|
2020-11-20 12:53:08 +03:00
|
|
|
_validateSignupRedirect(url, type) {
|
2020-11-23 12:38:29 +03:00
|
|
|
let errMessage = `Please enter a valid URL`;
|
2021-05-18 15:59:47 +03:00
|
|
|
this.settings.get('errors').remove(type);
|
|
|
|
this.settings.get('hasValidated').removeObject(type);
|
2020-11-20 12:53:08 +03:00
|
|
|
|
2020-11-23 12:38:29 +03:00
|
|
|
if (url === null) {
|
2021-05-18 15:59:47 +03:00
|
|
|
this.settings.get('errors').add(type, errMessage);
|
|
|
|
this.settings.get('hasValidated').pushObject(type);
|
2020-11-23 12:38:29 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (url === undefined) {
|
|
|
|
// Not initialised
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-20 12:53:08 +03:00
|
|
|
if (url.href.startsWith(this.siteUrl)) {
|
|
|
|
const path = url.href.replace(this.siteUrl, '');
|
|
|
|
this.settings.set(type, path);
|
2020-11-23 12:38:29 +03:00
|
|
|
} else {
|
|
|
|
this.settings.set(type, url.href);
|
2020-11-20 12:53:08 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-05-19 17:36:46 +03:00
|
|
|
finishPreloading: action(async function () {
|
|
|
|
if (this.model.preloadTask?.isRunning) {
|
|
|
|
await this.model.preloadTask;
|
|
|
|
}
|
|
|
|
|
|
|
|
const portalButtonIcon = this.settings.get('portalButtonIcon') || '';
|
|
|
|
if (portalButtonIcon && !this.membersUtils.defaultIconKeys.includes(portalButtonIcon)) {
|
|
|
|
this.set('customIcon', this.settings.get('portalButtonIcon'));
|
|
|
|
}
|
|
|
|
|
|
|
|
this.siteUrl = this.config.get('blogUrl');
|
|
|
|
this.set('isPreloading', false);
|
|
|
|
}),
|
|
|
|
|
2021-05-19 22:24:13 +03:00
|
|
|
refreshAfterStripeConnected: action(async function () {
|
|
|
|
if (this.isWaitingForStripeConnection) {
|
|
|
|
await this.finishPreloading();
|
|
|
|
this.notifyPropertyChange('page'); // force preview url to recompute
|
|
|
|
this.set('portalPreviewGuid', Date.now().valueOf()); // force preview re-render
|
|
|
|
this.isWaitingForStripeConnection = false;
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
2020-07-07 07:22:42 +03:00
|
|
|
copyLinkOrAttribute: task(function* () {
|
|
|
|
copyTextToClipboard(this.showModalLinkOrAttribute);
|
|
|
|
yield timeout(this.isTesting ? 50 : 3000);
|
|
|
|
}),
|
|
|
|
|
2020-06-19 19:06:49 +03:00
|
|
|
saveTask: task(function* () {
|
2020-11-23 12:38:29 +03:00
|
|
|
this.send('validateFreeSignupRedirect');
|
|
|
|
this.send('validatePaidSignupRedirect');
|
2021-05-18 15:59:47 +03:00
|
|
|
if (this.settings.get('errors').length !== 0) {
|
2020-11-23 12:38:29 +03:00
|
|
|
return;
|
|
|
|
}
|
2022-03-08 10:30:31 +03:00
|
|
|
|
|
|
|
// Save tier visibility if changed
|
|
|
|
yield Promise.all(
|
2022-05-11 20:11:54 +03:00
|
|
|
this.model.tiers.filter((tier) => {
|
|
|
|
const changedAttrs = tier.changedAttributes();
|
2022-03-08 10:30:31 +03:00
|
|
|
return !!changedAttrs.visibility;
|
2022-05-11 20:11:54 +03:00
|
|
|
}).map((tier) => {
|
|
|
|
return tier.save();
|
2022-03-08 10:30:31 +03:00
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2020-06-19 19:06:49 +03:00
|
|
|
yield this.settings.save();
|
2022-03-08 10:30:31 +03:00
|
|
|
|
2020-06-19 19:06:49 +03:00
|
|
|
this.closeModal();
|
2022-01-27 14:40:11 +03:00
|
|
|
}).drop(),
|
|
|
|
|
|
|
|
updateSupportAddress: task(function* () {
|
|
|
|
let url = this.get('ghostPaths.url').api('/settings/members/email');
|
|
|
|
try {
|
2022-05-24 19:56:12 +03:00
|
|
|
yield this.ajax.post(url, {
|
2022-01-27 14:40:11 +03:00
|
|
|
data: {
|
|
|
|
email: this.supportAddress,
|
|
|
|
type: 'supportAddressUpdate'
|
|
|
|
}
|
|
|
|
});
|
2022-05-24 19:56:12 +03:00
|
|
|
|
2022-05-24 19:52:25 +03:00
|
|
|
return true;
|
2022-01-27 14:40:11 +03:00
|
|
|
} catch (e) {
|
|
|
|
// Failed to send email, retry
|
|
|
|
return false;
|
|
|
|
}
|
2020-06-19 19:06:49 +03:00
|
|
|
}).drop()
|
|
|
|
});
|