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 PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
@ -7,7 +6,27 @@ import { Link } from 'react-router-dom';
|
||||
import Listing from 'listing/listing.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 [newsletterSubject, setNewsletterSubject] = React.useState('');
|
||||
|
||||
@ -44,7 +63,7 @@ const SendingStatus = props => {
|
||||
endpoint="sending_task_subscribers"
|
||||
base_url="sending-status/:id"
|
||||
onRenderItem={item => <div><ListingItem {...item} /></div>}
|
||||
getListingItemKey={item => item.taskId + '-' + item.subscriberId}
|
||||
getListingItemKey={item => `${item.taskId}-${item.subscriberId}`}
|
||||
columns={columns}
|
||||
messages={messages}
|
||||
auto_refresh
|
||||
@ -77,8 +96,14 @@ StatsLink.propTypes = {
|
||||
newsletterId: 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 = () => {
|
||||
MailPoet.Ajax.post({
|
||||
api_version: window.mailpoet_api_version,
|
||||
@ -86,12 +111,12 @@ const ListingItem = ({error, failed, taskId, processed, email, subscriberId, las
|
||||
action: 'resend',
|
||||
data: { taskId, subscriberId },
|
||||
})
|
||||
.done(res => window.mailpoet_listing.forceUpdate())
|
||||
.fail((res) => MailPoet.Notice.error(
|
||||
res.errors.map(error => error.message),
|
||||
.done(() => window.mailpoet_listing.forceUpdate())
|
||||
.fail(res => MailPoet.Notice.error(
|
||||
res.errors.map(err => err.message),
|
||||
{ scroll: true }
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
const rowClasses = classNames(
|
||||
'manage-column',
|
||||
@ -130,7 +155,7 @@ const ListingItem = ({error, failed, taskId, processed, email, subscriberId, las
|
||||
</a>
|
||||
</strong>
|
||||
<p style={{ margin: 0 }}>
|
||||
{ firstName + ' ' + lastName }
|
||||
{ `${firstName} ${lastName}` }
|
||||
</p>
|
||||
</td>
|
||||
<td className="column" data-colname={MailPoet.I18n.t('sendingStatus')}>
|
||||
@ -152,25 +177,8 @@ ListingItem.propTypes = {
|
||||
processed: PropTypes.string.isRequired,
|
||||
subscriberId: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
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')
|
||||
ListingItem.defaultProps = {
|
||||
error: '',
|
||||
};
|
||||
|
||||
export default SendingStatus;
|
||||
|
@ -5,7 +5,6 @@ namespace MailPoet\API\JSON\v1;
|
||||
use MailPoet\Listing;
|
||||
use MailPoet\Cron\CronHelper;
|
||||
use MailPoet\Models\Newsletter;
|
||||
use MailPoet\Models\SendingQueue;
|
||||
use MailPoet\Models\ScheduledTask;
|
||||
use MailPoet\Config\AccessControl;
|
||||
use MailPoet\API\JSON\Error as APIError;
|
||||
@ -13,12 +12,13 @@ use MailPoet\Settings\SettingsController;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
use MailPoet\Models\ScheduledTaskSubscriber;
|
||||
use MailPoet\API\JSON\Endpoint as APIEndpoint;
|
||||
use MailPoet\Models\SendingQueue as SendingQueueModel;
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class SendingTaskSubscribers extends APIEndpoint {
|
||||
public $permissions = [
|
||||
'global' => AccessControl::PERMISSION_MANAGE_EMAILS
|
||||
'global' => AccessControl::PERMISSION_MANAGE_EMAILS,
|
||||
];
|
||||
|
||||
/** @var Listing\Handler */
|
||||
@ -42,12 +42,12 @@ class SendingTaskSubscribers extends APIEndpoint {
|
||||
|
||||
function listing($data = []) {
|
||||
$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)
|
||||
->findArray();
|
||||
if (empty($tasks_ids)) {
|
||||
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) {
|
||||
@ -67,7 +67,7 @@ class SendingTaskSubscribers extends APIEndpoint {
|
||||
'mta_log' => $this->settings->get('mta_log'),
|
||||
'mta_method' => $this->settings->get('mta.method'),
|
||||
'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)
|
||||
->findOne();
|
||||
$task = ScheduledTask::findOne($task_id);
|
||||
$sending_queue = SendingQueue::where('task_id', $task_id)->findOne();
|
||||
if (!$task || !$task_subscriber || !$sending_queue || $task_subscriber->failed !== '1') {
|
||||
$sending_queue = SendingQueueModel::where('task_id', $task_id)->findOne();
|
||||
if (!$task || !$task_subscriber || !$sending_queue || $task_subscriber->failed != 1) {
|
||||
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);
|
||||
|
@ -44,6 +44,7 @@ if (!defined('ABSPATH')) exit;
|
||||
* @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 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 rightOuterJoin(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;
|
||||
|
||||
/**
|
||||
* @property int $task_id
|
||||
* @property int $subscriber_id
|
||||
* @property int $processed
|
||||
* @property int $failed
|
||||
* @property string $error
|
||||
*/
|
||||
class ScheduledTaskSubscriber extends Model {
|
||||
const STATUS_UNPROCESSED = 0;
|
||||
const STATUS_PROCESSED = 1;
|
||||
@ -70,7 +77,7 @@ class ScheduledTaskSubscriber extends Model {
|
||||
|
||||
static function listingQuery($data) {
|
||||
$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'])
|
||||
->select('error', 'error')
|
||||
->select('failed', 'failed')
|
||||
@ -92,17 +99,17 @@ class ScheduledTaskSubscriber extends Model {
|
||||
],
|
||||
[
|
||||
'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(),
|
||||
],
|
||||
[
|
||||
'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(),
|
||||
],
|
||||
[
|
||||
'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(),
|
||||
],
|
||||
];
|
||||
|
Reference in New Issue
Block a user