Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.2] Show a warning when there are due tasks #3212

Closed
jgerman-bot opened this issue Jul 3, 2024 · 0 comments · Fixed by #3214
Closed

[5.2] Show a warning when there are due tasks #3212

jgerman-bot opened this issue Jul 3, 2024 · 0 comments · Fixed by #3214

Comments

@jgerman-bot
Copy link

New language relevant PR in upstream repo: joomla/joomla-cms#43491 Here are the upstream changes:

Click to expand the diff!
diff --git a/administrator/components/com_scheduler/forms/filter_tasks.xml b/administrator/components/com_scheduler/forms/filter_tasks.xml
index 78ad2ca21dca5..ce99fa07909d2 100644
--- a/administrator/components/com_scheduler/forms/filter_tasks.xml
+++ b/administrator/components/com_scheduler/forms/filter_tasks.xml
@@ -45,7 +45,7 @@
 			type="list"
 			label="JGLOBAL_SORT_BY"
 			class="js-select-submit-on-change"
-			default="a.title ASC"
+			default="a.next_execution ASC"
 			validate="options"
 			>
 			<option value="">JGLOBAL_SORT_BY</option>
@@ -59,6 +59,8 @@
 			<option value="j.type_title DESC">COM_SCHEDULER_TASK_TYPE_DESC</option>
 			<option value="a.last_execution ASC">COM_SCHEDULER_LAST_RUN_ASC</option>
 			<option value="a.last_execution DESC">COM_SCHEDULER_LAST_RUN_DESC</option>
+			<option value="a.next_execution ASC">COM_SCHEDULER_NEXT_RUN_ASC</option>
+			<option value="a.next_execution DESC">COM_SCHEDULER_NEXT_RUN_DESC</option>
 			<option value="a.priority ASC">COM_SCHEDULER_TASK_PRIORITY_ASC</option>
 			<option value="a.priority DESC">COM_SCHEDULER_TASK_PRIORITY_DESC</option>
 			<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
diff --git a/administrator/components/com_scheduler/src/Model/TasksModel.php b/administrator/components/com_scheduler/src/Model/TasksModel.php
index 15d41bb5764ab..ec1bbabe3dcf4 100644
--- a/administrator/components/com_scheduler/src/Model/TasksModel.php
+++ b/administrator/components/com_scheduler/src/Model/TasksModel.php
@@ -328,7 +328,7 @@ static function (TaskOption $taskOption): string {
         $multiOrdering = $this->state->get('list.multi_ordering');
 
         if (!$multiOrdering || !\is_array($multiOrdering)) {
-            $orderCol = $this->state->get('list.ordering', 'a.title');
+            $orderCol = $this->state->get('list.ordering', 'a.next_execution');
             $orderDir = $this->state->get('list.direction', 'asc');
 
             // Type title ordering is handled exceptionally in _getList()
@@ -365,7 +365,7 @@ static function (TaskOption $taskOption): string {
     protected function _getList($query, $limitstart = 0, $limit = 0): array
     {
         // Get stuff from the model state
-        $listOrder      = $this->getState('list.ordering', 'a.title');
+        $listOrder      = $this->getState('list.ordering', 'a.next_execution');
         $listDirectionN = strtolower($this->getState('list.direction', 'asc')) === 'desc' ? -1 : 1;
 
         // Set limit parameters and get object list
@@ -432,7 +432,7 @@ private function attachTaskOptions(array $items): void
      * @return void
      * @since  4.1.0
      */
-    protected function populateState($ordering = 'a.title', $direction = 'ASC'): void
+    protected function populateState($ordering = 'a.next_execution', $direction = 'ASC'): void
     {
         // Call the parent method
         parent::populateState($ordering, $direction);
@@ -467,4 +467,15 @@ public function hasDueTasks(Date $time): bool
         // False if we don't have due tasks, or we have locked tasks
         return $taskDetails && $taskDetails->due_count && !$taskDetails->locked_count;
     }
+
+    /**
+     * Check if we have right now any enabled due tasks and no locked tasks.
+     *
+     * @return boolean
+     * @since  __DEPLOY_VERSION__
+     */
+    public function getHasDueTasks()
+    {
+        return $this->hasDueTasks(Factory::getDate('now', 'UTC'));
+    }
 }
diff --git a/administrator/components/com_scheduler/src/View/Tasks/HtmlView.php b/administrator/components/com_scheduler/src/View/Tasks/HtmlView.php
index 0934d91923a5f..828f486e46c61 100644
--- a/administrator/components/com_scheduler/src/View/Tasks/HtmlView.php
+++ b/administrator/components/com_scheduler/src/View/Tasks/HtmlView.php
@@ -97,6 +97,7 @@ public function display($tpl = null): void
         $this->state         = $this->get('State');
         $this->filterForm    = $this->get('FilterForm');
         $this->activeFilters = $this->get('ActiveFilters');
+        $this->hasDueTasks   = $this->get('hasDueTasks');
 
         if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
             $this->setLayout('empty_state');
diff --git a/administrator/components/com_scheduler/tmpl/tasks/default.php b/administrator/components/com_scheduler/tmpl/tasks/default.php
index 93d538ff17dfc..60ef2e27c9295 100644
--- a/administrator/components/com_scheduler/tmpl/tasks/default.php
+++ b/administrator/components/com_scheduler/tmpl/tasks/default.php
@@ -63,6 +63,12 @@
     $saveOrderingUrl = 'index.php?option=com_scheduler&task=tasks.saveOrderAjax&tmpl=component&' . Session::getFormToken() . '=1';
     HTMLHelper::_('draggablelist.draggable');
 }
+
+// When there are due Tasks show that information to the user
+if ($this->hasDueTasks === true) {
+    $app->enqueueMessage(Text::_('COM_SCHEDULER_MSG_DUETASKS'), 'warning');
+}
+
 ?>
 
 <form action="<?php echo Route::_('index.php?option=com_scheduler&view=tasks'); ?>" method="post" name="adminForm"
@@ -129,6 +135,11 @@ class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
                         <?php echo HTMLHelper::_('searchtools.sort', 'COM_SCHEDULER_LAST_RUN_DATE', 'a.last_execution', $listDirn, $listOrder) ?>
                     </th>
 
+                    <!-- Next runs -->
+                    <th scope="col" class="d-none d-lg-table-cell">
+                        <?php echo HTMLHelper::_('searchtools.sort', 'COM_SCHEDULER_NEXT_RUN_DATE', 'a.next_execution', $listDirn, $listOrder) ?>
+                    </th>
+
                     <!-- Test task -->
                     <th scope="col" class="d-none d-md-table-cell">
                         <?php echo Text::_('COM_SCHEDULER_TEST_TASK'); ?>
@@ -239,6 +250,11 @@ class="js-draggable" data-url="<?php echo $saveOrderingUrl; ?>" data-direction="
                             <?php echo $item->last_execution ? HTMLHelper::_('date', $item->last_execution, 'DATE_FORMAT_LC5') : '-'; ?>
                         </td>
 
+                        <!-- Next run date -->
+                        <td class="small d-none d-lg-table-cell">
+                            <?php echo $item->next_execution ? HTMLHelper::_('date', $item->next_execution, 'DATE_FORMAT_LC5') : Text::_('COM_SCHEDULER_NEXT_RUN_MANUAL'); ?>
+                        </td>
+
                         <!-- Test task -->
                         <td class="small d-none d-md-table-cell">
                             <button type="button" class="btn btn-sm btn-warning" <?php echo $item->state < 0 ? 'disabled' : ''; ?>
diff --git a/administrator/language/en-GB/com_scheduler.ini b/administrator/language/en-GB/com_scheduler.ini
index 4bbc9f5ef82f4..f5eee988a7c2c 100644
--- a/administrator/language/en-GB/com_scheduler.ini
+++ b/administrator/language/en-GB/com_scheduler.ini
@@ -84,8 +84,13 @@ COM_SCHEDULER_MANAGER_TASKS="Scheduled Tasks"
 COM_SCHEDULER_MANAGER_TASK_EDIT="Edit Task"
 COM_SCHEDULER_MANAGER_TASK_NEW="New Task"
 COM_SCHEDULER_MANAGER_TOOLTIP_TASK_FAILING="Task failed. Exit code: %1$d"
+COM_SCHEDULER_MSG_DUETASKS="There is at least one due task which should have already run. Please make sure that at least one cron scheduler is enabled and running."
 COM_SCHEDULER_MSG_MANAGE_NO_TASK_PLUGINS="There are no task types matching your query."
 COM_SCHEDULER_NEW_TASK="New Task"
+COM_SCHEDULER_NEXT_RUN_ASC="Next Run ascending"
+COM_SCHEDULER_NEXT_RUN_DATE="Next Run Date"
+COM_SCHEDULER_NEXT_RUN_DESC="Next Run descending"
+COM_SCHEDULER_NEXT_RUN_MANUAL="Manual"
 COM_SCHEDULER_N_ITEMS_CHECKED_IN_1="Task checked in."
 COM_SCHEDULER_N_ITEMS_CHECKED_IN_MORE="%d tasks checked in."
 COM_SCHEDULER_N_ITEMS_DELETED="%d tasks deleted."
tecpromotion added a commit to tecpromotion/joomla that referenced this issue Jul 3, 2024
translation
@tecpromotion tecpromotion linked a pull request Jul 3, 2024 that will close this issue
@zero-24 zero-24 closed this as completed Jul 3, 2024
zero-24 added a commit that referenced this issue Jul 7, 2024
* add 4 new strings

* fix #3212

translation

* Update administrator/language/de-DE/com_scheduler.ini

Co-authored-by: Tobias Zulauf <[email protected]>

* Update administrator/language/de-DE/com_scheduler.ini

Co-authored-by: Tobias Zulauf <[email protected]>

* Update administrator/language/de-DE/com_scheduler.ini

Co-authored-by: Tobias Zulauf <[email protected]>

* wording

* wording

* Update administrator/language/de-DE/com_scheduler.ini

Co-authored-by: Tobias Zulauf <[email protected]>

* Shorter spelling

* suitable for column heading

---------

Co-authored-by: Tobias Zulauf <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants