Page MenuHomePhabricator

D11090.diff
No OneTemporary

D11090.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1565,6 +1565,7 @@
'PhabricatorDaemonManagementWorkflow' => 'applications/daemon/management/PhabricatorDaemonManagementWorkflow.php',
'PhabricatorDaemonReference' => 'infrastructure/daemon/control/PhabricatorDaemonReference.php',
'PhabricatorDaemonTaskGarbageCollector' => 'applications/daemon/garbagecollector/PhabricatorDaemonTaskGarbageCollector.php',
+ 'PhabricatorDaemonTasksTableView' => 'applications/daemon/view/PhabricatorDaemonTasksTableView.php',
'PhabricatorDaemonsApplication' => 'applications/daemon/application/PhabricatorDaemonsApplication.php',
'PhabricatorDashboard' => 'applications/dashboard/storage/PhabricatorDashboard.php',
'PhabricatorDashboardAddPanelController' => 'applications/dashboard/controller/PhabricatorDashboardAddPanelController.php',
@@ -4714,6 +4715,7 @@
'PhabricatorDaemonManagementStopWorkflow' => 'PhabricatorDaemonManagementWorkflow',
'PhabricatorDaemonManagementWorkflow' => 'PhabricatorManagementWorkflow',
'PhabricatorDaemonTaskGarbageCollector' => 'PhabricatorGarbageCollector',
+ 'PhabricatorDaemonTasksTableView' => 'AphrontView',
'PhabricatorDaemonsApplication' => 'PhabricatorApplication',
'PhabricatorDashboard' => array(
'PhabricatorDashboardDAO',
diff --git a/src/applications/daemon/controller/PhabricatorDaemonConsoleController.php b/src/applications/daemon/controller/PhabricatorDaemonConsoleController.php
--- a/src/applications/daemon/controller/PhabricatorDaemonConsoleController.php
+++ b/src/applications/daemon/controller/PhabricatorDaemonConsoleController.php
@@ -134,9 +134,9 @@
$tasks = id(new PhabricatorWorkerActiveTask())->loadAllWhere(
'leaseOwner IS NOT NULL');
- $tasks_table = $this->renderTasksTable(
- $tasks,
- pht('No tasks are leased by workers.'));
+ $tasks_table = id(new PhabricatorDaemonTasksTableView())
+ ->setTasks($tasks)
+ ->setNoDataString(pht('No tasks are leased by workers.'));
$leased_panel = id(new PHUIObjectBoxView())
->setHeaderText(pht('Leased Tasks'))
@@ -182,7 +182,9 @@
$upcoming_panel = id(new PHUIObjectBoxView())
->setHeaderText(pht('Next In Queue'))
->appendChild(
- $this->renderTasksTable($upcoming, pht('Task queue is empty.')));
+ id(new PhabricatorDaemonTasksTableView())
+ ->setTasks($upcoming)
+ ->setNoDataString(pht('Task queue is empty.')));
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Console'));
@@ -207,52 +209,4 @@
));
}
- private function renderTasksTable(array $tasks, $nodata) {
- $rows = array();
- foreach ($tasks as $task) {
- $rows[] = array(
- $task->getID(),
- $task->getTaskClass(),
- $task->getLeaseOwner(),
- $task->getLeaseExpires()
- ? phutil_format_relative_time($task->getLeaseExpires() - time())
- : '-',
- $task->getPriority(),
- $task->getFailureCount(),
- phutil_tag(
- 'a',
- array(
- 'href' => '/daemon/task/'.$task->getID().'/',
- 'class' => 'button small grey',
- ),
- pht('View Task')),
- );
- }
-
- $table = new AphrontTableView($rows);
- $table->setHeaders(
- array(
- pht('ID'),
- pht('Class'),
- pht('Owner'),
- pht('Expires'),
- pht('Priority'),
- pht('Failures'),
- '',
- ));
- $table->setColumnClasses(
- array(
- 'n',
- 'wide',
- '',
- '',
- 'n',
- 'n',
- 'action',
- ));
- $table->setNoDataString($nodata);
-
- return $table;
- }
-
}
diff --git a/src/applications/daemon/view/PhabricatorDaemonTasksTableView.php b/src/applications/daemon/view/PhabricatorDaemonTasksTableView.php
new file mode 100644
--- /dev/null
+++ b/src/applications/daemon/view/PhabricatorDaemonTasksTableView.php
@@ -0,0 +1,79 @@
+<?php
+
+final class PhabricatorDaemonTasksTableView extends AphrontView {
+
+ private $tasks;
+ private $noDataString;
+
+ public function setTasks(array $tasks) {
+ $this->tasks = $tasks;
+ return $this;
+ }
+
+ public function getTasks() {
+ return $this->tasks;
+ }
+
+ public function setNoDataString($no_data_string) {
+ $this->noDataString = $no_data_string;
+ return $this;
+ }
+
+ public function getNoDataString() {
+ return $this->noDataString;
+ }
+
+ public function render() {
+ $tasks = $this->getTasks();
+
+ $rows = array();
+ foreach ($tasks as $task) {
+ $rows[] = array(
+ $task->getID(),
+ $task->getTaskClass(),
+ $task->getLeaseOwner(),
+ $task->getLeaseExpires()
+ ? phutil_format_relative_time($task->getLeaseExpires() - time())
+ : '-',
+ $task->getPriority(),
+ $task->getFailureCount(),
+ phutil_tag(
+ 'a',
+ array(
+ 'href' => '/daemon/task/'.$task->getID().'/',
+ 'class' => 'button small grey',
+ ),
+ pht('View Task')),
+ );
+ }
+
+ $table = new AphrontTableView($rows);
+ $table->setHeaders(
+ array(
+ pht('ID'),
+ pht('Class'),
+ pht('Owner'),
+ pht('Expires'),
+ pht('Priority'),
+ pht('Failures'),
+ '',
+ ));
+ $table->setColumnClasses(
+ array(
+ 'n',
+ 'wide',
+ '',
+ '',
+ 'n',
+ 'n',
+ 'action',
+ ));
+
+ if (strlen($this->getNoDataString())) {
+ $table->setNoDataString($this->getNoDataString());
+ }
+
+ return $table;
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 22, 6:05 PM (12 h, 49 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6919303
Default Alt Text
D11090.diff (5 KB)

Event Timeline