@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Separate daemon task table rendering into a standalone class

Summary: Ref T5402, T6238. Pull this out into a class so the Instances app can embed task views.

Test Plan: Loaded `/daemon/` and examined the content in the tables.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T6238, T5402

Differential Revision: https://secure.phabricator.com/D11090

+87 -52
+2
src/__phutil_library_map__.php
··· 1565 1565 'PhabricatorDaemonManagementWorkflow' => 'applications/daemon/management/PhabricatorDaemonManagementWorkflow.php', 1566 1566 'PhabricatorDaemonReference' => 'infrastructure/daemon/control/PhabricatorDaemonReference.php', 1567 1567 'PhabricatorDaemonTaskGarbageCollector' => 'applications/daemon/garbagecollector/PhabricatorDaemonTaskGarbageCollector.php', 1568 + 'PhabricatorDaemonTasksTableView' => 'applications/daemon/view/PhabricatorDaemonTasksTableView.php', 1568 1569 'PhabricatorDaemonsApplication' => 'applications/daemon/application/PhabricatorDaemonsApplication.php', 1569 1570 'PhabricatorDashboard' => 'applications/dashboard/storage/PhabricatorDashboard.php', 1570 1571 'PhabricatorDashboardAddPanelController' => 'applications/dashboard/controller/PhabricatorDashboardAddPanelController.php', ··· 4714 4715 'PhabricatorDaemonManagementStopWorkflow' => 'PhabricatorDaemonManagementWorkflow', 4715 4716 'PhabricatorDaemonManagementWorkflow' => 'PhabricatorManagementWorkflow', 4716 4717 'PhabricatorDaemonTaskGarbageCollector' => 'PhabricatorGarbageCollector', 4718 + 'PhabricatorDaemonTasksTableView' => 'AphrontView', 4717 4719 'PhabricatorDaemonsApplication' => 'PhabricatorApplication', 4718 4720 'PhabricatorDashboard' => array( 4719 4721 'PhabricatorDashboardDAO',
+6 -52
src/applications/daemon/controller/PhabricatorDaemonConsoleController.php
··· 134 134 $tasks = id(new PhabricatorWorkerActiveTask())->loadAllWhere( 135 135 'leaseOwner IS NOT NULL'); 136 136 137 - $tasks_table = $this->renderTasksTable( 138 - $tasks, 139 - pht('No tasks are leased by workers.')); 137 + $tasks_table = id(new PhabricatorDaemonTasksTableView()) 138 + ->setTasks($tasks) 139 + ->setNoDataString(pht('No tasks are leased by workers.')); 140 140 141 141 $leased_panel = id(new PHUIObjectBoxView()) 142 142 ->setHeaderText(pht('Leased Tasks')) ··· 182 182 $upcoming_panel = id(new PHUIObjectBoxView()) 183 183 ->setHeaderText(pht('Next In Queue')) 184 184 ->appendChild( 185 - $this->renderTasksTable($upcoming, pht('Task queue is empty.'))); 185 + id(new PhabricatorDaemonTasksTableView()) 186 + ->setTasks($upcoming) 187 + ->setNoDataString(pht('Task queue is empty.'))); 186 188 187 189 $crumbs = $this->buildApplicationCrumbs(); 188 190 $crumbs->addTextCrumb(pht('Console')); ··· 205 207 'title' => pht('Console'), 206 208 'device' => false, 207 209 )); 208 - } 209 - 210 - private function renderTasksTable(array $tasks, $nodata) { 211 - $rows = array(); 212 - foreach ($tasks as $task) { 213 - $rows[] = array( 214 - $task->getID(), 215 - $task->getTaskClass(), 216 - $task->getLeaseOwner(), 217 - $task->getLeaseExpires() 218 - ? phutil_format_relative_time($task->getLeaseExpires() - time()) 219 - : '-', 220 - $task->getPriority(), 221 - $task->getFailureCount(), 222 - phutil_tag( 223 - 'a', 224 - array( 225 - 'href' => '/daemon/task/'.$task->getID().'/', 226 - 'class' => 'button small grey', 227 - ), 228 - pht('View Task')), 229 - ); 230 - } 231 - 232 - $table = new AphrontTableView($rows); 233 - $table->setHeaders( 234 - array( 235 - pht('ID'), 236 - pht('Class'), 237 - pht('Owner'), 238 - pht('Expires'), 239 - pht('Priority'), 240 - pht('Failures'), 241 - '', 242 - )); 243 - $table->setColumnClasses( 244 - array( 245 - 'n', 246 - 'wide', 247 - '', 248 - '', 249 - 'n', 250 - 'n', 251 - 'action', 252 - )); 253 - $table->setNoDataString($nodata); 254 - 255 - return $table; 256 210 } 257 211 258 212 }
+79
src/applications/daemon/view/PhabricatorDaemonTasksTableView.php
··· 1 + <?php 2 + 3 + final class PhabricatorDaemonTasksTableView extends AphrontView { 4 + 5 + private $tasks; 6 + private $noDataString; 7 + 8 + public function setTasks(array $tasks) { 9 + $this->tasks = $tasks; 10 + return $this; 11 + } 12 + 13 + public function getTasks() { 14 + return $this->tasks; 15 + } 16 + 17 + public function setNoDataString($no_data_string) { 18 + $this->noDataString = $no_data_string; 19 + return $this; 20 + } 21 + 22 + public function getNoDataString() { 23 + return $this->noDataString; 24 + } 25 + 26 + public function render() { 27 + $tasks = $this->getTasks(); 28 + 29 + $rows = array(); 30 + foreach ($tasks as $task) { 31 + $rows[] = array( 32 + $task->getID(), 33 + $task->getTaskClass(), 34 + $task->getLeaseOwner(), 35 + $task->getLeaseExpires() 36 + ? phutil_format_relative_time($task->getLeaseExpires() - time()) 37 + : '-', 38 + $task->getPriority(), 39 + $task->getFailureCount(), 40 + phutil_tag( 41 + 'a', 42 + array( 43 + 'href' => '/daemon/task/'.$task->getID().'/', 44 + 'class' => 'button small grey', 45 + ), 46 + pht('View Task')), 47 + ); 48 + } 49 + 50 + $table = new AphrontTableView($rows); 51 + $table->setHeaders( 52 + array( 53 + pht('ID'), 54 + pht('Class'), 55 + pht('Owner'), 56 + pht('Expires'), 57 + pht('Priority'), 58 + pht('Failures'), 59 + '', 60 + )); 61 + $table->setColumnClasses( 62 + array( 63 + 'n', 64 + 'wide', 65 + '', 66 + '', 67 + 'n', 68 + 'n', 69 + 'action', 70 + )); 71 + 72 + if (strlen($this->getNoDataString())) { 73 + $table->setNoDataString($this->getNoDataString()); 74 + } 75 + 76 + return $table; 77 + } 78 + 79 + }