Show box to create newsletter when list is empty
[MAILPOET-2383]
This commit is contained in:
committed by
Jack Kitterhing
parent
36e5574b13
commit
1eb3cba42f
@@ -5,6 +5,7 @@ import ListingHeading from 'newsletters/listings/heading.jsx';
|
|||||||
import FeatureAnnouncement from 'announcements/feature_announcement.jsx';
|
import FeatureAnnouncement from 'announcements/feature_announcement.jsx';
|
||||||
import { checkMailerStatus, addStatsCTAAction } from 'newsletters/listings/utils.jsx';
|
import { checkMailerStatus, addStatsCTAAction } from 'newsletters/listings/utils.jsx';
|
||||||
import Statistics from 'newsletters/listings/statistics.jsx';
|
import Statistics from 'newsletters/listings/statistics.jsx';
|
||||||
|
import NewsletterTypes from 'newsletters/types.jsx';
|
||||||
import SubscribersLimitNotice from 'notices/subscribers_limit_notice.jsx';
|
import SubscribersLimitNotice from 'notices/subscribers_limit_notice.jsx';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import MailPoet from 'mailpoet';
|
import MailPoet from 'mailpoet';
|
||||||
@@ -165,6 +166,7 @@ class Listings extends React.Component {
|
|||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
eventCounts: {},
|
eventCounts: {},
|
||||||
|
newslettersCount: undefined,
|
||||||
};
|
};
|
||||||
this.afterGetItems = this.afterGetItems.bind(this);
|
this.afterGetItems = this.afterGetItems.bind(this);
|
||||||
}
|
}
|
||||||
@@ -384,23 +386,37 @@ class Listings extends React.Component {
|
|||||||
|
|
||||||
{this.renderWarning()}
|
{this.renderWarning()}
|
||||||
|
|
||||||
<Listing
|
{this.state.newslettersCount === 0 && (
|
||||||
limit={window.mailpoet_listing_per_page}
|
<NewsletterTypes
|
||||||
location={location}
|
filter={(type) => type.slug === 'woocommerce'}
|
||||||
params={match.params}
|
showHeader={false}
|
||||||
endpoint="newsletters"
|
/>
|
||||||
type="automatic"
|
)}
|
||||||
base_url="woocommerce"
|
{this.state.newslettersCount !== 0 && (
|
||||||
onRenderItem={this.renderItem}
|
<Listing
|
||||||
columns={columns}
|
limit={window.mailpoet_listing_per_page}
|
||||||
bulk_actions={bulkActions}
|
location={location}
|
||||||
item_actions={newsletterActions}
|
params={match.params}
|
||||||
messages={messages}
|
endpoint="newsletters"
|
||||||
auto_refresh
|
type="automatic"
|
||||||
sort_by="updated_at"
|
base_url="woocommerce"
|
||||||
sort_order="desc"
|
onRenderItem={this.renderItem}
|
||||||
afterGetItems={this.afterGetItems}
|
columns={columns}
|
||||||
/>
|
bulk_actions={bulkActions}
|
||||||
|
item_actions={newsletterActions}
|
||||||
|
messages={messages}
|
||||||
|
auto_refresh
|
||||||
|
sort_by="updated_at"
|
||||||
|
sort_order="desc"
|
||||||
|
afterGetItems={(state) => {
|
||||||
|
if (!state.loading) {
|
||||||
|
const total = state.groups.reduce((count, group) => (count + group.count), 0);
|
||||||
|
this.setState({ newslettersCount: total });
|
||||||
|
}
|
||||||
|
this.afterGetItems(state);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,7 @@ import {
|
|||||||
checkCronStatus,
|
checkCronStatus,
|
||||||
checkMailerStatus,
|
checkMailerStatus,
|
||||||
} from 'newsletters/listings/utils.jsx';
|
} from 'newsletters/listings/utils.jsx';
|
||||||
|
import NewsletterTypes from 'newsletters/types.jsx';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import MailPoet from 'mailpoet';
|
import MailPoet from 'mailpoet';
|
||||||
@@ -171,6 +172,13 @@ class NewsletterListNotification extends React.Component {
|
|||||||
}).isRequired,
|
}).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
newslettersCount: undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
updateStatus = (e) => {
|
updateStatus = (e) => {
|
||||||
// make the event persist so that we can still override the selected value
|
// make the event persist so that we can still override the selected value
|
||||||
// in the ajax callback
|
// in the ajax callback
|
||||||
@@ -343,23 +351,38 @@ class NewsletterListNotification extends React.Component {
|
|||||||
|
|
||||||
<ListingTabs tab="notification" />
|
<ListingTabs tab="notification" />
|
||||||
|
|
||||||
<Listing
|
{this.state.newslettersCount === 0 && (
|
||||||
limit={window.mailpoet_listing_per_page}
|
<NewsletterTypes
|
||||||
location={this.props.location}
|
filter={(type) => type.slug === 'notification'}
|
||||||
params={this.props.match.params}
|
showHeader={false}
|
||||||
endpoint="newsletters"
|
/>
|
||||||
type="notification"
|
)}
|
||||||
base_url="notification"
|
{this.state.newslettersCount !== 0 && (
|
||||||
onRenderItem={this.renderItem}
|
<Listing
|
||||||
columns={columns}
|
limit={window.mailpoet_listing_per_page}
|
||||||
bulk_actions={bulkActions}
|
location={this.props.location}
|
||||||
item_actions={newsletterActions}
|
params={this.props.match.params}
|
||||||
messages={messages}
|
endpoint="newsletters"
|
||||||
auto_refresh
|
type="notification"
|
||||||
sort_by="updated_at"
|
base_url="notification"
|
||||||
sort_order="desc"
|
onRenderItem={this.renderItem}
|
||||||
afterGetItems={(state) => { checkMailerStatus(state); checkCronStatus(state); }}
|
columns={columns}
|
||||||
/>
|
bulk_actions={bulkActions}
|
||||||
|
item_actions={newsletterActions}
|
||||||
|
messages={messages}
|
||||||
|
auto_refresh
|
||||||
|
sort_by="updated_at"
|
||||||
|
sort_order="desc"
|
||||||
|
afterGetItems={(state) => {
|
||||||
|
if (!state.loading) {
|
||||||
|
const total = state.groups.reduce((count, group) => (count + group.count), 0);
|
||||||
|
this.setState({ newslettersCount: total });
|
||||||
|
}
|
||||||
|
checkMailerStatus(state);
|
||||||
|
checkCronStatus(state);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,7 @@ import {
|
|||||||
checkCronStatus,
|
checkCronStatus,
|
||||||
checkMailerStatus,
|
checkMailerStatus,
|
||||||
} from 'newsletters/listings/utils.jsx';
|
} from 'newsletters/listings/utils.jsx';
|
||||||
|
import NewsletterTypes from 'newsletters/types.jsx';
|
||||||
import SubscribersLimitNotice from 'notices/subscribers_limit_notice.jsx';
|
import SubscribersLimitNotice from 'notices/subscribers_limit_notice.jsx';
|
||||||
import { GlobalContext } from 'context/index.jsx';
|
import { GlobalContext } from 'context/index.jsx';
|
||||||
|
|
||||||
@@ -183,6 +184,13 @@ class NewsletterListStandard extends React.Component {
|
|||||||
}).isRequired,
|
}).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
newslettersCount: undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
renderItem = (newsletter, actions, meta) => {
|
renderItem = (newsletter, actions, meta) => {
|
||||||
const rowClasses = classNames(
|
const rowClasses = classNames(
|
||||||
'manage-column',
|
'manage-column',
|
||||||
@@ -237,23 +245,38 @@ class NewsletterListStandard extends React.Component {
|
|||||||
|
|
||||||
<ListingTabs tab="standard" />
|
<ListingTabs tab="standard" />
|
||||||
|
|
||||||
<Listing
|
{this.state.newslettersCount === 0 && (
|
||||||
limit={window.mailpoet_listing_per_page}
|
<NewsletterTypes
|
||||||
location={this.props.location}
|
filter={(type) => type.slug === 'standard'}
|
||||||
params={this.props.match.params}
|
showHeader={false}
|
||||||
endpoint="newsletters"
|
/>
|
||||||
type="standard"
|
)}
|
||||||
base_url="standard"
|
{this.state.newslettersCount !== 0 && (
|
||||||
onRenderItem={this.renderItem}
|
<Listing
|
||||||
columns={columns}
|
limit={window.mailpoet_listing_per_page}
|
||||||
bulk_actions={bulkActions}
|
location={this.props.location}
|
||||||
item_actions={newsletterActions}
|
params={this.props.match.params}
|
||||||
messages={messages}
|
endpoint="newsletters"
|
||||||
auto_refresh
|
type="standard"
|
||||||
sort_by="sent_at"
|
base_url="standard"
|
||||||
sort_order="desc"
|
onRenderItem={this.renderItem}
|
||||||
afterGetItems={(state) => { checkMailerStatus(state); checkCronStatus(state); }}
|
columns={columns}
|
||||||
/>
|
bulk_actions={bulkActions}
|
||||||
|
item_actions={newsletterActions}
|
||||||
|
messages={messages}
|
||||||
|
auto_refresh
|
||||||
|
sort_by="sent_at"
|
||||||
|
sort_order="desc"
|
||||||
|
afterGetItems={(state) => {
|
||||||
|
if (!state.loading) {
|
||||||
|
const total = state.groups.reduce((count, group) => (count + group.count), 0);
|
||||||
|
this.setState({ newslettersCount: total });
|
||||||
|
}
|
||||||
|
checkMailerStatus(state);
|
||||||
|
checkCronStatus(state);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -13,6 +13,7 @@ import {
|
|||||||
checkCronStatus,
|
checkCronStatus,
|
||||||
checkMailerStatus,
|
checkMailerStatus,
|
||||||
} from 'newsletters/listings/utils.jsx';
|
} from 'newsletters/listings/utils.jsx';
|
||||||
|
import NewsletterTypes from 'newsletters/types.jsx';
|
||||||
import SubscribersLimitNotice from 'notices/subscribers_limit_notice.jsx';
|
import SubscribersLimitNotice from 'notices/subscribers_limit_notice.jsx';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
@@ -166,6 +167,13 @@ class NewsletterListWelcome extends React.Component {
|
|||||||
}).isRequired,
|
}).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
newslettersCount: undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
updateStatus = (e) => {
|
updateStatus = (e) => {
|
||||||
// make the event persist so that we can still override the selected value
|
// make the event persist so that we can still override the selected value
|
||||||
// in the ajax callback
|
// in the ajax callback
|
||||||
@@ -359,23 +367,38 @@ class NewsletterListWelcome extends React.Component {
|
|||||||
|
|
||||||
<ListingTabs tab="welcome" />
|
<ListingTabs tab="welcome" />
|
||||||
|
|
||||||
<Listing
|
{this.state.newslettersCount === 0 && (
|
||||||
limit={window.mailpoet_listing_per_page}
|
<NewsletterTypes
|
||||||
location={this.props.location}
|
filter={(type) => type.slug === 'welcome'}
|
||||||
params={this.props.match.params}
|
showHeader={false}
|
||||||
endpoint="newsletters"
|
/>
|
||||||
type="welcome"
|
)}
|
||||||
base_url="welcome"
|
{this.state.newslettersCount !== 0 && (
|
||||||
onRenderItem={this.renderItem}
|
<Listing
|
||||||
columns={columns}
|
limit={window.mailpoet_listing_per_page}
|
||||||
bulk_actions={bulkActions}
|
location={this.props.location}
|
||||||
item_actions={newsletterActions}
|
params={this.props.match.params}
|
||||||
messages={messages}
|
endpoint="newsletters"
|
||||||
auto_refresh
|
type="welcome"
|
||||||
sort_by="updated_at"
|
base_url="welcome"
|
||||||
sort_order="desc"
|
onRenderItem={this.renderItem}
|
||||||
afterGetItems={(state) => { checkMailerStatus(state); checkCronStatus(state); }}
|
columns={columns}
|
||||||
/>
|
bulk_actions={bulkActions}
|
||||||
|
item_actions={newsletterActions}
|
||||||
|
messages={messages}
|
||||||
|
auto_refresh
|
||||||
|
sort_by="updated_at"
|
||||||
|
sort_order="desc"
|
||||||
|
afterGetItems={(state) => {
|
||||||
|
if (!state.loading) {
|
||||||
|
const total = state.groups.reduce((count, group) => (count + group.count), 0);
|
||||||
|
this.setState({ newslettersCount: total });
|
||||||
|
}
|
||||||
|
checkMailerStatus(state);
|
||||||
|
checkCronStatus(state);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user