Show list of cancelled sending tasks
[MAILPOET-5755]
This commit is contained in:
committed by
Ján Mikláš
parent
1918d30fcd
commit
4211e02d6a
@ -69,6 +69,12 @@ function QueueStatus(props) {
|
|||||||
tasks={status.latestTasks.filter((task) => task.status === 'scheduled')}
|
tasks={status.latestTasks.filter((task) => task.status === 'scheduled')}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<h5>{MailPoet.I18n.t('cancelledTasks')}</h5>
|
||||||
|
<TasksList
|
||||||
|
show_cancelled_at
|
||||||
|
tasks={status.latestTasks.filter((task) => task.status === 'cancelled')}
|
||||||
|
/>
|
||||||
|
|
||||||
<h5>{MailPoet.I18n.t('runningTasks')}</h5>
|
<h5>{MailPoet.I18n.t('runningTasks')}</h5>
|
||||||
<TasksList
|
<TasksList
|
||||||
tasks={status.latestTasks.filter((task) => task.status === null)}
|
tasks={status.latestTasks.filter((task) => task.status === null)}
|
||||||
|
@ -4,10 +4,15 @@ import parseDate from 'date-fns/parse';
|
|||||||
|
|
||||||
function TasksListDataRow(props) {
|
function TasksListDataRow(props) {
|
||||||
let scheduled = props.task.scheduled_at;
|
let scheduled = props.task.scheduled_at;
|
||||||
if (scheduled) {
|
if (props.show_scheduled_at) {
|
||||||
scheduled = parseDate(scheduled, 'yyyy-MM-dd HH:mm:ss', new Date());
|
scheduled = parseDate(scheduled, 'yyyy-MM-dd HH:mm:ss', new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let cancelled = props.task.cancelled_at;
|
||||||
|
if (props.show_cancelled_at) {
|
||||||
|
cancelled = parseDate(cancelled, 'yyyy-MM-dd HH:mm:ss', new Date());
|
||||||
|
}
|
||||||
|
|
||||||
const updated = parseDate(
|
const updated = parseDate(
|
||||||
props.task.updated_at,
|
props.task.updated_at,
|
||||||
'yyyy-MM-dd HH:mm:ss',
|
'yyyy-MM-dd HH:mm:ss',
|
||||||
@ -51,6 +56,13 @@ function TasksListDataRow(props) {
|
|||||||
)}`}</abbr>
|
)}`}</abbr>
|
||||||
</td>
|
</td>
|
||||||
) : null}
|
) : null}
|
||||||
|
{props.show_cancelled_at ? (
|
||||||
|
<td className="column-date">
|
||||||
|
<abbr>{`${MailPoet.Date.short(cancelled)} ${MailPoet.Date.time(
|
||||||
|
cancelled,
|
||||||
|
)}`}</abbr>
|
||||||
|
</td>
|
||||||
|
) : null}
|
||||||
<td className="column-date">
|
<td className="column-date">
|
||||||
<abbr>{`${MailPoet.Date.short(updated)} ${MailPoet.Date.time(
|
<abbr>{`${MailPoet.Date.short(updated)} ${MailPoet.Date.time(
|
||||||
updated,
|
updated,
|
||||||
@ -62,12 +74,14 @@ function TasksListDataRow(props) {
|
|||||||
|
|
||||||
TasksListDataRow.propTypes = {
|
TasksListDataRow.propTypes = {
|
||||||
show_scheduled_at: PropTypes.bool,
|
show_scheduled_at: PropTypes.bool,
|
||||||
|
show_cancelled_at: PropTypes.bool,
|
||||||
task: PropTypes.shape({
|
task: PropTypes.shape({
|
||||||
id: PropTypes.number.isRequired,
|
id: PropTypes.number.isRequired,
|
||||||
type: PropTypes.string.isRequired,
|
type: PropTypes.string.isRequired,
|
||||||
priority: PropTypes.number.isRequired,
|
priority: PropTypes.number.isRequired,
|
||||||
updated_at: PropTypes.string.isRequired,
|
updated_at: PropTypes.string.isRequired,
|
||||||
scheduled_at: PropTypes.string,
|
scheduled_at: PropTypes.string,
|
||||||
|
cancelled_at: PropTypes.string,
|
||||||
status: PropTypes.string,
|
status: PropTypes.string,
|
||||||
newsletter: PropTypes.shape({
|
newsletter: PropTypes.shape({
|
||||||
newsletter_id: PropTypes.number.isRequired,
|
newsletter_id: PropTypes.number.isRequired,
|
||||||
@ -81,6 +95,7 @@ TasksListDataRow.propTypes = {
|
|||||||
|
|
||||||
TasksListDataRow.defaultProps = {
|
TasksListDataRow.defaultProps = {
|
||||||
show_scheduled_at: false,
|
show_scheduled_at: false,
|
||||||
|
show_cancelled_at: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export { TasksListDataRow };
|
export { TasksListDataRow };
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { MailPoet } from 'mailpoet';
|
import { MailPoet } from 'mailpoet';
|
||||||
|
|
||||||
function TasksListLabelsRow({ show_scheduled_at: showScheduledAt = false }) {
|
function TasksListLabelsRow(props) {
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
<th className="row-title">Id</th>
|
<th className="row-title">Id</th>
|
||||||
<th className="row-title">{MailPoet.I18n.t('email')}</th>
|
<th className="row-title">{MailPoet.I18n.t('email')}</th>
|
||||||
<th className="row-title">{MailPoet.I18n.t('subscriber')}</th>
|
<th className="row-title">{MailPoet.I18n.t('subscriber')}</th>
|
||||||
<th className="row-title">{MailPoet.I18n.t('priority')}</th>
|
<th className="row-title">{MailPoet.I18n.t('priority')}</th>
|
||||||
{showScheduledAt ? (
|
{props.show_scheduled_at ? (
|
||||||
<th className="row-title">{MailPoet.I18n.t('scheduledAt')}</th>
|
<th className="row-title">{MailPoet.I18n.t('scheduledAt')}</th>
|
||||||
) : null}
|
) : null}
|
||||||
|
{props.show_cancelled_at ? (
|
||||||
|
<th className="row-title">{MailPoet.I18n.t('cancelledAt')}</th>
|
||||||
|
) : null}
|
||||||
<th className="row-title">{MailPoet.I18n.t('updatedAt')}</th>
|
<th className="row-title">{MailPoet.I18n.t('updatedAt')}</th>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
@ -18,6 +21,12 @@ function TasksListLabelsRow({ show_scheduled_at: showScheduledAt = false }) {
|
|||||||
|
|
||||||
TasksListLabelsRow.propTypes = {
|
TasksListLabelsRow.propTypes = {
|
||||||
show_scheduled_at: PropTypes.bool,
|
show_scheduled_at: PropTypes.bool,
|
||||||
|
show_cancelled_at: PropTypes.bool,
|
||||||
|
};
|
||||||
|
|
||||||
|
TasksListLabelsRow.defaultProps = {
|
||||||
|
show_scheduled_at: false,
|
||||||
|
show_cancelled_at: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export { TasksListLabelsRow };
|
export { TasksListLabelsRow };
|
||||||
|
@ -4,12 +4,15 @@ import { TasksListDataRow } from './tasks-list-data-row.jsx';
|
|||||||
import { TasksListLabelsRow } from './tasks-list-labels-row.jsx';
|
import { TasksListLabelsRow } from './tasks-list-labels-row.jsx';
|
||||||
|
|
||||||
function TasksList(props) {
|
function TasksList(props) {
|
||||||
const colsCount = props.show_scheduled_at ? 6 : 5;
|
const colsCount = props.show_scheduled_at || props.show_cancelled_at ? 6 : 5;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<table className="widefat fixed striped">
|
<table className="widefat fixed striped">
|
||||||
<thead>
|
<thead>
|
||||||
<TasksListLabelsRow show_scheduled_at={props.show_scheduled_at} />
|
<TasksListLabelsRow
|
||||||
|
show_scheduled_at={props.show_scheduled_at}
|
||||||
|
show_cancelled_at={props.show_cancelled_at}
|
||||||
|
/>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{props.tasks.length ? (
|
{props.tasks.length ? (
|
||||||
@ -18,6 +21,7 @@ function TasksList(props) {
|
|||||||
key={task.id}
|
key={task.id}
|
||||||
task={task}
|
task={task}
|
||||||
show_scheduled_at={props.show_scheduled_at}
|
show_scheduled_at={props.show_scheduled_at}
|
||||||
|
show_cancelled_at={props.show_cancelled_at}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
@ -27,7 +31,10 @@ function TasksList(props) {
|
|||||||
)}
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<TasksListLabelsRow show_scheduled_at={props.show_scheduled_at} />
|
<TasksListLabelsRow
|
||||||
|
show_scheduled_at={props.show_scheduled_at}
|
||||||
|
show_cancelled_at={props.show_cancelled_at}
|
||||||
|
/>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
);
|
);
|
||||||
@ -35,11 +42,13 @@ function TasksList(props) {
|
|||||||
|
|
||||||
TasksList.propTypes = {
|
TasksList.propTypes = {
|
||||||
show_scheduled_at: PropTypes.bool,
|
show_scheduled_at: PropTypes.bool,
|
||||||
|
show_cancelled_at: PropTypes.bool,
|
||||||
tasks: PropTypes.arrayOf(TasksListDataRow.propTypes.task).isRequired,
|
tasks: PropTypes.arrayOf(TasksListDataRow.propTypes.task).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
TasksList.defaultProps = {
|
TasksList.defaultProps = {
|
||||||
show_scheduled_at: false,
|
show_scheduled_at: false,
|
||||||
|
show_cancelled_at: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export { TasksList };
|
export { TasksList };
|
||||||
|
@ -153,6 +153,9 @@ class Help {
|
|||||||
'scheduled_at' => $task->getScheduledAt() ?
|
'scheduled_at' => $task->getScheduledAt() ?
|
||||||
$task->getScheduledAt()->format(DateTime::DEFAULT_DATE_TIME_FORMAT)
|
$task->getScheduledAt()->format(DateTime::DEFAULT_DATE_TIME_FORMAT)
|
||||||
: null,
|
: null,
|
||||||
|
'cancelled_at' => $task->getCancelledAt() ?
|
||||||
|
$task->getCancelledAt()->format(DateTime::DEFAULT_DATE_TIME_FORMAT)
|
||||||
|
: null,
|
||||||
'status' => $task->getStatus(),
|
'status' => $task->getStatus(),
|
||||||
'newsletter' => $queue && $newsletter ? [
|
'newsletter' => $queue && $newsletter ? [
|
||||||
'newsletter_id' => $newsletter->getId(),
|
'newsletter_id' => $newsletter->getId(),
|
||||||
|
@ -226,6 +226,7 @@ class ScheduledTasksRepository extends Repository {
|
|||||||
$type = null,
|
$type = null,
|
||||||
$statuses = [
|
$statuses = [
|
||||||
ScheduledTaskEntity::STATUS_COMPLETED,
|
ScheduledTaskEntity::STATUS_COMPLETED,
|
||||||
|
ScheduledTaskEntity::STATUS_CANCELLED,
|
||||||
ScheduledTaskEntity::STATUS_SCHEDULED,
|
ScheduledTaskEntity::STATUS_SCHEDULED,
|
||||||
ScheduledTaskEntity::VIRTUAL_STATUS_RUNNING,
|
ScheduledTaskEntity::VIRTUAL_STATUS_RUNNING,
|
||||||
],
|
],
|
||||||
|
@ -63,12 +63,14 @@
|
|||||||
'scheduledTasks': __('Scheduled sending tasks'),
|
'scheduledTasks': __('Scheduled sending tasks'),
|
||||||
'runningTasks': __('Running sending tasks'),
|
'runningTasks': __('Running sending tasks'),
|
||||||
'completedTasks': __('Completed sending tasks'),
|
'completedTasks': __('Completed sending tasks'),
|
||||||
|
'cancelledTasks': __('Cancelled sending tasks'),
|
||||||
'type': _x('Type', 'Table column heading for task type.'),
|
'type': _x('Type', 'Table column heading for task type.'),
|
||||||
'email': __('Email'),
|
'email': __('Email'),
|
||||||
'subscriber': __('Subscriber'),
|
'subscriber': __('Subscriber'),
|
||||||
'multipleSubscribers': _x('Multiple subscribers', 'Used when multiple subscribers are selected for a task and we don\'t list them all.'),
|
'multipleSubscribers': _x('Multiple subscribers', 'Used when multiple subscribers are selected for a task and we don\'t list them all.'),
|
||||||
'priority': _x('Priority', 'Table column heading for task priority (number).' ),
|
'priority': _x('Priority', 'Table column heading for task priority (number).' ),
|
||||||
'scheduledAt': __('Scheduled At'),
|
'scheduledAt': __('Scheduled At'),
|
||||||
|
'cancelledAt': __('Cancelled At'),
|
||||||
'updatedAt': __('Updated At'),
|
'updatedAt': __('Updated At'),
|
||||||
'nothingToShow': __('Nothing to show.'),
|
'nothingToShow': __('Nothing to show.'),
|
||||||
'preview': _x('Preview', 'Text of a link to email preview page.'),
|
'preview': _x('Preview', 'Text of a link to email preview page.'),
|
||||||
|
Reference in New Issue
Block a user