Fixing more bugs. Lists and scheduling options are hidden when editing a newsletter that is being sent

This commit is contained in:
Amine Ben hammou
2017-08-15 14:29:39 +00:00
parent 033d527db9
commit 9117ae1a27
3 changed files with 27 additions and 16 deletions

View File

@@ -250,6 +250,12 @@ define(
return true;
},
render: function () {
const isPaused = this.state.item.status == 'sending'
&& this.state.item.queue
&& this.state.item.queue.status == 'paused';
const fields = (!isPaused)
? this.state.fields
: this.state.fields.filter(field => field.name != 'segments' && field.name != 'options');
return (
<div>
<h1>{MailPoet.I18n.t('finalNewsletterStep')}</h1>
@@ -258,32 +264,30 @@ define(
<Form
id="mailpoet_newsletter"
fields={ this.state.fields }
fields={ fields }
item={ this.state.item }
loading={ this.state.loading }
onChange={this.handleFormChange}
onSubmit={this.handleSave}
>
<p className="submit">
<input
{
isPaused ?
<input
className="button button-primary"
type="button"
onClick={ this.handleResume }
value={MailPoet.I18n.t('resume')} />
:
<input
className="button button-primary"
type="button"
onClick={ this.handleSend }
value={MailPoet.I18n.t('send')}
{...this.getSendButtonOptions()}
/>
&nbsp;
{
this.state.item.status == 'sending'
&& this.state.item.queue
&& this.state.item.queue.status == 'paused'
? <input
className="button button-secondary"
type="button"
onClick={ this.handleResume }
value={MailPoet.I18n.t('resume')} />
: null
}
&nbsp;
<input
className="button button-secondary"
type="submit"

View File

@@ -34,7 +34,7 @@ class LinksTest extends \MailPoetTest {
);
}
function testItDoesnotRehashExistingLinks() {
function testItDoesNotRehashExistingLinks() {
$link = NewsletterLink::create();
$link->newsletter_id = 3;
$link->queue_id = 3;

View File

@@ -341,7 +341,7 @@
'unsavedChangesWillBeLost': __('There are unsaved changes which will be lost if you leave this page.'),
'selectColor': _x('Select', 'select color'),
'cancelColorSelection': _x('Cancel', 'cancel color selection'),
'newsletterIsPaused': __('Email sending has been paused'),
'newsletterIsPaused': __('Email sending has been paused.'),
}) %>
<% endblock %>
@@ -1226,7 +1226,14 @@
}
}).done(response =>
MailPoet.Notice.success(MailPoet.I18n.t('newsletterIsPaused'))
);
).fail(function(response) {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true, static: true }
);
}
});
}
}).fail(function(response) {
if (response.errors.length > 0) {