Convert resume sending button JS to TS, fix missing mta method var
[MAILPOET-3830]
This commit is contained in:
@@ -16,6 +16,7 @@ var MailPoet = {
|
||||
hasPremiumSupport: window.mailpoet_has_premium_support,
|
||||
hasValidApiKey: window.mailpoet_has_valid_api_key,
|
||||
hasInvalidMssApiKey: window.mailpoet_mss_key_invalid,
|
||||
mtaMethod: window.mailpoet_mta_method,
|
||||
listingPerPage: window.mailpoet_listing_per_page,
|
||||
libs3rdPartyEnabled: window.mailpoet_3rd_party_libs_enabled,
|
||||
apiVersion: window.mailpoet_api_version,
|
||||
|
@@ -2,19 +2,19 @@ import jQuery from 'jquery';
|
||||
import MailPoet from 'mailpoet';
|
||||
|
||||
const loadAuthorizedEmailAddresses = async () => {
|
||||
if (window.mailpoet_mta_method !== 'MailPoet') {
|
||||
if (MailPoet.mtaMethod !== 'MailPoet') {
|
||||
return [];
|
||||
}
|
||||
const response = await MailPoet.Ajax.post({
|
||||
api_version: window.mailpoet_api_version,
|
||||
api_version: MailPoet.apiVersion,
|
||||
endpoint: 'mailer',
|
||||
action: 'getAuthorizedEmailAddresses',
|
||||
});
|
||||
return response.data || [];
|
||||
};
|
||||
|
||||
const isValidFromAddress = async (fromAddress) => {
|
||||
if (window.mailpoet_mta_method !== 'MailPoet') {
|
||||
const isValidFromAddress = async (fromAddress: string | null) => {
|
||||
if (MailPoet.mtaMethod !== 'MailPoet') {
|
||||
return true;
|
||||
}
|
||||
const addresses = await loadAuthorizedEmailAddresses();
|
||||
@@ -23,12 +23,11 @@ const isValidFromAddress = async (fromAddress) => {
|
||||
|
||||
const resumeMailerSending = () => {
|
||||
MailPoet.Ajax.post({
|
||||
api_version: window.mailpoet_api_version,
|
||||
api_version: MailPoet.apiVersion,
|
||||
endpoint: 'mailer',
|
||||
action: 'resumeSending',
|
||||
}).done(() => {
|
||||
MailPoet.Notice.success(MailPoet.I18n.t('mailerSendingResumedNotice'));
|
||||
window.mailpoet_listing.forceUpdate();
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
@@ -39,7 +38,7 @@ const resumeMailerSending = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const resumeSendingIfAuthorized = (fromAddress) => isValidFromAddress(fromAddress)
|
||||
const resumeSendingIfAuthorized = (fromAddress: string | null) => isValidFromAddress(fromAddress)
|
||||
.then((valid) => {
|
||||
if (!valid) {
|
||||
MailPoet.Notice.error(
|
@@ -15,4 +15,4 @@ import 'wizard/wizard.jsx'; // side effect - renders ReactDOM to document
|
||||
import 'experimental_features/experimental_features.jsx'; // side effect - renders ReactDOM to document
|
||||
import 'logs/logs'; // side effect - renders ReactDOM to document
|
||||
import 'sending-paused-notices-fix-button.tsx'; // side effect - renders ReactDOM to document
|
||||
import 'sending-paused-notices-resume-button.jsx'; // side effect - executes on doc ready, adds events
|
||||
import 'sending-paused-notices-resume-button.ts'; // side effect - executes on doc ready, adds events
|
||||
|
Reference in New Issue
Block a user