Added site domain for default from address
refs https://github.com/TryGhost/Ghost/issues/11414 - Appends blog domain as default for from address members setting - Disabled update button when current from address is same as in field
This commit is contained in:
parent
9c9814d0f7
commit
c16381bb42
|
@ -232,14 +232,15 @@
|
|||
<GhFormGroup>
|
||||
<div class="flex items-center justify-center mt1">
|
||||
<GhTextInput
|
||||
@value={{readonly this.subscriptionSettings.fromAddress}}
|
||||
@input={{action "setSubscriptionSettings" "fromAddress"}}
|
||||
@value={{readonly this.fromAddress}}
|
||||
@input={{action "setFromAddress" value="target.value"}}
|
||||
@class="w20"
|
||||
/>
|
||||
<GhTaskButton
|
||||
@buttonText="Update from address"
|
||||
@runningText="Sending..."
|
||||
@successText="Confirmation Email Sent"
|
||||
@disabled={{this.disableUpdateFromAddressButton}}
|
||||
@task={{this.updateFromAddress}}
|
||||
@class="gh-btn gh-btn-icon gh-btn-textfield-group ml2"
|
||||
data-test-button="update-from-address"
|
||||
|
|
|
@ -48,8 +48,18 @@ export default Component.extend({
|
|||
return CURRENCIES.findBy('value', this.get('subscriptionSettings.stripeConfig.plans.monthly.currency'));
|
||||
}),
|
||||
|
||||
disableUpdateFromAddressButton: computed('subscriptionSettings.fromAddress', function () {
|
||||
return (this.originalFromAddress === this.get('subscriptionSettings.fromAddress'));
|
||||
disableUpdateFromAddressButton: computed('fromAddress', function () {
|
||||
const savedFromAddress = this.get('subscriptionSettings.fromAddress');
|
||||
if (savedFromAddress.indexOf('@') < 0 && this.blogDomain) {
|
||||
return (this.fromAddress === `${savedFromAddress}@${this.blogDomain}`);
|
||||
}
|
||||
return (this.fromAddress === savedFromAddress);
|
||||
}),
|
||||
|
||||
blogDomain: computed('config.blogDomain', function () {
|
||||
let blogDomain = this.config.blogDomain || '';
|
||||
const domainExp = blogDomain.replace('https://', '').replace('http://', '').match(new RegExp('^([^/:?#]+)(?:[/:?#]|$)', 'i'));
|
||||
return (domainExp && domainExp[1]) || '';
|
||||
}),
|
||||
|
||||
mailgunRegion: computed('settings.bulkEmailSettings.baseUrl', function () {
|
||||
|
@ -62,12 +72,6 @@ export default Component.extend({
|
|||
});
|
||||
}),
|
||||
|
||||
blogDomain: computed('config.blogDomain', function () {
|
||||
let domain = this.config.blogDomain || '';
|
||||
const host = domain.replace('https://', '').replace('http://', '').split('/');
|
||||
return (host && host[0]) || '';
|
||||
}),
|
||||
|
||||
subscriptionSettings: computed('settings.membersSubscriptionSettings', function () {
|
||||
let subscriptionSettings = this.settings.parseSubscriptionSettings(this.get('settings.membersSubscriptionSettings'));
|
||||
let stripeProcessor = subscriptionSettings.paymentProcessors.find((proc) => {
|
||||
|
@ -133,6 +137,10 @@ export default Component.extend({
|
|||
this.setBulkEmailSettings(bulkEmailSettings);
|
||||
},
|
||||
|
||||
setFromAddress(fromAddress) {
|
||||
this.setFromAddress(fromAddress);
|
||||
},
|
||||
|
||||
setSubscriptionSettings(key, event) {
|
||||
let subscriptionSettings = this.settings.parseSubscriptionSettings(this.get('settings.membersSubscriptionSettings'));
|
||||
let stripeProcessor = subscriptionSettings.paymentProcessors.find((proc) => {
|
||||
|
@ -157,9 +165,6 @@ export default Component.extend({
|
|||
if (key === 'allowSelfSignup') {
|
||||
subscriptionSettings.allowSelfSignup = !subscriptionSettings.allowSelfSignup;
|
||||
}
|
||||
if (key === 'fromAddress') {
|
||||
subscriptionSettings.fromAddress = event.target.value;
|
||||
}
|
||||
|
||||
if (key === 'currency') {
|
||||
stripeProcessor.config.plans.forEach((plan) => {
|
||||
|
|
|
@ -8,6 +8,7 @@ import {
|
|||
isRequestEntityTooLargeError,
|
||||
isUnsupportedMediaTypeError
|
||||
} from 'ghost-admin/services/ajax';
|
||||
import {computed} from '@ember/object';
|
||||
import {isBlank} from '@ember/utils';
|
||||
import {isArray as isEmberArray} from '@ember/array';
|
||||
import {run} from '@ember/runloop';
|
||||
|
@ -70,6 +71,16 @@ export default Controller.extend({
|
|||
this.yamlAccept = [...this.yamlMimeType, ...Array.from(this.yamlExtension, extension => '.' + extension)];
|
||||
},
|
||||
|
||||
fromAddress: computed(function () {
|
||||
return this.parseFromAddress();
|
||||
}),
|
||||
|
||||
blogDomain: computed('config.blogDomain', function () {
|
||||
let blogDomain = this.config.blogDomain || '';
|
||||
const domainExp = blogDomain.replace('https://', '').replace('http://', '').match(new RegExp('^([^/:?#]+)(?:[/:?#]|$)', 'i'));
|
||||
return (domainExp && domainExp[1]) || '';
|
||||
}),
|
||||
|
||||
actions: {
|
||||
onUpload(file) {
|
||||
let formData = new FormData();
|
||||
|
@ -179,6 +190,10 @@ export default Controller.extend({
|
|||
|
||||
setBulkEmailSettings(bulkEmailSettings) {
|
||||
this.set('settings.bulkEmailSettings', bulkEmailSettings);
|
||||
},
|
||||
|
||||
setFromAddress(fromAddress) {
|
||||
this.set('fromAddress', fromAddress);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -223,8 +238,21 @@ export default Controller.extend({
|
|||
return RSVP.resolve();
|
||||
},
|
||||
|
||||
parseFromAddress() {
|
||||
let subscriptionSettings = this.settings.parseSubscriptionSettings(this.get('settings.membersSubscriptionSettings'));
|
||||
const fromAddress = subscriptionSettings.fromAddress || '';
|
||||
// Adds default domain as site domain
|
||||
if (fromAddress.indexOf('@') < 0 && this.blogDomain) {
|
||||
return `${fromAddress}@${this.blogDomain}`;
|
||||
}
|
||||
return fromAddress;
|
||||
},
|
||||
|
||||
saveSettings: task(function* () {
|
||||
return yield this.settings.save();
|
||||
const response = yield this.settings.save();
|
||||
// Reset from address value on save
|
||||
this.set('fromAddress', this.parseFromAddress());
|
||||
return response;
|
||||
}).drop(),
|
||||
|
||||
redirectUploadResult: task(function* (success) {
|
||||
|
|
|
@ -25,10 +25,12 @@
|
|||
{{#liquid-if this.feature.labs.members}}
|
||||
<GhMembersLabSetting
|
||||
@settings={{this.settings}}
|
||||
@fromAddress={{this.fromAddress}}
|
||||
@setDefaultContentVisibility={{action "setDefaultContentVisibility"}}
|
||||
@setMembersSubscriptionSettings={{action "setMembersSubscriptionSettings"}}
|
||||
@setStripeConnectIntegrationTokenSetting={{action "setStripeConnectIntegrationTokenSetting"}}
|
||||
@setBulkEmailSettings={{action "setBulkEmailSettings"}}
|
||||
@setFromAddress={{action "setFromAddress"}}
|
||||
/>
|
||||
<div class="mt5 pl5 pr5 pb5">
|
||||
<GhTaskButton @buttonText="Save members settings"
|
||||
|
|
Loading…
Reference in New Issue