Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/view/DiffusionPushLogListView.php
<?php | <?php | ||||
final class DiffusionPushLogListView extends AphrontView { | final class DiffusionPushLogListView extends AphrontView { | ||||
private $logs; | private $logs; | ||||
private $handles; | |||||
public function setLogs(array $logs) { | public function setLogs(array $logs) { | ||||
assert_instances_of($logs, 'PhabricatorRepositoryPushLog'); | assert_instances_of($logs, 'PhabricatorRepositoryPushLog'); | ||||
$this->logs = $logs; | $this->logs = $logs; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setHandles(array $handles) { | |||||
$this->handles = $handles; | |||||
return $this; | |||||
} | |||||
public function render() { | public function render() { | ||||
$logs = $this->logs; | $logs = $this->logs; | ||||
$viewer = $this->getUser(); | $viewer = $this->getViewer(); | ||||
$handles = $this->handles; | |||||
$handle_phids = array(); | |||||
foreach ($logs as $log) { | |||||
$handle_phids[] = $log->getPusherPHID(); | |||||
$device_phid = $log->getDevicePHID(); | |||||
if ($device_phid) { | |||||
$handle_phids[] = $device_phid; | |||||
} | |||||
} | |||||
$handles = $viewer->loadHandles($handle_phids); | |||||
// Figure out which repositories are editable. We only let you see remote | // Figure out which repositories are editable. We only let you see remote | ||||
// IPs if you have edit capability on a repository. | // IPs if you have edit capability on a repository. | ||||
$editable_repos = array(); | $editable_repos = array(); | ||||
if ($logs) { | if ($logs) { | ||||
$editable_repos = id(new PhabricatorRepositoryQuery()) | $editable_repos = id(new PhabricatorRepositoryQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->requireCapabilities( | ->requireCapabilities( | ||||
Show All 26 Lines | foreach ($logs as $log) { | ||||
array( | array( | ||||
'href' => $repository->getCommitURI($log->getRefOld()), | 'href' => $repository->getCommitURI($log->getRefOld()), | ||||
), | ), | ||||
$log->getRefOldShort()); | $log->getRefOldShort()); | ||||
} | } | ||||
$device_phid = $log->getDevicePHID(); | $device_phid = $log->getDevicePHID(); | ||||
if ($device_phid) { | if ($device_phid) { | ||||
$device = $handles[$device_phid]->renderLink(); | $device = $viewer->renderHandle($device_phid); | ||||
$any_host = true; | $any_host = true; | ||||
} else { | } else { | ||||
$device = null; | $device = null; | ||||
} | } | ||||
$rows[] = array( | $rows[] = array( | ||||
phutil_tag( | phutil_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'href' => '/diffusion/pushlog/view/'.$event_id.'/', | 'href' => '/diffusion/pushlog/view/'.$event_id.'/', | ||||
), | ), | ||||
$event_id), | $event_id), | ||||
phutil_tag( | phutil_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'href' => $repository->getURI(), | 'href' => $repository->getURI(), | ||||
), | ), | ||||
$repository->getDisplayName()), | $repository->getDisplayName()), | ||||
$handles[$log->getPusherPHID()]->renderLink(), | $viewer->renderHandle($log->getPusherPHID()), | ||||
$remote_address, | $remote_address, | ||||
$log->getPushEvent()->getRemoteProtocol(), | $log->getPushEvent()->getRemoteProtocol(), | ||||
$device, | $device, | ||||
$log->getRefType(), | $log->getRefType(), | ||||
$log->getRefName(), | $log->getRefName(), | ||||
$old_ref_link, | $old_ref_link, | ||||
phutil_tag( | phutil_tag( | ||||
'a', | 'a', | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |