[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/diffusion/view/ -> DiffusionBranchTableView.php (source)

   1  <?php
   2  
   3  final class DiffusionBranchTableView extends DiffusionView {
   4  
   5    private $branches;
   6    private $commits = array();
   7  
   8    public function setBranches(array $branches) {
   9      assert_instances_of($branches, 'DiffusionRepositoryRef');
  10      $this->branches = $branches;
  11      return $this;
  12    }
  13  
  14    public function setCommits(array $commits) {
  15      assert_instances_of($commits, 'PhabricatorRepositoryCommit');
  16      $this->commits = mpull($commits, null, 'getCommitIdentifier');
  17      return $this;
  18    }
  19  
  20    public function render() {
  21      $drequest = $this->getDiffusionRequest();
  22      $current_branch = $drequest->getBranch();
  23      $repository = $drequest->getRepository();
  24  
  25      Javelin::initBehavior('phabricator-tooltips');
  26  
  27      $doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Autoclose');
  28  
  29      $rows = array();
  30      $rowc = array();
  31      foreach ($this->branches as $branch) {
  32        $commit = idx($this->commits, $branch->getCommitIdentifier());
  33        if ($commit) {
  34          $details = $commit->getSummary();
  35          $datetime = phabricator_datetime($commit->getEpoch(), $this->user);
  36        } else {
  37          $datetime = null;
  38          $details = null;
  39        }
  40  
  41        switch ($repository->shouldSkipAutocloseBranch($branch->getShortName())) {
  42          case PhabricatorRepository::BECAUSE_REPOSITORY_IMPORTING:
  43            $icon = 'fa-times bluegrey';
  44            $tip = pht('Repository Importing');
  45            break;
  46          case PhabricatorRepository::BECAUSE_AUTOCLOSE_DISABLED:
  47            $icon = 'fa-times bluegrey';
  48            $tip = pht('Repository Autoclose Disabled');
  49            break;
  50          case PhabricatorRepository::BECAUSE_BRANCH_UNTRACKED:
  51            $icon = 'fa-times bluegrey';
  52            $tip = pht('Branch Untracked');
  53            break;
  54          case PhabricatorRepository::BECAUSE_BRANCH_NOT_AUTOCLOSE:
  55            $icon = 'fa-times bluegrey';
  56            $tip = pht('Branch Autoclose Disabled');
  57            break;
  58          case null:
  59            $icon = 'fa-check bluegrey';
  60            $tip = pht('Autoclose Enabled');
  61            break;
  62          default:
  63            $icon = 'fa-question';
  64            $tip = pht('Status Unknown');
  65            break;
  66        }
  67  
  68        $status_icon = id(new PHUIIconView())
  69          ->setIconFont($icon)
  70          ->addSigil('has-tooltip')
  71          ->setHref($doc_href)
  72          ->setMetadata(
  73            array(
  74              'tip' => $tip,
  75              'size' => 200,
  76            ));
  77  
  78        $rows[] = array(
  79          phutil_tag(
  80            'a',
  81            array(
  82              'href' => $drequest->generateURI(
  83                array(
  84                  'action' => 'history',
  85                  'branch' => $branch->getShortName(),
  86                )),
  87            ),
  88            pht('History')),
  89          phutil_tag(
  90            'a',
  91            array(
  92              'href' => $drequest->generateURI(
  93                array(
  94                  'action' => 'browse',
  95                  'branch' => $branch->getShortName(),
  96                )),
  97            ),
  98            $branch->getShortName()),
  99          self::linkCommit(
 100            $drequest->getRepository(),
 101            $branch->getCommitIdentifier()),
 102          $status_icon,
 103          $datetime,
 104          AphrontTableView::renderSingleDisplayLine($details),
 105        );
 106        if ($branch->getShortName() == $current_branch) {
 107          $rowc[] = 'highlighted';
 108        } else {
 109          $rowc[] = null;
 110        }
 111      }
 112  
 113      $view = new AphrontTableView($rows);
 114      $view->setHeaders(
 115        array(
 116          pht('History'),
 117          pht('Branch'),
 118          pht('Head'),
 119          pht(''),
 120          pht('Modified'),
 121          pht('Details'),
 122        ));
 123      $view->setColumnClasses(
 124        array(
 125          '',
 126          'pri',
 127          '',
 128          '',
 129          '',
 130          'wide',
 131        ));
 132      $view->setRowClasses($rowc);
 133      return $view->render();
 134    }
 135  
 136  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1