feat: automatically enable the SMTP transport option if the SMTP service is changed

isekai-main
Julian Lam 3 years ago
parent 3e56c547a9
commit 4055e3bd1c

@ -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 &quot;App Password&quot; in order for NodeBB to authenticate successfully. You can generate one at the <a href=\"https://myaccount.google.com/apppasswords\">App Passwords <i class=\"fa fa-external-link\"></i></a> page.",
"smtp-transport.gmail-warning2": "For more information about this workaround, <a href=\"https://nodemailer.com/usage/using-gmail/\">please consult this NodeMailer article <i class=\"fa fa-external-link\"></i></a> on the issue. An alternative would be to utilise a third-party emailer plugin such as SendGrid, Mailgun, etc. <a href=\"../extend/plugins\">Browse available plugins here</a>.",
"smtp-transport.auto-enable-toast": "It looks like you&apos;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",

@ -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;

Loading…
Cancel
Save