From 4055e3bd1cd76b1a72d4cfdd0541fe34d74504ea Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 5 Aug 2022 15:39:22 -0400 Subject: [PATCH] feat: automatically enable the SMTP transport option if the SMTP service is changed --- public/language/en-GB/admin/settings/email.json | 1 + public/src/admin/settings/email.js | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/public/language/en-GB/admin/settings/email.json b/public/language/en-GB/admin/settings/email.json index e6f92fb8ec..93ffe374f9 100644 --- a/public/language/en-GB/admin/settings/email.json +++ b/public/language/en-GB/admin/settings/email.json @@ -13,6 +13,7 @@ "smtp-transport.service-help": "Select a service name above in order to use the known information about it. Alternatively, select "Custom Service" and enter the details below.", "smtp-transport.gmail-warning1": "If you are using GMail as your email provider, you will have to generate an "App Password" in order for NodeBB to authenticate successfully. You can generate one at the App Passwords page.", "smtp-transport.gmail-warning2": "For more information about this workaround, please consult this NodeMailer article on the issue. An alternative would be to utilise a third-party emailer plugin such as SendGrid, Mailgun, etc. Browse available plugins here.", + "smtp-transport.auto-enable-toast": "It looks like you're configuring an SMTP transport. We enabled the \"SMTP Transport\" option for you.", "smtp-transport.host": "SMTP Host", "smtp-transport.port": "SMTP Port", "smtp-transport.security": "Connection security", diff --git a/public/src/admin/settings/email.js b/public/src/admin/settings/email.js index 20f5d8587d..e1598c2c0b 100644 --- a/public/src/admin/settings/email.js +++ b/public/src/admin/settings/email.js @@ -108,6 +108,18 @@ define('admin/settings/email', ['ace/ace', 'alerts', 'admin/settings'], function function handleSmtpServiceChange() { const isCustom = $('[id="email:smtpTransport:service"]').val() === 'nodebb-custom-smtp'; $('[id="email:smtpTransport:custom-service"]')[isCustom ? 'slideDown' : 'slideUp'](isCustom); + + const enabledEl = document.getElementById('email:smtpTransport:enabled'); + if (enabledEl) { + if (!enabledEl.checked) { + enabledEl.closest('label').classList.toggle('is-checked', true); + enabledEl.checked = true; + alerts.alert({ + message: '[[admin/settings/email:smtp-transport.auto-enable-toast]]', + timeout: 5000, + }); + } + } } return module;