@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.

Move Push log rendering to SearchEngine

Summary: Ref T4986. Move push logs to a View, then have all the stuff that needs to use it use that View.

Test Plan: Viewed push logs and transaction detail in Diffusion. Created a panel.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4986

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

+159 -128
+3 -5
src/__phutil_library_map__.php
··· 528 528 'DiffusionPushEventViewController' => 'applications/diffusion/controller/DiffusionPushEventViewController.php', 529 529 'DiffusionPushLogController' => 'applications/diffusion/controller/DiffusionPushLogController.php', 530 530 'DiffusionPushLogListController' => 'applications/diffusion/controller/DiffusionPushLogListController.php', 531 + 'DiffusionPushLogListView' => 'applications/diffusion/view/DiffusionPushLogListView.php', 531 532 'DiffusionQuery' => 'applications/diffusion/query/DiffusionQuery.php', 532 533 'DiffusionRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionRawDiffQuery.php', 533 534 'DiffusionRefNotFoundException' => 'applications/diffusion/exception/DiffusionRefNotFoundException.php', ··· 3166 3167 'DiffusionPathValidateController' => 'DiffusionController', 3167 3168 'DiffusionPushEventViewController' => 'DiffusionPushLogController', 3168 3169 'DiffusionPushLogController' => 'DiffusionController', 3169 - 'DiffusionPushLogListController' => 3170 - array( 3171 - 0 => 'DiffusionPushLogController', 3172 - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', 3173 - ), 3170 + 'DiffusionPushLogListController' => 'DiffusionPushLogController', 3171 + 'DiffusionPushLogListView' => 'AphrontView', 3174 3172 'DiffusionQuery' => 'PhabricatorQuery', 3175 3173 'DiffusionRawDiffQuery' => 'DiffusionQuery', 3176 3174 'DiffusionRefNotFoundException' => 'Exception',
+6 -1
src/applications/diffusion/controller/DiffusionPushEventViewController.php
··· 52 52 ->setHeaderText(pht('Pushed Commits')) 53 53 ->appendChild($commits_table); 54 54 55 - $updates_table = $this->renderPushLogTable($event->getLogs()); 55 + $logs = $event->getLogs(); 56 + 57 + $updates_table = id(new DiffusionPushLogListView()) 58 + ->setUser($viewer) 59 + ->setLogs($logs) 60 + ->setHandles($this->loadViewerHandles(mpull($logs, 'getPusherPHID'))); 56 61 57 62 $update_box = id(new PHUIObjectBoxView()) 58 63 ->setHeaderText(pht('All Pushed Updates'))
-107
src/applications/diffusion/controller/DiffusionPushLogController.php
··· 2 2 3 3 abstract class DiffusionPushLogController extends DiffusionController { 4 4 5 - public function renderPushLogTable(array $logs) { 6 - $viewer = $this->getRequest()->getUser(); 7 - 8 - $this->loadHandles(mpull($logs, 'getPusherPHID')); 9 - 10 - // Figure out which repositories are editable. We only let you see remote 11 - // IPs if you have edit capability on a repository. 12 - $editable_repos = array(); 13 - if ($logs) { 14 - $editable_repos = id(new PhabricatorRepositoryQuery()) 15 - ->setViewer($viewer) 16 - ->requireCapabilities( 17 - array( 18 - PhabricatorPolicyCapability::CAN_VIEW, 19 - PhabricatorPolicyCapability::CAN_EDIT, 20 - )) 21 - ->withPHIDs(mpull($logs, 'getRepositoryPHID')) 22 - ->execute(); 23 - $editable_repos = mpull($editable_repos, null, 'getPHID'); 24 - } 25 - 26 - $rows = array(); 27 - foreach ($logs as $log) { 28 - 29 - // Reveal this if it's valid and the user can edit the repository. 30 - $remote_addr = '-'; 31 - if (isset($editable_repos[$log->getRepositoryPHID()])) { 32 - $remote_long = $log->getPushEvent()->getRemoteAddress(); 33 - if ($remote_long) { 34 - $remote_addr = long2ip($remote_long); 35 - } 36 - } 37 - 38 - $event_id = $log->getPushEvent()->getID(); 39 - 40 - $callsign = $log->getRepository()->getCallsign(); 41 - $rows[] = array( 42 - phutil_tag( 43 - 'a', 44 - array( 45 - 'href' => $this->getApplicationURI('pushlog/view/'.$event_id.'/'), 46 - ), 47 - $event_id), 48 - phutil_tag( 49 - 'a', 50 - array( 51 - 'href' => $this->getApplicationURI($callsign.'/'), 52 - ), 53 - $callsign), 54 - $this->getHandle($log->getPusherPHID())->renderLink(), 55 - $remote_addr, 56 - $log->getPushEvent()->getRemoteProtocol(), 57 - $log->getRefType(), 58 - $log->getRefName(), 59 - phutil_tag( 60 - 'a', 61 - array( 62 - 'href' => '/r'.$callsign.$log->getRefOld(), 63 - ), 64 - $log->getRefOldShort()), 65 - phutil_tag( 66 - 'a', 67 - array( 68 - 'href' => '/r'.$callsign.$log->getRefNew(), 69 - ), 70 - $log->getRefNewShort()), 71 - 72 - // TODO: Make these human-readable. 73 - $log->getChangeFlags(), 74 - $log->getPushEvent()->getRejectCode(), 75 - phabricator_datetime($log->getEpoch(), $viewer), 76 - ); 77 - } 78 - 79 - $table = id(new AphrontTableView($rows)) 80 - ->setHeaders( 81 - array( 82 - pht('Push'), 83 - pht('Repository'), 84 - pht('Pusher'), 85 - pht('From'), 86 - pht('Via'), 87 - pht('Type'), 88 - pht('Name'), 89 - pht('Old'), 90 - pht('New'), 91 - pht('Flags'), 92 - pht('Code'), 93 - pht('Date'), 94 - )) 95 - ->setColumnClasses( 96 - array( 97 - '', 98 - '', 99 - '', 100 - '', 101 - '', 102 - '', 103 - 'wide', 104 - 'n', 105 - 'n', 106 - 'date', 107 - )); 108 - 109 - return $table; 110 - } 111 - 112 5 }
+1 -15
src/applications/diffusion/controller/DiffusionPushLogListController.php
··· 1 1 <?php 2 2 3 - final class DiffusionPushLogListController extends DiffusionPushLogController 4 - implements PhabricatorApplicationSearchResultsControllerInterface { 3 + final class DiffusionPushLogListController extends DiffusionPushLogController { 5 4 6 5 private $queryKey; 7 6 ··· 21 20 ->setNavigation($this->buildSideNavView()); 22 21 23 22 return $this->delegateToController($controller); 24 - } 25 - 26 - public function renderResultsList( 27 - array $logs, 28 - PhabricatorSavedQuery $query) { 29 - 30 - $table = $this->renderPushLogTable($logs); 31 - 32 - $box = id(new PHUIBoxView()) 33 - ->addMargin(PHUI::MARGIN_LARGE) 34 - ->appendChild($table); 35 - 36 - return $box; 37 23 } 38 24 39 25 public function buildSideNavView($for_app = false) {
+126
src/applications/diffusion/view/DiffusionPushLogListView.php
··· 1 + <?php 2 + 3 + final class DiffusionPushLogListView extends AphrontView { 4 + 5 + private $logs; 6 + private $handles; 7 + 8 + public function setLogs(array $logs) { 9 + assert_instances_of($logs, 'PhabricatorRepositoryPushLog'); 10 + $this->logs = $logs; 11 + return $this; 12 + } 13 + 14 + public function setHandles(array $handles) { 15 + $this->handles = $handles; 16 + return $this; 17 + } 18 + 19 + public function render() { 20 + $logs = $this->logs; 21 + $viewer = $this->getUser(); 22 + $handles = $this->handles; 23 + 24 + // Figure out which repositories are editable. We only let you see remote 25 + // IPs if you have edit capability on a repository. 26 + $editable_repos = array(); 27 + if ($logs) { 28 + $editable_repos = id(new PhabricatorRepositoryQuery()) 29 + ->setViewer($viewer) 30 + ->requireCapabilities( 31 + array( 32 + PhabricatorPolicyCapability::CAN_VIEW, 33 + PhabricatorPolicyCapability::CAN_EDIT, 34 + )) 35 + ->withPHIDs(mpull($logs, 'getRepositoryPHID')) 36 + ->execute(); 37 + $editable_repos = mpull($editable_repos, null, 'getPHID'); 38 + } 39 + 40 + $rows = array(); 41 + foreach ($logs as $log) { 42 + 43 + // Reveal this if it's valid and the user can edit the repository. 44 + $remote_addr = '-'; 45 + if (isset($editable_repos[$log->getRepositoryPHID()])) { 46 + $remote_long = $log->getPushEvent()->getRemoteAddress(); 47 + if ($remote_long) { 48 + $remote_addr = long2ip($remote_long); 49 + } 50 + } 51 + 52 + $event_id = $log->getPushEvent()->getID(); 53 + 54 + $callsign = $log->getRepository()->getCallsign(); 55 + $rows[] = array( 56 + phutil_tag( 57 + 'a', 58 + array( 59 + 'href' => '/diffusion/pushlog/view/'.$event_id.'/', 60 + ), 61 + $event_id), 62 + phutil_tag( 63 + 'a', 64 + array( 65 + 'href' => '/diffusion/'.$callsign.'/', 66 + ), 67 + $callsign), 68 + $handles[$log->getPusherPHID()]->renderLink(), 69 + $remote_addr, 70 + $log->getPushEvent()->getRemoteProtocol(), 71 + $log->getRefType(), 72 + $log->getRefName(), 73 + phutil_tag( 74 + 'a', 75 + array( 76 + 'href' => '/r'.$callsign.$log->getRefOld(), 77 + ), 78 + $log->getRefOldShort()), 79 + phutil_tag( 80 + 'a', 81 + array( 82 + 'href' => '/r'.$callsign.$log->getRefNew(), 83 + ), 84 + $log->getRefNewShort()), 85 + 86 + // TODO: Make these human-readable. 87 + $log->getChangeFlags(), 88 + $log->getPushEvent()->getRejectCode(), 89 + phabricator_datetime($log->getEpoch(), $viewer), 90 + ); 91 + } 92 + 93 + $table = id(new AphrontTableView($rows)) 94 + ->setHeaders( 95 + array( 96 + pht('Push'), 97 + pht('Repository'), 98 + pht('Pusher'), 99 + pht('From'), 100 + pht('Via'), 101 + pht('Type'), 102 + pht('Name'), 103 + pht('Old'), 104 + pht('New'), 105 + pht('Flags'), 106 + pht('Code'), 107 + pht('Date'), 108 + )) 109 + ->setColumnClasses( 110 + array( 111 + '', 112 + '', 113 + '', 114 + '', 115 + '', 116 + '', 117 + 'wide', 118 + 'n', 119 + 'n', 120 + 'date', 121 + )); 122 + 123 + return $table; 124 + } 125 + 126 + }
+23
src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php
··· 107 107 return parent::buildSavedQueryFromBuiltin($query_key); 108 108 } 109 109 110 + protected function getRequiredHandlePHIDsForResultList( 111 + array $logs, 112 + PhabricatorSavedQuery $query) { 113 + return mpull($logs, 'getPusherPHID'); 114 + } 115 + 116 + protected function renderResultList( 117 + array $logs, 118 + PhabricatorSavedQuery $query, 119 + array $handles) { 120 + 121 + $table = id(new DiffusionPushLogListView()) 122 + ->setUser($this->requireViewer()) 123 + ->setHandles($handles) 124 + ->setLogs($logs); 125 + 126 + $box = id(new PHUIBoxView()) 127 + ->addMargin(PHUI::MARGIN_LARGE) 128 + ->appendChild($table); 129 + 130 + return $box; 131 + } 132 + 110 133 }