Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/view/DiffusionBranchTableView.php
Show All 15 Lines | public function setCommits(array $commits) { | ||||
$this->commits = mpull($commits, null, 'getCommitIdentifier'); | $this->commits = mpull($commits, null, 'getCommitIdentifier'); | ||||
return $this; | return $this; | ||||
} | } | ||||
public function render() { | public function render() { | ||||
$drequest = $this->getDiffusionRequest(); | $drequest = $this->getDiffusionRequest(); | ||||
$current_branch = $drequest->getBranch(); | $current_branch = $drequest->getBranch(); | ||||
$repository = $drequest->getRepository(); | $repository = $drequest->getRepository(); | ||||
$commits = $this->commits; | |||||
$viewer = $this->getUser(); | |||||
$buildables = $this->loadBuildables($commits); | |||||
$have_builds = false; | |||||
$can_close_branches = ($repository->isHg()); | $can_close_branches = ($repository->isHg()); | ||||
Javelin::initBehavior('phabricator-tooltips'); | Javelin::initBehavior('phabricator-tooltips'); | ||||
$doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Autoclose'); | $doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Autoclose'); | ||||
$rows = array(); | $rows = array(); | ||||
$rowc = array(); | $rowc = array(); | ||||
foreach ($this->branches as $branch) { | foreach ($this->branches as $branch) { | ||||
$commit = idx($this->commits, $branch->getCommitIdentifier()); | $commit = idx($commits, $branch->getCommitIdentifier()); | ||||
if ($commit) { | if ($commit) { | ||||
$details = $commit->getSummary(); | $details = $commit->getSummary(); | ||||
$datetime = phabricator_datetime($commit->getEpoch(), $this->user); | $datetime = phabricator_datetime($commit->getEpoch(), $viewer); | ||||
$buildable = idx($buildables, $commit->getPHID()); | |||||
if ($buildable) { | |||||
$build_status = $this->renderBuildable($buildable); | |||||
$have_builds = true; | |||||
} else { | |||||
$build_status = null; | |||||
} | |||||
} else { | } else { | ||||
$datetime = null; | $datetime = null; | ||||
$details = null; | $details = null; | ||||
$build_status = null; | |||||
} | } | ||||
switch ($repository->shouldSkipAutocloseBranch($branch->getShortName())) { | switch ($repository->shouldSkipAutocloseBranch($branch->getShortName())) { | ||||
case PhabricatorRepository::BECAUSE_REPOSITORY_IMPORTING: | case PhabricatorRepository::BECAUSE_REPOSITORY_IMPORTING: | ||||
$icon = 'fa-times bluegrey'; | $icon = 'fa-times bluegrey'; | ||||
$tip = pht('Repository Importing'); | $tip = pht('Repository Importing'); | ||||
break; | break; | ||||
case PhabricatorRepository::BECAUSE_AUTOCLOSE_DISABLED: | case PhabricatorRepository::BECAUSE_AUTOCLOSE_DISABLED: | ||||
Show All 32 Lines | foreach ($this->branches as $branch) { | ||||
$closed = idx($fields, 'closed'); | $closed = idx($fields, 'closed'); | ||||
if ($closed) { | if ($closed) { | ||||
$status = pht('Closed'); | $status = pht('Closed'); | ||||
} else { | } else { | ||||
$status = pht('Open'); | $status = pht('Open'); | ||||
} | } | ||||
$rows[] = array( | $rows[] = array( | ||||
phutil_tag( | $this->linkBranchHistory($branch->getShortName()), | ||||
'a', | |||||
array( | |||||
'href' => $drequest->generateURI( | |||||
array( | |||||
'action' => 'history', | |||||
'branch' => $branch->getShortName(), | |||||
)), | |||||
), | |||||
pht('History')), | |||||
phutil_tag( | phutil_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'href' => $drequest->generateURI( | 'href' => $drequest->generateURI( | ||||
array( | array( | ||||
'action' => 'browse', | 'action' => 'browse', | ||||
'branch' => $branch->getShortName(), | 'branch' => $branch->getShortName(), | ||||
)), | )), | ||||
), | ), | ||||
$branch->getShortName()), | $branch->getShortName()), | ||||
self::linkCommit( | self::linkCommit( | ||||
$drequest->getRepository(), | $drequest->getRepository(), | ||||
$branch->getCommitIdentifier()), | $branch->getCommitIdentifier()), | ||||
$build_status, | |||||
$status, | $status, | ||||
AphrontTableView::renderSingleDisplayLine($details), | |||||
$status_icon, | $status_icon, | ||||
$datetime, | $datetime, | ||||
AphrontTableView::renderSingleDisplayLine($details), | |||||
); | ); | ||||
if ($branch->getShortName() == $current_branch) { | if ($branch->getShortName() == $current_branch) { | ||||
$rowc[] = 'highlighted'; | $rowc[] = 'highlighted'; | ||||
} else { | } else { | ||||
$rowc[] = null; | $rowc[] = null; | ||||
} | } | ||||
} | } | ||||
$view = new AphrontTableView($rows); | $view = new AphrontTableView($rows); | ||||
$view->setHeaders( | $view->setHeaders( | ||||
array( | array( | ||||
pht('History'), | null, | ||||
pht('Branch'), | pht('Branch'), | ||||
pht('Head'), | pht('Head'), | ||||
null, | |||||
pht('State'), | pht('State'), | ||||
pht(''), | |||||
pht('Modified'), | |||||
pht('Details'), | pht('Details'), | ||||
null, | |||||
pht('Committed'), | |||||
)); | )); | ||||
$view->setColumnClasses( | $view->setColumnClasses( | ||||
array( | array( | ||||
'', | '', | ||||
'pri', | 'pri', | ||||
'', | '', | ||||
'icon', | |||||
'', | '', | ||||
'wide', | |||||
'', | '', | ||||
'', | '', | ||||
'wide', | |||||
)); | )); | ||||
$view->setColumnVisibility( | $view->setColumnVisibility( | ||||
array( | array( | ||||
true, | true, | ||||
true, | true, | ||||
true, | true, | ||||
$have_builds, | |||||
$can_close_branches, | $can_close_branches, | ||||
)); | )); | ||||
$view->setRowClasses($rowc); | $view->setRowClasses($rowc); | ||||
return $view->render(); | return $view->render(); | ||||
} | } | ||||
} | } |