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
This commit is contained in:
epriestley
2014-05-13 14:00:24 -07:00
parent 23ada21d35
commit 82102cd95a
6 changed files with 159 additions and 128 deletions

View File

@@ -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;
}
}