diff --git a/ghost/admin/app/components/gh-members-lab-setting.js b/ghost/admin/app/components/gh-members-lab-setting.js index 2cfe43ce74..9bde953e05 100644 --- a/ghost/admin/app/components/gh-members-lab-setting.js +++ b/ghost/admin/app/components/gh-members-lab-setting.js @@ -29,17 +29,19 @@ export default Component.extend({ subscriptionSettings.stripeConfig = stripeProcessor.config; subscriptionSettings.allowSelfSignup = !!subscriptionSettings.allowSelfSignup; subscriptionSettings.fromAddress = subscriptionSettings.fromAddress || ''; - if (Object.keys(subscriptionSettings).includes('mailgunApiKey')) { - subscriptionSettings.mailgunApiKey = subscriptionSettings.mailgunApiKey || ''; - subscriptionSettings.mailgunDomain = subscriptionSettings.mailgunDomain || ''; - } return subscriptionSettings; }), - hasMailgunAPIKeyOption: computed('settings.membersSubscriptionSettings', function () { - let subscriptionSettings = this.parseSubscriptionSettings(this.get('settings.membersSubscriptionSettings')); - return Object.keys(subscriptionSettings).includes('mailgunApiKey'); + bulkEmailSettings: computed('settings.bulkEmailSettings', function () { + let bulkEmailSettings = this.get('settings.bulkEmailSettings') || {}; + const {apiKey = '', baseUrl = '', domain = ''} = bulkEmailSettings; + return {apiKey, baseUrl, domain}; + }), + + hasBulkEmailConfig: computed('settings.bulkEmailSettings', function () { + let bulkEmailSettings = this.get('settings.bulkEmailSettings'); + return !!bulkEmailSettings.isConfig; }), defaultContentVisibility: computed('settings.defaultContentVisibility', function () { @@ -50,6 +52,11 @@ export default Component.extend({ setDefaultContentVisibility(value) { this.setDefaultContentVisibility(value); }, + setBulkEmailSettings(key, event) { + let bulkEmailSettings = this.get('settings.bulkEmailSettings') || {}; + bulkEmailSettings[key] = event.target.value; + this.setBulkEmailSettings(bulkEmailSettings); + }, setSubscriptionSettings(key, event) { let subscriptionSettings = this.parseSubscriptionSettings(this.get('settings.membersSubscriptionSettings')); let stripeProcessor = subscriptionSettings.paymentProcessors.find((proc) => { @@ -80,12 +87,6 @@ export default Component.extend({ if (key === 'fromAddress') { subscriptionSettings.fromAddress = event.target.value; } - if (key === 'mailgunApiKey') { - subscriptionSettings.mailgunApiKey = event.target.value; - } - if (key === 'mailgunDomain') { - subscriptionSettings.mailgunDomain = event.target.value; - } this.setMembersSubscriptionSettings(subscriptionSettings); } }, diff --git a/ghost/admin/app/controllers/settings/labs.js b/ghost/admin/app/controllers/settings/labs.js index 7963d93bd4..53b146988d 100644 --- a/ghost/admin/app/controllers/settings/labs.js +++ b/ghost/admin/app/controllers/settings/labs.js @@ -163,6 +163,10 @@ export default Controller.extend({ setMembersSubscriptionSettings(subscriptionSettings) { this.set('settings.membersSubscriptionSettings', JSON.stringify(subscriptionSettings)); + }, + + setBulkEmailSettings(bulkEmailSettings) { + this.set('settings.bulkEmailSettings', bulkEmailSettings); } }, diff --git a/ghost/admin/app/templates/components/gh-members-lab-setting.hbs b/ghost/admin/app/templates/components/gh-members-lab-setting.hbs index 86ec02f68a..190835a337 100644 --- a/ghost/admin/app/templates/components/gh-members-lab-setting.hbs +++ b/ghost/admin/app/templates/components/gh-members-lab-setting.hbs @@ -185,12 +185,12 @@
Your members will receive system emails from this address
{{/gh-form-group}} - {{#if hasMailgunAPIKeyOption}} + {{#unless hasBulkEmailConfig}} {{#gh-form-group}} {{gh-text-input - value=(readonly subscriptionSettings.mailgunDomain) - input=(action "setSubscriptionSettings" "mailgunDomain") + value=(readonly bulkEmailSettings.domain) + input=(action "setBulkEmailSettings" "domain") class="mt1" }} @@ -201,8 +201,8 @@ {{gh-text-input type="password" - value=(readonly subscriptionSettings.mailgunApiKey) - input=(action "setSubscriptionSettings" "mailgunApiKey") + value=(readonly bulkEmailSettings.apiKey) + input=(action "setBulkEmailSettings" "apiKey") class="mt1 password" autocomplete="new-password" }} @@ -210,7 +210,16 @@ Find your Mailgun API keys here » {{/gh-form-group}} - {{/if}} + + {{#gh-form-group}} + + {{gh-text-input + value=(readonly bulkEmailSettings.baseUrl) + input=(action "setBulkEmailSettings" "baseUrl") + class="mt1" + }} + {{/gh-form-group}} + {{/unless}} {{/liquid-if}} diff --git a/ghost/admin/app/templates/settings/labs.hbs b/ghost/admin/app/templates/settings/labs.hbs index b2710b800c..9d380b41c3 100644 --- a/ghost/admin/app/templates/settings/labs.hbs +++ b/ghost/admin/app/templates/settings/labs.hbs @@ -27,6 +27,7 @@ settings=settings setDefaultContentVisibility=(action "setDefaultContentVisibility") setMembersSubscriptionSettings=(action "setMembersSubscriptionSettings") + setBulkEmailSettings=(action "setBulkEmailSettings") }}
{{gh-task-button "Save members settings"