Something went wrong. Try again.
@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
Something went wrong. Try again.
3.8 kB · 144 lines
PHP
at commit dcd7a316
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145<?php
final class DiffusionPushLogListController extends DiffusionController implements PhabricatorApplicationSearchResultsControllerInterface {
private $queryKey;
public function shouldAllowPublic() { return true; }
public function willProcessRequest(array $data) { $this->queryKey = idx($data, 'queryKey'); }
public function processRequest() { $request = $this->getRequest(); $controller = id(new PhabricatorApplicationSearchController($request)) ->setQueryKey($this->queryKey) ->setSearchEngine(new PhabricatorRepositoryPushLogSearchEngine()) ->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller); }
public function renderResultsList( array $logs, PhabricatorSavedQuery $query) { $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->getRemoteAddress(); if ($remote_long) { $remote_addr = long2ip($remote_long); } }
$callsign = $log->getRepository()->getCallsign(); $rows[] = array( phutil_tag( 'a', array( 'href' => $this->getApplicationURI($callsign.'/'), ), $callsign), $this->getHandle($log->getPusherPHID())->renderLink(), $remote_addr, $log->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->getRejectCode(), phabricator_datetime($log->getEpoch(), $viewer), ); }
$table = id(new AphrontTableView($rows)) ->setHeaders( array( 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', ));
$box = id(new PHUIBoxView()) ->addMargin(PHUI::MARGIN_LARGE) ->appendChild($table);
return $box; }
public function buildSideNavView($for_app = false) { $viewer = $this->getRequest()->getUser();
$nav = new AphrontSideNavFilterView(); $nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
id(new PhabricatorRepositoryPushLogSearchEngine()) ->setViewer($viewer) ->addNavigationItems($nav->getMenu());
$nav->selectFilter(null);
return $nav; }
}