Display unapproved key notice for sending step, disable send buttons

[MAILPOET-2729]
This commit is contained in:
Jan Jakeš
2020-03-17 12:27:22 +01:00
committed by Veljko V
parent 5160498c22
commit 7d352062ba
4 changed files with 40 additions and 4 deletions

View File

@@ -454,6 +454,9 @@ class NewsletterSend extends React.Component {
'send' 'send'
); );
const sendingDisabled = window.mailpoet_subscribers_limit_reached
|| window.mailpoet_mss_key_pending_approval;
return ( return (
<div> <div>
<h1>{MailPoet.I18n.t('finalNewsletterStep')}</h1> <h1>{MailPoet.I18n.t('finalNewsletterStep')}</h1>
@@ -479,7 +482,7 @@ class NewsletterSend extends React.Component {
type="button" type="button"
onClick={this.handleResume} onClick={this.handleResume}
value={MailPoet.I18n.t('resume')} value={MailPoet.I18n.t('resume')}
disabled={window.mailpoet_subscribers_limit_reached} disabled={sendingDisabled}
/> />
) )
: ( : (
@@ -489,7 +492,7 @@ class NewsletterSend extends React.Component {
onClick={this.handleSend} onClick={this.handleSend}
value={MailPoet.I18n.t('send')} value={MailPoet.I18n.t('send')}
{...sendButtonOptions} // eslint-disable-line react/jsx-props-no-spreading {...sendButtonOptions} // eslint-disable-line react/jsx-props-no-spreading
disabled={window.mailpoet_subscribers_limit_reached} disabled={sendingDisabled}
/> />
) )
} }
@@ -518,6 +521,26 @@ class NewsletterSend extends React.Component {
tooltipId="helpTooltipSendEmail" tooltipId="helpTooltipSendEmail"
/> />
) } ) }
{ window.mailpoet_mss_key_pending_approval && (
<div className="mailpoet_error">
{
ReactStringReplace(
MailPoet.I18n.t('pendingKeyApprovalNotice'),
/\[link\](.*?)\[\/link\]/g,
(match) => (
<a
key="pendingKeyApprovalNoticeLink"
href="https://account.mailpoet.com/authorization"
target="_blank"
rel="noopener noreferrer"
>
{match}
</a>
)
)
}
</div>
) }
</Form> </Form>
</div> </div>
); );

View File

@@ -6,6 +6,7 @@ use MailPoet\AdminPages\PageRenderer;
use MailPoet\Config\Env; use MailPoet\Config\Env;
use MailPoet\Config\Installer; use MailPoet\Config\Installer;
use MailPoet\Config\Menu; use MailPoet\Config\Menu;
use MailPoet\Config\ServicesChecker;
use MailPoet\Features\FeaturesController; use MailPoet\Features\FeaturesController;
use MailPoet\Listing\PageLimit; use MailPoet\Listing\PageLimit;
use MailPoet\Models\Newsletter; use MailPoet\Models\Newsletter;
@@ -50,6 +51,9 @@ class Newsletters {
/** @var SubscribersFeature */ /** @var SubscribersFeature */
private $subscribersFeature; private $subscribersFeature;
/** @var ServicesChecker */
private $servicesChecker;
public function __construct( public function __construct(
PageRenderer $pageRenderer, PageRenderer $pageRenderer,
PageLimit $listingPageLimit, PageLimit $listingPageLimit,
@@ -59,7 +63,8 @@ class Newsletters {
WooCommerceHelper $woocommerceHelper, WooCommerceHelper $woocommerceHelper,
Installation $installation, Installation $installation,
FeaturesController $featuresController, FeaturesController $featuresController,
SubscribersFeature $subscribersFeature SubscribersFeature $subscribersFeature,
ServicesChecker $servicesChecker
) { ) {
$this->pageRenderer = $pageRenderer; $this->pageRenderer = $pageRenderer;
$this->listingPageLimit = $listingPageLimit; $this->listingPageLimit = $listingPageLimit;
@@ -70,6 +75,7 @@ class Newsletters {
$this->installation = $installation; $this->installation = $installation;
$this->featuresController = $featuresController; $this->featuresController = $featuresController;
$this->subscribersFeature = $subscribersFeature; $this->subscribersFeature = $subscribersFeature;
$this->servicesChecker = $servicesChecker;
} }
public function render() { public function render() {
@@ -102,6 +108,11 @@ class Newsletters {
$data['roles'] = $wp_roles->get_names(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps $data['roles'] = $wp_roles->get_names(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$data['roles']['mailpoet_all'] = $this->wp->__('In any WordPress role', 'mailpoet'); $data['roles']['mailpoet_all'] = $this->wp->__('In any WordPress role', 'mailpoet');
$mssActive = Bridge::isMPSendingServiceEnabled();
$mssKeyValid = $this->servicesChecker->isMailPoetAPIKeyValid();
$mssKeyPendingApproval = $this->settings->get('mta.mailpoet_api_key_state.data.is_approved') === false;
$data['mss_key_pending_approval'] = $mssActive && $mssKeyValid && $mssKeyPendingApproval;
$installedAtDateTime = new \DateTime($data['settings']['installed_at']); $installedAtDateTime = new \DateTime($data['settings']['installed_at']);
$data['installed_days_ago'] = (int)$installedAtDateTime->diff(new \DateTime())->format('%a'); $data['installed_days_ago'] = (int)$installedAtDateTime->diff(new \DateTime())->format('%a');
$data['subscribers_limit'] = $this->subscribersFeature->getSubscribersLimit(); $data['subscribers_limit'] = $this->subscribersFeature->getSubscribersLimit();

View File

@@ -18,7 +18,7 @@
{{#if mssKeyPendingApproval }} {{#if mssKeyPendingApproval }}
<div class="mailpoet_error"> <div class="mailpoet_error">
<%= __('Youll soon be able to send once our team reviews your account. In the meantime, you can send previews to [link]your authorized emails[/link].')|replaceLinkTags('https://account.mailpoet.com/authorization', {'target': '_blank'})|raw %> <%= __('Youll soon be able to send once our team reviews your account. In the meantime, you can send previews to [link]your authorized emails[/link].')|replaceLinkTags('https://account.mailpoet.com/authorization', {'target': '_blank', 'rel': 'noopener noreferrer'})|raw %>
</div> </div>
{{/if}} {{/if}}

View File

@@ -58,6 +58,7 @@
<% endif %> <% endif %>
<% endautoescape %> <% endautoescape %>
var mailpoet_beacon_articles = ['57fdc312c697911f2d324fd7', '5a0257ac2c7d3a272c0d7ad6', '58f671152c7d3a057f8858e8']; var mailpoet_beacon_articles = ['57fdc312c697911f2d324fd7', '5a0257ac2c7d3a272c0d7ad6', '58f671152c7d3a057f8858e8'];
var mailpoet_mss_key_pending_approval = '<%= mss_key_pending_approval %>';
</script> </script>
<% endblock %> <% endblock %>
@@ -241,6 +242,7 @@
'finalNewsletterStep': __('Final Step: Last Details'), 'finalNewsletterStep': __('Final Step: Last Details'),
'saveDraftAndClose': __('Save as draft and close'), 'saveDraftAndClose': __('Save as draft and close'),
'helpTooltipSendEmail': __('You cannot send the same email twice, as that would be considered spam. <br /> If you must send the same email more than one time, simply duplicate this email first.'), 'helpTooltipSendEmail': __('You cannot send the same email twice, as that would be considered spam. <br /> If you must send the same email more than one time, simply duplicate this email first.'),
'pendingKeyApprovalNotice': __('Youll soon be able to send once our team reviews your account. In the meantime, you can send previews to [link]your authorized emails[/link].'),
'orSimply': __('or simply'), 'orSimply': __('or simply'),
'goBackToDesign': __('go back to the Design page'), 'goBackToDesign': __('go back to the Design page'),
'websiteTimeIs': __("Your websites time is"), 'websiteTimeIs': __("Your websites time is"),