Differential D7454 Diff 16807 src/applications/diffusion/controller/DiffusionBranchTableController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionBranchTableController.php
<?php | <?php | ||||
final class DiffusionBranchTableController extends DiffusionController { | final class DiffusionBranchTableController extends DiffusionController { | ||||
public function shouldAllowPublic() { | public function shouldAllowPublic() { | ||||
return true; | return true; | ||||
} | } | ||||
public function processRequest() { | public function processRequest() { | ||||
$drequest = $this->getDiffusionRequest(); | $drequest = $this->getDiffusionRequest(); | ||||
$request = $this->getRequest(); | $request = $this->getRequest(); | ||||
$user = $request->getUser(); | $viewer = $request->getUser(); | ||||
$repository = $drequest->getRepository(); | $repository = $drequest->getRepository(); | ||||
$pager = new AphrontPagerView(); | $pager = new AphrontPagerView(); | ||||
$pager->setURI($request->getRequestURI(), 'offset'); | $pager->setURI($request->getRequestURI(), 'offset'); | ||||
$pager->setOffset($request->getInt('offset')); | $pager->setOffset($request->getInt('offset')); | ||||
// TODO: Add support for branches that contain commit | // TODO: Add support for branches that contain commit | ||||
$branches = DiffusionBranchInformation::newFromConduit( | $branches = DiffusionBranchInformation::newFromConduit( | ||||
$this->callConduitWithDiffusionRequest( | $this->callConduitWithDiffusionRequest( | ||||
'diffusion.branchquery', | 'diffusion.branchquery', | ||||
array( | array( | ||||
'offset' => $pager->getOffset(), | 'offset' => $pager->getOffset(), | ||||
'limit' => $pager->getPageSize() + 1 | 'limit' => $pager->getPageSize() + 1 | ||||
))); | ))); | ||||
$branches = $pager->sliceResults($branches); | $branches = $pager->sliceResults($branches); | ||||
$content = null; | $content = null; | ||||
if (!$branches) { | if (!$branches) { | ||||
$content = new AphrontErrorView(); | $content = $this->renderStatusMessage( | ||||
$content->setTitle(pht('No Branches')); | pht('No Branches'), | ||||
$content->appendChild(pht('This repository has no branches.')); | pht('This repository has no branches.')); | ||||
$content->setSeverity(AphrontErrorView::SEVERITY_NODATA); | |||||
} else { | } else { | ||||
$commits = id(new PhabricatorAuditCommitQuery()) | $commits = id(new DiffusionCommitQuery()) | ||||
->withIdentifiers( | ->setViewer($viewer) | ||||
$drequest->getRepository()->getID(), | ->withIdentifiers(mpull($branches, 'getHeadCommitIdentifier')) | ||||
mpull($branches, 'getHeadCommitIdentifier')) | ->withRepositoryIDs(array($repository->getID())) | ||||
->needCommitData(true) | |||||
->execute(); | ->execute(); | ||||
$view = id(new DiffusionBranchTableView()) | $view = id(new DiffusionBranchTableView()) | ||||
->setUser($viewer) | |||||
->setBranches($branches) | ->setBranches($branches) | ||||
->setUser($user) | |||||
->setCommits($commits) | ->setCommits($commits) | ||||
->setDiffusionRequest($drequest); | ->setDiffusionRequest($drequest); | ||||
$panel = id(new AphrontPanelView()) | $panel = id(new AphrontPanelView()) | ||||
->setNoBackground(true) | ->setNoBackground(true) | ||||
->appendChild($view) | ->appendChild($view) | ||||
->appendChild($pager); | ->appendChild($pager); | ||||
$content = $panel; | $content = $panel; | ||||
} | } | ||||
$crumbs = $this->buildCrumbs( | $crumbs = $this->buildCrumbs( | ||||
array( | array( | ||||
'branches' => true, | 'branches' => true, | ||||
)); | )); | ||||
return $this->buildApplicationPage( | return $this->buildApplicationPage( | ||||
array( | array( | ||||
$crumbs, | $crumbs, | ||||
$content, | $content, | ||||
), | ), | ||||
array( | array( | ||||
'title' => array( | 'title' => array( | ||||
'Branches', | pht('Branches'), | ||||
$repository->getCallsign().' Repository', | 'r'.$repository->getCallsign(), | ||||
), | ), | ||||
)); | )); | ||||
} | } | ||||
} | } |