From 4211e02d6ad4fdb9bc8a58d0f8266c267ce33bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Mon, 17 Jun 2024 15:33:44 +0200 Subject: [PATCH] Show list of cancelled sending tasks [MAILPOET-5755] --- mailpoet/assets/js/src/help/queue-status.jsx | 6 ++++++ .../src/help/tasks-list/tasks-list-data-row.jsx | 17 ++++++++++++++++- .../help/tasks-list/tasks-list-labels-row.jsx | 13 +++++++++++-- .../js/src/help/tasks-list/tasks-list.jsx | 15 ++++++++++++--- mailpoet/lib/AdminPages/Pages/Help.php | 3 +++ .../Sending/ScheduledTasksRepository.php | 1 + mailpoet/views/help.html | 2 ++ 7 files changed, 51 insertions(+), 6 deletions(-) diff --git a/mailpoet/assets/js/src/help/queue-status.jsx b/mailpoet/assets/js/src/help/queue-status.jsx index 7dcff36de8..bc5727bc56 100644 --- a/mailpoet/assets/js/src/help/queue-status.jsx +++ b/mailpoet/assets/js/src/help/queue-status.jsx @@ -69,6 +69,12 @@ function QueueStatus(props) { tasks={status.latestTasks.filter((task) => task.status === 'scheduled')} /> +
{MailPoet.I18n.t('cancelledTasks')}
+ task.status === 'cancelled')} + /> +
{MailPoet.I18n.t('runningTasks')}
task.status === null)} diff --git a/mailpoet/assets/js/src/help/tasks-list/tasks-list-data-row.jsx b/mailpoet/assets/js/src/help/tasks-list/tasks-list-data-row.jsx index c3b155d275..3a9668aa10 100644 --- a/mailpoet/assets/js/src/help/tasks-list/tasks-list-data-row.jsx +++ b/mailpoet/assets/js/src/help/tasks-list/tasks-list-data-row.jsx @@ -4,10 +4,15 @@ import parseDate from 'date-fns/parse'; function TasksListDataRow(props) { let scheduled = props.task.scheduled_at; - if (scheduled) { + if (props.show_scheduled_at) { 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( props.task.updated_at, 'yyyy-MM-dd HH:mm:ss', @@ -51,6 +56,13 @@ function TasksListDataRow(props) { )}`} ) : null} + {props.show_cancelled_at ? ( + + {`${MailPoet.Date.short(cancelled)} ${MailPoet.Date.time( + cancelled, + )}`} + + ) : null} {`${MailPoet.Date.short(updated)} ${MailPoet.Date.time( updated, @@ -62,12 +74,14 @@ function TasksListDataRow(props) { TasksListDataRow.propTypes = { show_scheduled_at: PropTypes.bool, + show_cancelled_at: PropTypes.bool, task: PropTypes.shape({ id: PropTypes.number.isRequired, type: PropTypes.string.isRequired, priority: PropTypes.number.isRequired, updated_at: PropTypes.string.isRequired, scheduled_at: PropTypes.string, + cancelled_at: PropTypes.string, status: PropTypes.string, newsletter: PropTypes.shape({ newsletter_id: PropTypes.number.isRequired, @@ -81,6 +95,7 @@ TasksListDataRow.propTypes = { TasksListDataRow.defaultProps = { show_scheduled_at: false, + show_cancelled_at: false, }; export { TasksListDataRow }; diff --git a/mailpoet/assets/js/src/help/tasks-list/tasks-list-labels-row.jsx b/mailpoet/assets/js/src/help/tasks-list/tasks-list-labels-row.jsx index d6e3d4697e..b8c1d468d7 100644 --- a/mailpoet/assets/js/src/help/tasks-list/tasks-list-labels-row.jsx +++ b/mailpoet/assets/js/src/help/tasks-list/tasks-list-labels-row.jsx @@ -1,16 +1,19 @@ import PropTypes from 'prop-types'; import { MailPoet } from 'mailpoet'; -function TasksListLabelsRow({ show_scheduled_at: showScheduledAt = false }) { +function TasksListLabelsRow(props) { return ( Id {MailPoet.I18n.t('email')} {MailPoet.I18n.t('subscriber')} {MailPoet.I18n.t('priority')} - {showScheduledAt ? ( + {props.show_scheduled_at ? ( {MailPoet.I18n.t('scheduledAt')} ) : null} + {props.show_cancelled_at ? ( + {MailPoet.I18n.t('cancelledAt')} + ) : null} {MailPoet.I18n.t('updatedAt')} ); @@ -18,6 +21,12 @@ function TasksListLabelsRow({ show_scheduled_at: showScheduledAt = false }) { TasksListLabelsRow.propTypes = { show_scheduled_at: PropTypes.bool, + show_cancelled_at: PropTypes.bool, +}; + +TasksListLabelsRow.defaultProps = { + show_scheduled_at: false, + show_cancelled_at: false, }; export { TasksListLabelsRow }; diff --git a/mailpoet/assets/js/src/help/tasks-list/tasks-list.jsx b/mailpoet/assets/js/src/help/tasks-list/tasks-list.jsx index 3f70d9ef84..6fcb8c1658 100644 --- a/mailpoet/assets/js/src/help/tasks-list/tasks-list.jsx +++ b/mailpoet/assets/js/src/help/tasks-list/tasks-list.jsx @@ -4,12 +4,15 @@ import { TasksListDataRow } from './tasks-list-data-row.jsx'; import { TasksListLabelsRow } from './tasks-list-labels-row.jsx'; function TasksList(props) { - const colsCount = props.show_scheduled_at ? 6 : 5; + const colsCount = props.show_scheduled_at || props.show_cancelled_at ? 6 : 5; return ( - + {props.tasks.length ? ( @@ -18,6 +21,7 @@ function TasksList(props) { key={task.id} task={task} show_scheduled_at={props.show_scheduled_at} + show_cancelled_at={props.show_cancelled_at} /> )) ) : ( @@ -27,7 +31,10 @@ function TasksList(props) { )} - +
); @@ -35,11 +42,13 @@ function TasksList(props) { TasksList.propTypes = { show_scheduled_at: PropTypes.bool, + show_cancelled_at: PropTypes.bool, tasks: PropTypes.arrayOf(TasksListDataRow.propTypes.task).isRequired, }; TasksList.defaultProps = { show_scheduled_at: false, + show_cancelled_at: false, }; export { TasksList }; diff --git a/mailpoet/lib/AdminPages/Pages/Help.php b/mailpoet/lib/AdminPages/Pages/Help.php index 0133a04912..273889858c 100644 --- a/mailpoet/lib/AdminPages/Pages/Help.php +++ b/mailpoet/lib/AdminPages/Pages/Help.php @@ -153,6 +153,9 @@ class Help { 'scheduled_at' => $task->getScheduledAt() ? $task->getScheduledAt()->format(DateTime::DEFAULT_DATE_TIME_FORMAT) : null, + 'cancelled_at' => $task->getCancelledAt() ? + $task->getCancelledAt()->format(DateTime::DEFAULT_DATE_TIME_FORMAT) + : null, 'status' => $task->getStatus(), 'newsletter' => $queue && $newsletter ? [ 'newsletter_id' => $newsletter->getId(), diff --git a/mailpoet/lib/Newsletter/Sending/ScheduledTasksRepository.php b/mailpoet/lib/Newsletter/Sending/ScheduledTasksRepository.php index 4d3c3f6a92..04d3422d19 100644 --- a/mailpoet/lib/Newsletter/Sending/ScheduledTasksRepository.php +++ b/mailpoet/lib/Newsletter/Sending/ScheduledTasksRepository.php @@ -226,6 +226,7 @@ class ScheduledTasksRepository extends Repository { $type = null, $statuses = [ ScheduledTaskEntity::STATUS_COMPLETED, + ScheduledTaskEntity::STATUS_CANCELLED, ScheduledTaskEntity::STATUS_SCHEDULED, ScheduledTaskEntity::VIRTUAL_STATUS_RUNNING, ], diff --git a/mailpoet/views/help.html b/mailpoet/views/help.html index ae2802be31..26941d88b1 100644 --- a/mailpoet/views/help.html +++ b/mailpoet/views/help.html @@ -63,12 +63,14 @@ 'scheduledTasks': __('Scheduled sending tasks'), 'runningTasks': __('Running sending tasks'), 'completedTasks': __('Completed sending tasks'), + 'cancelledTasks': __('Cancelled sending tasks'), 'type': _x('Type', 'Table column heading for task type.'), 'email': __('Email'), 'subscriber': __('Subscriber'), '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).' ), 'scheduledAt': __('Scheduled At'), + 'cancelledAt': __('Cancelled At'), 'updatedAt': __('Updated At'), 'nothingToShow': __('Nothing to show.'), 'preview': _x('Preview', 'Text of a link to email preview page.'),