Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14040465
D9104.id21636.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
D9104.id21636.diff
View Options
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
@@ -528,6 +528,7 @@
'DiffusionPushEventViewController' => 'applications/diffusion/controller/DiffusionPushEventViewController.php',
'DiffusionPushLogController' => 'applications/diffusion/controller/DiffusionPushLogController.php',
'DiffusionPushLogListController' => 'applications/diffusion/controller/DiffusionPushLogListController.php',
+ 'DiffusionPushLogListView' => 'applications/diffusion/view/DiffusionPushLogListView.php',
'DiffusionQuery' => 'applications/diffusion/query/DiffusionQuery.php',
'DiffusionRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionRawDiffQuery.php',
'DiffusionRefNotFoundException' => 'applications/diffusion/exception/DiffusionRefNotFoundException.php',
@@ -3166,11 +3167,8 @@
'DiffusionPathValidateController' => 'DiffusionController',
'DiffusionPushEventViewController' => 'DiffusionPushLogController',
'DiffusionPushLogController' => 'DiffusionController',
- 'DiffusionPushLogListController' =>
- array(
- 0 => 'DiffusionPushLogController',
- 1 => 'PhabricatorApplicationSearchResultsControllerInterface',
- ),
+ 'DiffusionPushLogListController' => 'DiffusionPushLogController',
+ 'DiffusionPushLogListView' => 'AphrontView',
'DiffusionQuery' => 'PhabricatorQuery',
'DiffusionRawDiffQuery' => 'DiffusionQuery',
'DiffusionRefNotFoundException' => 'Exception',
diff --git a/src/applications/diffusion/controller/DiffusionPushEventViewController.php b/src/applications/diffusion/controller/DiffusionPushEventViewController.php
--- a/src/applications/diffusion/controller/DiffusionPushEventViewController.php
+++ b/src/applications/diffusion/controller/DiffusionPushEventViewController.php
@@ -52,7 +52,12 @@
->setHeaderText(pht('Pushed Commits'))
->appendChild($commits_table);
- $updates_table = $this->renderPushLogTable($event->getLogs());
+ $logs = $event->getLogs();
+
+ $updates_table = id(new DiffusionPushLogListView())
+ ->setUser($viewer)
+ ->setLogs($logs)
+ ->setHandles($this->loadViewerHandles(mpull($logs, 'getPusherPHID')));
$update_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('All Pushed Updates'))
diff --git a/src/applications/diffusion/controller/DiffusionPushLogController.php b/src/applications/diffusion/controller/DiffusionPushLogController.php
--- a/src/applications/diffusion/controller/DiffusionPushLogController.php
+++ b/src/applications/diffusion/controller/DiffusionPushLogController.php
@@ -2,111 +2,4 @@
abstract class DiffusionPushLogController extends DiffusionController {
- public function renderPushLogTable(array $logs) {
- $viewer = $this->getRequest()->getUser();
-
- $this->loadHandles(mpull($logs, 'getPusherPHID'));
-
- // Figure out which repositories are editable. We only let you see remote
- // IPs if you have edit capability on a repository.
- $editable_repos = array();
- if ($logs) {
- $editable_repos = id(new PhabricatorRepositoryQuery())
- ->setViewer($viewer)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->withPHIDs(mpull($logs, 'getRepositoryPHID'))
- ->execute();
- $editable_repos = mpull($editable_repos, null, 'getPHID');
- }
-
- $rows = array();
- foreach ($logs as $log) {
-
- // Reveal this if it's valid and the user can edit the repository.
- $remote_addr = '-';
- if (isset($editable_repos[$log->getRepositoryPHID()])) {
- $remote_long = $log->getPushEvent()->getRemoteAddress();
- if ($remote_long) {
- $remote_addr = long2ip($remote_long);
- }
- }
-
- $event_id = $log->getPushEvent()->getID();
-
- $callsign = $log->getRepository()->getCallsign();
- $rows[] = array(
- phutil_tag(
- 'a',
- array(
- 'href' => $this->getApplicationURI('pushlog/view/'.$event_id.'/'),
- ),
- $event_id),
- phutil_tag(
- 'a',
- array(
- 'href' => $this->getApplicationURI($callsign.'/'),
- ),
- $callsign),
- $this->getHandle($log->getPusherPHID())->renderLink(),
- $remote_addr,
- $log->getPushEvent()->getRemoteProtocol(),
- $log->getRefType(),
- $log->getRefName(),
- phutil_tag(
- 'a',
- array(
- 'href' => '/r'.$callsign.$log->getRefOld(),
- ),
- $log->getRefOldShort()),
- phutil_tag(
- 'a',
- array(
- 'href' => '/r'.$callsign.$log->getRefNew(),
- ),
- $log->getRefNewShort()),
-
- // TODO: Make these human-readable.
- $log->getChangeFlags(),
- $log->getPushEvent()->getRejectCode(),
- phabricator_datetime($log->getEpoch(), $viewer),
- );
- }
-
- $table = id(new AphrontTableView($rows))
- ->setHeaders(
- array(
- pht('Push'),
- pht('Repository'),
- pht('Pusher'),
- pht('From'),
- pht('Via'),
- pht('Type'),
- pht('Name'),
- pht('Old'),
- pht('New'),
- pht('Flags'),
- pht('Code'),
- pht('Date'),
- ))
- ->setColumnClasses(
- array(
- '',
- '',
- '',
- '',
- '',
- '',
- 'wide',
- 'n',
- 'n',
- 'date',
- ));
-
- return $table;
- }
-
}
diff --git a/src/applications/diffusion/controller/DiffusionPushLogListController.php b/src/applications/diffusion/controller/DiffusionPushLogListController.php
--- a/src/applications/diffusion/controller/DiffusionPushLogListController.php
+++ b/src/applications/diffusion/controller/DiffusionPushLogListController.php
@@ -1,7 +1,6 @@
<?php
-final class DiffusionPushLogListController extends DiffusionPushLogController
- implements PhabricatorApplicationSearchResultsControllerInterface {
+final class DiffusionPushLogListController extends DiffusionPushLogController {
private $queryKey;
@@ -23,19 +22,6 @@
return $this->delegateToController($controller);
}
- public function renderResultsList(
- array $logs,
- PhabricatorSavedQuery $query) {
-
- $table = $this->renderPushLogTable($logs);
-
- $box = id(new PHUIBoxView())
- ->addMargin(PHUI::MARGIN_LARGE)
- ->appendChild($table);
-
- return $box;
- }
-
public function buildSideNavView($for_app = false) {
$viewer = $this->getRequest()->getUser();
diff --git a/src/applications/diffusion/controller/DiffusionPushLogController.php b/src/applications/diffusion/view/DiffusionPushLogListView.php
copy from src/applications/diffusion/controller/DiffusionPushLogController.php
copy to src/applications/diffusion/view/DiffusionPushLogListView.php
--- a/src/applications/diffusion/controller/DiffusionPushLogController.php
+++ b/src/applications/diffusion/view/DiffusionPushLogListView.php
@@ -1,11 +1,25 @@
<?php
-abstract class DiffusionPushLogController extends DiffusionController {
+final class DiffusionPushLogListView extends AphrontView {
- public function renderPushLogTable(array $logs) {
- $viewer = $this->getRequest()->getUser();
+ private $logs;
+ private $handles;
- $this->loadHandles(mpull($logs, 'getPusherPHID'));
+ public function setLogs(array $logs) {
+ assert_instances_of($logs, 'PhabricatorRepositoryPushLog');
+ $this->logs = $logs;
+ return $this;
+ }
+
+ public function setHandles(array $handles) {
+ $this->handles = $handles;
+ return $this;
+ }
+
+ public function render() {
+ $logs = $this->logs;
+ $viewer = $this->getUser();
+ $handles = $this->handles;
// Figure out which repositories are editable. We only let you see remote
// IPs if you have edit capability on a repository.
@@ -42,16 +56,16 @@
phutil_tag(
'a',
array(
- 'href' => $this->getApplicationURI('pushlog/view/'.$event_id.'/'),
+ 'href' => '/diffusion/pushlog/view/'.$event_id.'/',
),
$event_id),
phutil_tag(
'a',
array(
- 'href' => $this->getApplicationURI($callsign.'/'),
+ 'href' => '/diffusion/'.$callsign.'/',
),
$callsign),
- $this->getHandle($log->getPusherPHID())->renderLink(),
+ $handles[$log->getPusherPHID()]->renderLink(),
$remote_addr,
$log->getPushEvent()->getRemoteProtocol(),
$log->getRefType(),
diff --git a/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php b/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php
--- a/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php
+++ b/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php
@@ -107,4 +107,27 @@
return parent::buildSavedQueryFromBuiltin($query_key);
}
+ protected function getRequiredHandlePHIDsForResultList(
+ array $logs,
+ PhabricatorSavedQuery $query) {
+ return mpull($logs, 'getPusherPHID');
+ }
+
+ protected function renderResultList(
+ array $logs,
+ PhabricatorSavedQuery $query,
+ array $handles) {
+
+ $table = id(new DiffusionPushLogListView())
+ ->setUser($this->requireViewer())
+ ->setHandles($handles)
+ ->setLogs($logs);
+
+ $box = id(new PHUIBoxView())
+ ->addMargin(PHUI::MARGIN_LARGE)
+ ->appendChild($table);
+
+ return $box;
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 12, 10:29 AM (1 d, 18 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6735233
Default Alt Text
D9104.id21636.diff (9 KB)
Attached To
Mode
D9104: Move Push log rendering to SearchEngine
Attached
Detach File
Event Timeline
Log In to Comment