Use same link to statistics for free and premium plugin
[MAILPOET-2104]
This commit is contained in:
@@ -2,7 +2,6 @@ import React from 'react';
|
|||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import MailPoet from 'mailpoet';
|
import MailPoet from 'mailpoet';
|
||||||
import Hooks from 'wp-js-hooks';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import Listing from 'listing/listing.jsx';
|
import Listing from 'listing/listing.jsx';
|
||||||
@@ -56,9 +55,7 @@ let newsletterActions = [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
newsletterActions = addStatsCTAAction(newsletterActions);
|
||||||
Hooks.addFilter('mailpoet_newsletters_listings_notification_history_actions', 'mailpoet', addStatsCTAAction);
|
|
||||||
newsletterActions = Hooks.applyFilters('mailpoet_newsletters_listings_notification_history_actions', newsletterActions);
|
|
||||||
|
|
||||||
class NewsletterListNotificationHistory extends React.Component {
|
class NewsletterListNotificationHistory extends React.Component {
|
||||||
static displayName = 'NewsletterListNotificationHistory';
|
static displayName = 'NewsletterListNotificationHistory';
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import MailPoet from 'mailpoet';
|
import MailPoet from 'mailpoet';
|
||||||
import Hooks from 'wp-js-hooks';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import confirmAlert from 'common/confirm_alert.jsx';
|
import confirmAlert from 'common/confirm_alert.jsx';
|
||||||
@@ -167,9 +166,7 @@ let newsletterActions = [
|
|||||||
name: 'trash',
|
name: 'trash',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
newsletterActions = addStatsCTAAction(newsletterActions);
|
||||||
Hooks.addFilter('mailpoet_newsletters_listings_standard_actions', 'mailpoet', addStatsCTAAction);
|
|
||||||
newsletterActions = Hooks.applyFilters('mailpoet_newsletters_listings_standard_actions', newsletterActions);
|
|
||||||
|
|
||||||
class NewsletterListStandard extends React.Component {
|
class NewsletterListStandard extends React.Component {
|
||||||
static displayName = 'NewsletterListStandard';
|
static displayName = 'NewsletterListStandard';
|
||||||
|
@@ -35,17 +35,6 @@ const wrapInLink = (content, params, id, totalSent) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const addStatsCTALink = (params) => {
|
|
||||||
if (window.mailpoet_premium_active) {
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
const newParams = params;
|
|
||||||
newParams.link = 'admin.php?page=mailpoet-premium';
|
|
||||||
newParams.externalLink = true;
|
|
||||||
newParams.onClick = trackStatsCTAClicked;
|
|
||||||
return newParams;
|
|
||||||
};
|
|
||||||
|
|
||||||
const Statistics = ({ newsletter, isSent, currentTime }) => {
|
const Statistics = ({ newsletter, isSent, currentTime }) => {
|
||||||
let sent = isSent;
|
let sent = isSent;
|
||||||
if (sent === undefined) {
|
if (sent === undefined) {
|
||||||
@@ -60,9 +49,10 @@ const Statistics = ({ newsletter, isSent, currentTime }) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let params = {};
|
const params = {
|
||||||
Hooks.addFilter('mailpoet_newsletters_listing_stats_before', 'mailpoet', addStatsCTALink);
|
link: `/stats/${newsletter.id}`,
|
||||||
params = Hooks.applyFilters('mailpoet_newsletters_listing_stats_before', params, newsletter);
|
onClick: Hooks.applyFilters('mailpoet_newsletters_listing_stats_tracking', trackStatsCTAClicked),
|
||||||
|
};
|
||||||
|
|
||||||
// welcome emails provide explicit total_sent value
|
// welcome emails provide explicit total_sent value
|
||||||
const totalSent = Number((newsletter.total_sent || newsletter.queue.count_processed));
|
const totalSent = Number((newsletter.total_sent || newsletter.queue.count_processed));
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
import ReactStringReplace from 'react-string-replace';
|
import ReactStringReplace from 'react-string-replace';
|
||||||
|
import Hooks from 'wp-js-hooks';
|
||||||
import MailPoet from 'mailpoet';
|
import MailPoet from 'mailpoet';
|
||||||
import jQuery from 'jquery';
|
import jQuery from 'jquery';
|
||||||
|
|
||||||
@@ -12,16 +14,16 @@ export const trackStatsCTAClicked = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const addStatsCTAAction = (actions) => {
|
export const addStatsCTAAction = (actions) => {
|
||||||
if (window.mailpoet_premium_active) {
|
|
||||||
return actions;
|
|
||||||
}
|
|
||||||
actions.unshift({
|
actions.unshift({
|
||||||
name: 'stats',
|
name: 'stats',
|
||||||
link: function link() {
|
link: function link(newsletter) {
|
||||||
return (
|
return (
|
||||||
<a href="admin.php?page=mailpoet-premium" onClick={trackStatsCTAClicked}>
|
<Link
|
||||||
|
to={`/stats/${newsletter.id}`}
|
||||||
|
onClick={Hooks.applyFilters('mailpoet_newsletters_listing_stats_tracking', trackStatsCTAClicked)}
|
||||||
|
>
|
||||||
{MailPoet.I18n.t('statsListingActionTitle')}
|
{MailPoet.I18n.t('statsListingActionTitle')}
|
||||||
</a>
|
</Link>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
display: function display(newsletter) {
|
display: function display(newsletter) {
|
||||||
|
@@ -17,7 +17,6 @@ import {
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import MailPoet from 'mailpoet';
|
import MailPoet from 'mailpoet';
|
||||||
import _ from 'underscore';
|
import _ from 'underscore';
|
||||||
import Hooks from 'wp-js-hooks';
|
|
||||||
|
|
||||||
const mailpoetRoles = window.mailpoet_roles || {};
|
const mailpoetRoles = window.mailpoet_roles || {};
|
||||||
const mailpoetSegments = window.mailpoet_segments || {};
|
const mailpoetSegments = window.mailpoet_segments || {};
|
||||||
@@ -153,9 +152,7 @@ let newsletterActions = [
|
|||||||
name: 'trash',
|
name: 'trash',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
newsletterActions = addStatsCTAAction(newsletterActions);
|
||||||
Hooks.addFilter('mailpoet_newsletters_listings_welcome_notification_actions', 'mailpoet', addStatsCTAAction);
|
|
||||||
newsletterActions = Hooks.applyFilters('mailpoet_newsletters_listings_welcome_notification_actions', newsletterActions);
|
|
||||||
|
|
||||||
class NewsletterListWelcome extends React.Component {
|
class NewsletterListWelcome extends React.Component {
|
||||||
static displayName = 'NewsletterListWelcome';
|
static displayName = 'NewsletterListWelcome';
|
||||||
|
@@ -101,10 +101,7 @@ SendingStatusListing.propTypes = {
|
|||||||
|
|
||||||
const StatsLink = ({ newsletterId, newsletterSubject }) => {
|
const StatsLink = ({ newsletterId, newsletterSubject }) => {
|
||||||
if (!newsletterId || !newsletterSubject) return null;
|
if (!newsletterId || !newsletterSubject) return null;
|
||||||
if (window.mailpoet_premium_active) {
|
|
||||||
return <p><Link to={`/stats/${newsletterId}`}>{ newsletterSubject }</Link></p>;
|
return <p><Link to={`/stats/${newsletterId}`}>{ newsletterSubject }</Link></p>;
|
||||||
}
|
|
||||||
return <p><a href="admin.php?page=mailpoet-premium">{newsletterSubject}</a></p>;
|
|
||||||
};
|
};
|
||||||
StatsLink.propTypes = {
|
StatsLink.propTypes = {
|
||||||
newsletterId: PropTypes.string,
|
newsletterId: PropTypes.string,
|
||||||
|
Reference in New Issue
Block a user