2013-12-05 20:56:14 +01:00
|
|
|
<?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'));
|
|
|
|
|
2013-12-06 02:01:07 +01:00
|
|
|
// 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');
|
|
|
|
}
|
|
|
|
|
2013-12-05 20:56:14 +01:00
|
|
|
$rows = array();
|
|
|
|
foreach ($logs as $log) {
|
2013-12-06 02:01:07 +01:00
|
|
|
|
|
|
|
// Reveal this if it's valid and the user can edit the repository.
|
|
|
|
$remote_addr = '-';
|
|
|
|
if (isset($editable_repos[$log->getRepositoryPHID()])) {
|
2014-03-26 03:43:26 +01:00
|
|
|
$remote_long = $log->getPushEvent()->getRemoteAddress();
|
2013-12-06 02:01:07 +01:00
|
|
|
if ($remote_long) {
|
|
|
|
$remote_addr = long2ip($remote_long);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-05 20:56:14 +01:00
|
|
|
$callsign = $log->getRepository()->getCallsign();
|
|
|
|
$rows[] = array(
|
2014-03-26 03:43:26 +01:00
|
|
|
$log->getPushEvent()->getID(),
|
2013-12-05 20:56:14 +01:00
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $this->getApplicationURI($callsign.'/'),
|
|
|
|
),
|
|
|
|
$callsign),
|
|
|
|
$this->getHandle($log->getPusherPHID())->renderLink(),
|
2013-12-06 02:01:07 +01:00
|
|
|
$remote_addr,
|
2014-03-26 03:43:26 +01:00
|
|
|
$log->getPushEvent()->getRemoteProtocol(),
|
2013-12-05 20:56:14 +01:00
|
|
|
$log->getRefType(),
|
|
|
|
$log->getRefName(),
|
2013-12-06 02:01:07 +01:00
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/r'.$callsign.$log->getRefOld(),
|
|
|
|
),
|
|
|
|
$log->getRefOldShort()),
|
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/r'.$callsign.$log->getRefNew(),
|
|
|
|
),
|
|
|
|
$log->getRefNewShort()),
|
2013-12-17 17:32:33 +01:00
|
|
|
|
|
|
|
// TODO: Make these human-readable.
|
|
|
|
$log->getChangeFlags(),
|
2014-03-26 03:43:26 +01:00
|
|
|
$log->getPushEvent()->getRejectCode(),
|
2013-12-05 20:56:14 +01:00
|
|
|
phabricator_datetime($log->getEpoch(), $viewer),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = id(new AphrontTableView($rows))
|
|
|
|
->setHeaders(
|
|
|
|
array(
|
2014-03-26 03:43:26 +01:00
|
|
|
pht('Push'),
|
2013-12-05 20:56:14 +01:00
|
|
|
pht('Repository'),
|
|
|
|
pht('Pusher'),
|
2013-12-05 20:59:22 +01:00
|
|
|
pht('From'),
|
|
|
|
pht('Via'),
|
2013-12-05 20:56:14 +01:00
|
|
|
pht('Type'),
|
|
|
|
pht('Name'),
|
|
|
|
pht('Old'),
|
|
|
|
pht('New'),
|
2013-12-17 17:32:33 +01:00
|
|
|
pht('Flags'),
|
|
|
|
pht('Code'),
|
2013-12-05 20:56:14 +01:00
|
|
|
pht('Date'),
|
|
|
|
))
|
|
|
|
->setColumnClasses(
|
|
|
|
array(
|
2013-12-05 20:59:22 +01:00
|
|
|
'',
|
|
|
|
'',
|
2013-12-05 20:56:14 +01:00
|
|
|
'',
|
|
|
|
'',
|
|
|
|
'',
|
2014-03-26 03:43:26 +01:00
|
|
|
'',
|
2013-12-05 20:56:14 +01:00
|
|
|
'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;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|