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')}
|
||||
/>
|
||||
|
||||
<h5>{MailPoet.I18n.t('cancelledTasks')}</h5>
|
||||
<TasksList
|
||||
show_cancelled_at
|
||||
tasks={status.latestTasks.filter((task) => task.status === 'cancelled')}
|
||||
/>
|
||||
|
||||
<h5>{MailPoet.I18n.t('runningTasks')}</h5>
|
||||
<TasksList
|
||||
tasks={status.latestTasks.filter((task) => task.status === null)}
|
||||
|
@ -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) {
|
||||
)}`}</abbr>
|
||||
</td>
|
||||
) : 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">
|
||||
<abbr>{`${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 };
|
||||
|
@ -1,16 +1,19 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import { MailPoet } from 'mailpoet';
|
||||
|
||||
function TasksListLabelsRow({ show_scheduled_at: showScheduledAt = false }) {
|
||||
function TasksListLabelsRow(props) {
|
||||
return (
|
||||
<tr>
|
||||
<th className="row-title">Id</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('priority')}</th>
|
||||
{showScheduledAt ? (
|
||||
{props.show_scheduled_at ? (
|
||||
<th className="row-title">{MailPoet.I18n.t('scheduledAt')}</th>
|
||||
) : null}
|
||||
{props.show_cancelled_at ? (
|
||||
<th className="row-title">{MailPoet.I18n.t('cancelledAt')}</th>
|
||||
) : null}
|
||||
<th className="row-title">{MailPoet.I18n.t('updatedAt')}</th>
|
||||
</tr>
|
||||
);
|
||||
@ -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 };
|
||||
|
@ -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 (
|
||||
<table className="widefat fixed striped">
|
||||
<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>
|
||||
<tbody>
|
||||
{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) {
|
||||
)}
|
||||
</tbody>
|
||||
<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>
|
||||
</table>
|
||||
);
|
||||
@ -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 };
|
||||
|
@ -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(),
|
||||
|
@ -226,6 +226,7 @@ class ScheduledTasksRepository extends Repository {
|
||||
$type = null,
|
||||
$statuses = [
|
||||
ScheduledTaskEntity::STATUS_COMPLETED,
|
||||
ScheduledTaskEntity::STATUS_CANCELLED,
|
||||
ScheduledTaskEntity::STATUS_SCHEDULED,
|
||||
ScheduledTaskEntity::VIRTUAL_STATUS_RUNNING,
|
||||
],
|
||||
|
@ -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.'),
|
||||
|
Reference in New Issue
Block a user