Fix ESLint and PHPCS errors
This commit is contained in:
committed by
M. Shull
parent
abfd00fd6d
commit
0d27d0f7a6
@ -1,4 +1,3 @@
|
|||||||
import Hooks from 'wp-js-hooks';
|
|
||||||
import MailPoet from 'mailpoet';
|
import MailPoet from 'mailpoet';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
@ -7,7 +6,27 @@ import { Link } from 'react-router-dom';
|
|||||||
import Listing from 'listing/listing.jsx';
|
import Listing from 'listing/listing.jsx';
|
||||||
import { CronMixin, MailerMixin } from 'newsletters/listings/mixins.jsx';
|
import { CronMixin, MailerMixin } from 'newsletters/listings/mixins.jsx';
|
||||||
|
|
||||||
const SendingStatus = props => {
|
const columns = [
|
||||||
|
{
|
||||||
|
name: 'subscriber_id',
|
||||||
|
label: MailPoet.I18n.t('subscriber'),
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'status',
|
||||||
|
label: MailPoet.I18n.t('sendingStatus'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'failureReason',
|
||||||
|
label: MailPoet.I18n.t('failureReason'),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const messages = {
|
||||||
|
onNoItemsFound: () => MailPoet.I18n.t('noSendingTaskFound'),
|
||||||
|
};
|
||||||
|
|
||||||
|
const SendingStatus = (props) => {
|
||||||
const newsletterId = props.match.params.id;
|
const newsletterId = props.match.params.id;
|
||||||
const [newsletterSubject, setNewsletterSubject] = React.useState('');
|
const [newsletterSubject, setNewsletterSubject] = React.useState('');
|
||||||
|
|
||||||
@ -44,7 +63,7 @@ const SendingStatus = props => {
|
|||||||
endpoint="sending_task_subscribers"
|
endpoint="sending_task_subscribers"
|
||||||
base_url="sending-status/:id"
|
base_url="sending-status/:id"
|
||||||
onRenderItem={item => <div><ListingItem {...item} /></div>}
|
onRenderItem={item => <div><ListingItem {...item} /></div>}
|
||||||
getListingItemKey={item => item.taskId + '-' + item.subscriberId}
|
getListingItemKey={item => `${item.taskId}-${item.subscriberId}`}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
messages={messages}
|
messages={messages}
|
||||||
auto_refresh
|
auto_refresh
|
||||||
@ -77,8 +96,14 @@ StatsLink.propTypes = {
|
|||||||
newsletterId: PropTypes.string,
|
newsletterId: PropTypes.string,
|
||||||
newsletterSubject: PropTypes.string,
|
newsletterSubject: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
StatsLink.defaultProps = {
|
||||||
|
newsletterId: null,
|
||||||
|
newsletterSubject: null,
|
||||||
|
};
|
||||||
|
|
||||||
const ListingItem = ({error, failed, taskId, processed, email, subscriberId, lastName, firstName}) => {
|
const ListingItem = ({
|
||||||
|
error, failed, taskId, processed, email, subscriberId, lastName, firstName,
|
||||||
|
}) => {
|
||||||
const resend = () => {
|
const resend = () => {
|
||||||
MailPoet.Ajax.post({
|
MailPoet.Ajax.post({
|
||||||
api_version: window.mailpoet_api_version,
|
api_version: window.mailpoet_api_version,
|
||||||
@ -86,12 +111,12 @@ const ListingItem = ({error, failed, taskId, processed, email, subscriberId, las
|
|||||||
action: 'resend',
|
action: 'resend',
|
||||||
data: { taskId, subscriberId },
|
data: { taskId, subscriberId },
|
||||||
})
|
})
|
||||||
.done(res => window.mailpoet_listing.forceUpdate())
|
.done(() => window.mailpoet_listing.forceUpdate())
|
||||||
.fail((res) => MailPoet.Notice.error(
|
.fail(res => MailPoet.Notice.error(
|
||||||
res.errors.map(error => error.message),
|
res.errors.map(err => err.message),
|
||||||
{ scroll: true }
|
{ scroll: true }
|
||||||
));
|
));
|
||||||
}
|
};
|
||||||
|
|
||||||
const rowClasses = classNames(
|
const rowClasses = classNames(
|
||||||
'manage-column',
|
'manage-column',
|
||||||
@ -130,7 +155,7 @@ const ListingItem = ({error, failed, taskId, processed, email, subscriberId, las
|
|||||||
</a>
|
</a>
|
||||||
</strong>
|
</strong>
|
||||||
<p style={{ margin: 0 }}>
|
<p style={{ margin: 0 }}>
|
||||||
{ firstName + ' ' + lastName }
|
{ `${firstName} ${lastName}` }
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
<td className="column" data-colname={MailPoet.I18n.t('sendingStatus')}>
|
<td className="column" data-colname={MailPoet.I18n.t('sendingStatus')}>
|
||||||
@ -152,25 +177,8 @@ ListingItem.propTypes = {
|
|||||||
processed: PropTypes.string.isRequired,
|
processed: PropTypes.string.isRequired,
|
||||||
subscriberId: PropTypes.string.isRequired,
|
subscriberId: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
ListingItem.defaultProps = {
|
||||||
const columns = [
|
error: '',
|
||||||
{
|
|
||||||
name: 'subscriber_id',
|
|
||||||
label: MailPoet.I18n.t('subscriber'),
|
|
||||||
sortable: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'status',
|
|
||||||
label: MailPoet.I18n.t('sendingStatus'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'failureReason',
|
|
||||||
label: MailPoet.I18n.t('failureReason'),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const messages = {
|
|
||||||
onNoItemsFound: () => MailPoet.I18n.t('noSendingTaskFound')
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SendingStatus;
|
export default SendingStatus;
|
||||||
|
@ -5,7 +5,6 @@ namespace MailPoet\API\JSON\v1;
|
|||||||
use MailPoet\Listing;
|
use MailPoet\Listing;
|
||||||
use MailPoet\Cron\CronHelper;
|
use MailPoet\Cron\CronHelper;
|
||||||
use MailPoet\Models\Newsletter;
|
use MailPoet\Models\Newsletter;
|
||||||
use MailPoet\Models\SendingQueue;
|
|
||||||
use MailPoet\Models\ScheduledTask;
|
use MailPoet\Models\ScheduledTask;
|
||||||
use MailPoet\Config\AccessControl;
|
use MailPoet\Config\AccessControl;
|
||||||
use MailPoet\API\JSON\Error as APIError;
|
use MailPoet\API\JSON\Error as APIError;
|
||||||
@ -13,12 +12,13 @@ use MailPoet\Settings\SettingsController;
|
|||||||
use MailPoet\WP\Functions as WPFunctions;
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
use MailPoet\Models\ScheduledTaskSubscriber;
|
use MailPoet\Models\ScheduledTaskSubscriber;
|
||||||
use MailPoet\API\JSON\Endpoint as APIEndpoint;
|
use MailPoet\API\JSON\Endpoint as APIEndpoint;
|
||||||
|
use MailPoet\Models\SendingQueue as SendingQueueModel;
|
||||||
|
|
||||||
if (!defined('ABSPATH')) exit;
|
if (!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
class SendingTaskSubscribers extends APIEndpoint {
|
class SendingTaskSubscribers extends APIEndpoint {
|
||||||
public $permissions = [
|
public $permissions = [
|
||||||
'global' => AccessControl::PERMISSION_MANAGE_EMAILS
|
'global' => AccessControl::PERMISSION_MANAGE_EMAILS,
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var Listing\Handler */
|
/** @var Listing\Handler */
|
||||||
@ -42,12 +42,12 @@ class SendingTaskSubscribers extends APIEndpoint {
|
|||||||
|
|
||||||
function listing($data = []) {
|
function listing($data = []) {
|
||||||
$newsletter_id = !empty($data['params']['id']) ? (int)$data['params']['id'] : false;
|
$newsletter_id = !empty($data['params']['id']) ? (int)$data['params']['id'] : false;
|
||||||
$tasks_ids = SendingQueue::select('task_id')
|
$tasks_ids = SendingQueueModel::select('task_id')
|
||||||
->where('newsletter_id', $newsletter_id)
|
->where('newsletter_id', $newsletter_id)
|
||||||
->findArray();
|
->findArray();
|
||||||
if (empty($tasks_ids)) {
|
if (empty($tasks_ids)) {
|
||||||
return $this->errorResponse([
|
return $this->errorResponse([
|
||||||
APIError::NOT_FOUND => __('This newsletter is not being sent to any subcriber yet.', 'mailpoet')
|
APIError::NOT_FOUND => __('This newsletter is not being sent to any subcriber yet.', 'mailpoet'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$data['params']['task_ids'] = array_map(function($item) {
|
$data['params']['task_ids'] = array_map(function($item) {
|
||||||
@ -67,7 +67,7 @@ class SendingTaskSubscribers extends APIEndpoint {
|
|||||||
'mta_log' => $this->settings->get('mta_log'),
|
'mta_log' => $this->settings->get('mta_log'),
|
||||||
'mta_method' => $this->settings->get('mta.method'),
|
'mta_method' => $this->settings->get('mta.method'),
|
||||||
'cron_accessible' => CronHelper::isDaemonAccessible(),
|
'cron_accessible' => CronHelper::isDaemonAccessible(),
|
||||||
'current_time' => $this->wp->currentTime('mysql')
|
'current_time' => $this->wp->currentTime('mysql'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,10 +78,10 @@ class SendingTaskSubscribers extends APIEndpoint {
|
|||||||
->where('subscriber_id', $subscriber_id)
|
->where('subscriber_id', $subscriber_id)
|
||||||
->findOne();
|
->findOne();
|
||||||
$task = ScheduledTask::findOne($task_id);
|
$task = ScheduledTask::findOne($task_id);
|
||||||
$sending_queue = SendingQueue::where('task_id', $task_id)->findOne();
|
$sending_queue = SendingQueueModel::where('task_id', $task_id)->findOne();
|
||||||
if (!$task || !$task_subscriber || !$sending_queue || $task_subscriber->failed !== '1') {
|
if (!$task || !$task_subscriber || !$sending_queue || $task_subscriber->failed != 1) {
|
||||||
return $this->errorResponse([
|
return $this->errorResponse([
|
||||||
APIError::NOT_FOUND => __('Failed sending task not found!', 'mailpoet')
|
APIError::NOT_FOUND => __('Failed sending task not found!', 'mailpoet'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$newsletter = Newsletter::findOne($sending_queue->newsletter_id);
|
$newsletter = Newsletter::findOne($sending_queue->newsletter_id);
|
||||||
|
@ -44,6 +44,7 @@ if (!defined('ABSPATH')) exit;
|
|||||||
* @method $this rawJoin(string $table, string|array $constraint, string $table_alias, array $parameters = array())
|
* @method $this rawJoin(string $table, string|array $constraint, string $table_alias, array $parameters = array())
|
||||||
* @method $this innerJoin(string $table, string|array $constraint, string $table_alias=null)
|
* @method $this innerJoin(string $table, string|array $constraint, string $table_alias=null)
|
||||||
* @method $this join(string $table, string|array $constraint, string $table_alias=null)
|
* @method $this join(string $table, string|array $constraint, string $table_alias=null)
|
||||||
|
* @method static static join(string $table, string|array $constraint, string $table_alias=null)
|
||||||
* @method $this leftOuterJoin(string $table, string|array $constraint, string $table_alias=null)
|
* @method $this leftOuterJoin(string $table, string|array $constraint, string $table_alias=null)
|
||||||
* @method $this rightOuterJoin(string $table, string|array $constraint, string $table_alias=null)
|
* @method $this rightOuterJoin(string $table, string|array $constraint, string $table_alias=null)
|
||||||
* @method $this fullOuterJoin(string $table, string|array $constraint, string $table_alias=null)
|
* @method $this fullOuterJoin(string $table, string|array $constraint, string $table_alias=null)
|
||||||
|
@ -5,6 +5,13 @@ use MailPoet\WP\Functions as WPFunctions;
|
|||||||
|
|
||||||
if (!defined('ABSPATH')) exit;
|
if (!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $task_id
|
||||||
|
* @property int $subscriber_id
|
||||||
|
* @property int $processed
|
||||||
|
* @property int $failed
|
||||||
|
* @property string $error
|
||||||
|
*/
|
||||||
class ScheduledTaskSubscriber extends Model {
|
class ScheduledTaskSubscriber extends Model {
|
||||||
const STATUS_UNPROCESSED = 0;
|
const STATUS_UNPROCESSED = 0;
|
||||||
const STATUS_PROCESSED = 1;
|
const STATUS_PROCESSED = 1;
|
||||||
@ -70,7 +77,7 @@ class ScheduledTaskSubscriber extends Model {
|
|||||||
|
|
||||||
static function listingQuery($data) {
|
static function listingQuery($data) {
|
||||||
$group = isset($data['group']) ? $data['group'] : 'all';
|
$group = isset($data['group']) ? $data['group'] : 'all';
|
||||||
return self::join(Subscriber::$_table, array("subscriber_id", "=", "subscribers.id"), "subscribers")
|
return self::join(Subscriber::$_table, ["subscriber_id", "=", "subscribers.id"], "subscribers")
|
||||||
->filter($group, $data['params'])
|
->filter($group, $data['params'])
|
||||||
->select('error', 'error')
|
->select('error', 'error')
|
||||||
->select('failed', 'failed')
|
->select('failed', 'failed')
|
||||||
@ -92,17 +99,17 @@ class ScheduledTaskSubscriber extends Model {
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => self::SENDING_STATUS_SENT,
|
'name' => self::SENDING_STATUS_SENT,
|
||||||
'label' => WPFunctions::get()->x('Sent', 'status when a newsletter has been sent', 'mailpoet'),
|
'label' => WPFunctions::get()->_x('Sent', 'status when a newsletter has been sent', 'mailpoet'),
|
||||||
'count' => self::filter(self::SENDING_STATUS_SENT, $params)->count(),
|
'count' => self::filter(self::SENDING_STATUS_SENT, $params)->count(),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => self::SENDING_STATUS_FAILED,
|
'name' => self::SENDING_STATUS_FAILED,
|
||||||
'label' => WPFunctions::get()->x('Failed', 'status when the sending of a newsletter has failed', 'mailpoet'),
|
'label' => WPFunctions::get()->_x('Failed', 'status when the sending of a newsletter has failed', 'mailpoet'),
|
||||||
'count' => self::filter(self::SENDING_STATUS_FAILED, $params)->count(),
|
'count' => self::filter(self::SENDING_STATUS_FAILED, $params)->count(),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => self::SENDING_STATUS_UNPROCESSED,
|
'name' => self::SENDING_STATUS_UNPROCESSED,
|
||||||
'label' => WPFunctions::get()->x('Unprocessed', 'status when the sending of a newsletter has not been processed', 'mailpoet'),
|
'label' => WPFunctions::get()->_x('Unprocessed', 'status when the sending of a newsletter has not been processed', 'mailpoet'),
|
||||||
'count' => self::filter(self::SENDING_STATUS_UNPROCESSED, $params)->count(),
|
'count' => self::filter(self::SENDING_STATUS_UNPROCESSED, $params)->count(),
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user