2014-05-13 23:00:24 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DiffusionPushLogListView extends AphrontView {
|
|
|
|
|
|
|
|
private $logs;
|
|
|
|
private $handles;
|
|
|
|
|
|
|
|
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.
|
|
|
|
$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) {
|
2016-01-02 20:28:31 +01:00
|
|
|
$repository = $log->getRepository();
|
2014-05-13 23:00:24 +02:00
|
|
|
|
|
|
|
// Reveal this if it's valid and the user can edit the repository.
|
2016-02-02 18:59:49 +01:00
|
|
|
$remote_address = '-';
|
2014-05-13 23:00:24 +02:00
|
|
|
if (isset($editable_repos[$log->getRepositoryPHID()])) {
|
2016-02-02 18:59:49 +01:00
|
|
|
$remote_address = $log->getPushEvent()->getRemoteAddress();
|
2014-05-13 23:00:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$event_id = $log->getPushEvent()->getID();
|
|
|
|
|
2014-12-31 00:17:49 +01:00
|
|
|
$old_ref_link = null;
|
|
|
|
if ($log->getRefOld() != DiffusionCommitHookEngine::EMPTY_HASH) {
|
|
|
|
$old_ref_link = phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
2016-01-02 20:28:31 +01:00
|
|
|
'href' => $repository->getCommitURI($log->getRefOld()),
|
2014-12-31 00:17:49 +01:00
|
|
|
),
|
|
|
|
$log->getRefOldShort());
|
|
|
|
}
|
2016-01-02 20:28:31 +01:00
|
|
|
|
2014-05-13 23:00:24 +02:00
|
|
|
$rows[] = array(
|
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/diffusion/pushlog/view/'.$event_id.'/',
|
|
|
|
),
|
|
|
|
$event_id),
|
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
2016-01-02 20:28:31 +01:00
|
|
|
'href' => $repository->getURI(),
|
2014-05-13 23:00:24 +02:00
|
|
|
),
|
2016-01-02 20:28:31 +01:00
|
|
|
$repository->getDisplayName()),
|
2014-05-13 23:00:24 +02:00
|
|
|
$handles[$log->getPusherPHID()]->renderLink(),
|
2016-02-02 18:59:49 +01:00
|
|
|
$remote_address,
|
2014-05-13 23:00:24 +02:00
|
|
|
$log->getPushEvent()->getRemoteProtocol(),
|
|
|
|
$log->getRefType(),
|
|
|
|
$log->getRefName(),
|
2014-12-31 00:17:49 +01:00
|
|
|
$old_ref_link,
|
2014-05-13 23:00:24 +02:00
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
2016-01-02 20:28:31 +01:00
|
|
|
'href' => $repository->getCommitURI($log->getRefNew()),
|
2014-05-13 23:00:24 +02:00
|
|
|
),
|
|
|
|
$log->getRefNewShort()),
|
|
|
|
|
|
|
|
// TODO: Make these human-readable.
|
|
|
|
$log->getChangeFlags(),
|
|
|
|
$log->getPushEvent()->getRejectCode(),
|
2016-03-18 16:59:21 +01:00
|
|
|
$viewer->formatShortDateTime($log->getEpoch()),
|
2014-05-13 23:00:24 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$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',
|
2016-03-18 16:59:21 +01:00
|
|
|
'right',
|
2014-05-13 23:00:24 +02:00
|
|
|
));
|
|
|
|
|
|
|
|
return $table;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|