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