public function render()
 {
     $drequest = $this->getDiffusionRequest();
     $current_branch = $drequest->getBranch();
     $rows = array();
     $rowc = array();
     foreach ($this->branches as $branch) {
         $commit = idx($this->commits, $branch->getHeadCommitIdentifier());
         if ($commit) {
             $details = $commit->getCommitData()->getCommitMessage();
             $details = idx(explode("\n", $details), 0);
             $details = substr($details, 0, 80);
             $datetime = phabricator_datetime($commit->getEpoch(), $this->user);
         } else {
             $datetime = null;
             $details = null;
         }
         $rows[] = array(phutil_render_tag('a', array('href' => $drequest->generateURI(array('action' => 'history', 'branch' => $branch->getName()))), 'History'), phutil_render_tag('a', array('href' => $drequest->generateURI(array('action' => 'browse', 'branch' => $branch->getName()))), phutil_escape_html($branch->getName())), self::linkCommit($drequest->getRepository(), $branch->getHeadCommitIdentifier()), $datetime, AphrontTableView::renderSingleDisplayLine(phutil_escape_html($details)));
         if ($branch->getName() == $current_branch) {
             $rowc[] = 'highlighted';
         } else {
             $rowc[] = null;
         }
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array('History', 'Branch', 'Head', 'Modified', 'Details'));
     $view->setColumnClasses(array('', 'pri', '', '', 'wide'));
     $view->setRowClasses($rowc);
     return $view->render();
 }
 private function renderCommitsTable(PhabricatorRepositoryPushEvent $event, array $commits)
 {
     $viewer = $this->getRequest()->getUser();
     $repository = $event->getRepository();
     $rows = array();
     foreach ($commits as $identifier => $commit) {
         if ($commit) {
             $partial_import = PhabricatorRepositoryCommit::IMPORTED_MESSAGE | PhabricatorRepositoryCommit::IMPORTED_CHANGE;
             if ($commit->isPartiallyImported($partial_import)) {
                 $summary = AphrontTableView::renderSingleDisplayLine($commit->getSummary());
             } else {
                 $summary = phutil_tag('em', array(), pht('Importing...'));
             }
         } else {
             $summary = phutil_tag('em', array(), pht('Discovering...'));
         }
         $commit_name = $repository->formatCommitName($identifier);
         if ($commit) {
             $commit_name = phutil_tag('a', array('href' => '/' . $commit_name), $commit_name);
         }
         $rows[] = array($commit_name, $summary);
     }
     $table = id(new AphrontTableView($rows))->setNoDataString(pht("This push didn't push any new commits."))->setHeaders(array(pht('Commit'), pht('Summary')))->setColumnClasses(array('n', 'wide'));
     return $table;
 }
 public function render()
 {
     $drequest = $this->getDiffusionRequest();
     $handles = $this->handles;
     $rows = array();
     foreach ($this->history as $history) {
         $epoch = $history->getEpoch();
         if ($epoch) {
             $date = date('M j, Y', $epoch);
             $time = date('g:i A', $epoch);
         } else {
             $date = null;
             $time = null;
         }
         $data = $history->getCommitData();
         $author_phid = null;
         if ($data) {
             $author_phid = $data->getCommitDetail('authorPHID');
         }
         if ($author_phid && isset($handles[$author_phid])) {
             $author = $handles[$author_phid]->renderLink();
         } else {
             $author = phutil_escape_html($history->getAuthorName());
         }
         $rows[] = array($this->linkBrowse($drequest->getPath(), array('commit' => $history->getCommitIdentifier())), self::linkCommit($drequest->getRepository(), $history->getCommitIdentifier()), $this->linkChange($history->getChangeType(), $history->getFileType(), null, $history->getCommitIdentifier()), $date, $time, $author, AphrontTableView::renderSingleDisplayLine(phutil_escape_html($history->getSummary())));
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array('Browse', 'Commit', 'Change', 'Date', 'Time', 'Author', 'Details'));
     $view->setColumnClasses(array('', 'n', '', '', 'right', '', 'wide'));
     return $view->render();
 }
 public static function renderLastModifiedColumns(PhabricatorRepository $repository, array $handles, PhabricatorRepositoryCommit $commit = null, PhabricatorRepositoryCommitData $data = null)
 {
     if ($commit) {
         $epoch = $commit->getEpoch();
         $modified = DiffusionView::linkCommit($repository, $commit->getCommitIdentifier());
         $date = date('M j, Y', $epoch);
         $time = date('g:i A', $epoch);
     } else {
         $modified = '';
         $date = '';
         $time = '';
     }
     if ($data) {
         $author_phid = $data->getCommitDetail('authorPHID');
         if ($author_phid && isset($handles[$author_phid])) {
             $author = $handles[$author_phid]->renderLink();
         } else {
             $author = phutil_escape_html($data->getAuthorName());
         }
         $details = AphrontTableView::renderSingleDisplayLine(phutil_escape_html($data->getSummary()));
     } else {
         $author = '';
         $details = '';
     }
     return array('commit' => $modified, 'date' => $date, 'time' => $time, 'author' => $author, 'details' => $details);
 }
 public function render()
 {
     $drequest = $this->getDiffusionRequest();
     $current_branch = $drequest->getBranch();
     $repository = $drequest->getRepository();
     Javelin::initBehavior('phabricator-tooltips');
     $doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Autoclose');
     $rows = array();
     $rowc = array();
     foreach ($this->branches as $branch) {
         $commit = idx($this->commits, $branch->getCommitIdentifier());
         if ($commit) {
             $details = $commit->getSummary();
             $datetime = phabricator_datetime($commit->getEpoch(), $this->user);
         } else {
             $datetime = null;
             $details = null;
         }
         switch ($repository->shouldSkipAutocloseBranch($branch->getShortName())) {
             case PhabricatorRepository::BECAUSE_REPOSITORY_IMPORTING:
                 $icon = 'fa-times bluegrey';
                 $tip = pht('Repository Importing');
                 break;
             case PhabricatorRepository::BECAUSE_AUTOCLOSE_DISABLED:
                 $icon = 'fa-times bluegrey';
                 $tip = pht('Repository Autoclose Disabled');
                 break;
             case PhabricatorRepository::BECAUSE_BRANCH_UNTRACKED:
                 $icon = 'fa-times bluegrey';
                 $tip = pht('Branch Untracked');
                 break;
             case PhabricatorRepository::BECAUSE_BRANCH_NOT_AUTOCLOSE:
                 $icon = 'fa-times bluegrey';
                 $tip = pht('Branch Autoclose Disabled');
                 break;
             case null:
                 $icon = 'fa-check bluegrey';
                 $tip = pht('Autoclose Enabled');
                 break;
             default:
                 $icon = 'fa-question';
                 $tip = pht('Status Unknown');
                 break;
         }
         $status_icon = id(new PHUIIconView())->setIconFont($icon)->addSigil('has-tooltip')->setHref($doc_href)->setMetadata(array('tip' => $tip, 'size' => 200));
         $rows[] = array(phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'history', 'branch' => $branch->getShortName()))), pht('History')), phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'browse', 'branch' => $branch->getShortName()))), $branch->getShortName()), self::linkCommit($drequest->getRepository(), $branch->getCommitIdentifier()), $status_icon, $datetime, AphrontTableView::renderSingleDisplayLine($details));
         if ($branch->getShortName() == $current_branch) {
             $rowc[] = 'highlighted';
         } else {
             $rowc[] = null;
         }
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array(pht('History'), pht('Branch'), pht('Head'), pht(''), pht('Modified'), pht('Details')));
     $view->setColumnClasses(array('', 'pri', '', '', '', 'wide'));
     $view->setRowClasses($rowc);
     return $view->render();
 }
 protected function newTableRow($phid, $object, $trace)
 {
     $viewer = $this->getViewer();
     if ($object) {
         $status_icon = $object->getStatusIcon();
         $status_name = $object->getStatusDisplayName();
         $status = array(id(new PHUIIconView())->setIcon($status_icon), ' ', $status_name);
         $author = $viewer->renderHandle($object->getAuthorPHID());
         $link = phutil_tag('a', array('href' => $object->getURI()), $object->getTitle());
         $link = array($object->getMonogram(), ' ', $link);
     } else {
         $status = null;
         $author = null;
         $link = $viewer->renderHandle($phid);
     }
     $link = AphrontTableView::renderSingleDisplayLine($link);
     return array($trace, $status, $author, $link);
 }
 private function renderColumns(DiffusionRequest $drequest, array $handles, PhabricatorRepositoryCommit $commit = null, $lint = null)
 {
     assert_instances_of($handles, 'PhabricatorObjectHandle');
     $viewer = $this->getRequest()->getUser();
     if ($commit) {
         $epoch = $commit->getEpoch();
         $modified = DiffusionView::linkCommit($drequest->getRepository(), $commit->getCommitIdentifier());
         $date = phabricator_date($epoch, $viewer);
         $time = phabricator_time($epoch, $viewer);
     } else {
         $modified = '';
         $date = '';
         $time = '';
     }
     $data = $commit->getCommitData();
     if ($data) {
         $author_phid = $data->getCommitDetail('authorPHID');
         if ($author_phid && isset($handles[$author_phid])) {
             $author = $handles[$author_phid]->renderLink();
         } else {
             $author = DiffusionView::renderName($data->getAuthorName());
         }
         $committer = $data->getCommitDetail('committer');
         if ($committer) {
             $committer_phid = $data->getCommitDetail('committerPHID');
             if ($committer_phid && isset($handles[$committer_phid])) {
                 $committer = $handles[$committer_phid]->renderLink();
             } else {
                 $committer = DiffusionView::renderName($committer);
             }
             if ($author != $committer) {
                 $author = hsprintf('%s/%s', $author, $committer);
             }
         }
         $details = AphrontTableView::renderSingleDisplayLine($data->getSummary());
     } else {
         $author = '';
         $details = '';
     }
     $return = array('commit' => $modified, 'date' => $date, 'time' => $time, 'author' => $author, 'details' => $details);
     if ($lint !== null) {
         $return['lint'] = phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'lint', 'lint' => null))), number_format($lint));
     }
     // The client treats these results as markup, so make sure they have been
     // escaped correctly.
     foreach ($return as $key => $value) {
         $return[$key] = hsprintf('%s', $value);
     }
     return $return;
 }
 public function render()
 {
     $drequest = $this->getDiffusionRequest();
     $viewer = $this->getUser();
     $buildables = $this->loadBuildables(mpull($this->history, 'getCommit'));
     $has_any_build = false;
     $show_revisions = PhabricatorApplication::isClassInstalledForViewer('PhabricatorDifferentialApplication', $viewer);
     $handles = $viewer->loadHandles($this->getRequiredHandlePHIDs());
     $graph = null;
     if ($this->parents) {
         $graph = $this->renderGraph();
     }
     $show_builds = PhabricatorApplication::isClassInstalledForViewer('PhabricatorHarbormasterApplication', $this->getUser());
     $rows = array();
     $ii = 0;
     foreach ($this->history as $history) {
         $epoch = $history->getEpoch();
         if ($epoch) {
             $committed = phabricator_datetime($epoch, $viewer);
         } else {
             $committed = null;
         }
         $data = $history->getCommitData();
         $author_phid = $committer = $committer_phid = null;
         if ($data) {
             $author_phid = $data->getCommitDetail('authorPHID');
             $committer_phid = $data->getCommitDetail('committerPHID');
             $committer = $data->getCommitDetail('committer');
         }
         if ($author_phid && isset($handles[$author_phid])) {
             $author = $handles[$author_phid]->renderLink();
         } else {
             $author = self::renderName($history->getAuthorName());
         }
         $different_committer = false;
         if ($committer_phid) {
             $different_committer = $committer_phid != $author_phid;
         } else {
             if ($committer != '') {
                 $different_committer = $committer != $history->getAuthorName();
             }
         }
         if ($different_committer) {
             if ($committer_phid && isset($handles[$committer_phid])) {
                 $committer = $handles[$committer_phid]->renderLink();
             } else {
                 $committer = self::renderName($committer);
             }
             $author = hsprintf('%s/%s', $author, $committer);
         }
         // We can show details once the message and change have been imported.
         $partial_import = PhabricatorRepositoryCommit::IMPORTED_MESSAGE | PhabricatorRepositoryCommit::IMPORTED_CHANGE;
         $commit = $history->getCommit();
         if ($commit && $commit->isPartiallyImported($partial_import) && $data) {
             $summary = AphrontTableView::renderSingleDisplayLine($history->getSummary());
         } else {
             $summary = phutil_tag('em', array(), pht("Importing…"));
         }
         $build = null;
         if ($show_builds) {
             $buildable = idx($buildables, $commit->getPHID());
             if ($buildable !== null) {
                 $build = $this->renderBuildable($buildable);
                 $has_any_build = true;
             }
         }
         $browse = $this->linkBrowse($history->getPath(), array('commit' => $history->getCommitIdentifier(), 'branch' => $drequest->getBranch(), 'type' => $history->getFileType()));
         $rows[] = array($graph ? $graph[$ii++] : null, $browse, self::linkCommit($drequest->getRepository(), $history->getCommitIdentifier()), $build, $commit ? self::linkRevision(idx($this->revisions, $commit->getPHID())) : null, $author, $summary, $committed);
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array(null, null, pht('Commit'), null, null, pht('Author/Committer'), pht('Details'), pht('Committed')));
     $view->setColumnClasses(array('threads', 'nudgeright', '', 'icon', '', '', 'wide', ''));
     $view->setColumnVisibility(array($graph ? true : false, true, true, $has_any_build, $show_revisions));
     $view->setDeviceVisibility(array($graph ? true : false, true, true, true, true, false, true, false));
     return $view->render();
 }
 public function render()
 {
     $drequest = $this->getDiffusionRequest();
     $handles = $this->handles;
     $graph = null;
     if ($this->parents) {
         $graph = $this->renderGraph();
     }
     $show_builds = PhabricatorApplication::isClassInstalledForViewer('PhabricatorHarbormasterApplication', $this->getUser());
     $rows = array();
     $ii = 0;
     foreach ($this->history as $history) {
         $epoch = $history->getEpoch();
         if ($epoch) {
             $date = phabricator_date($epoch, $this->user);
             $time = phabricator_time($epoch, $this->user);
         } else {
             $date = null;
             $time = null;
         }
         $data = $history->getCommitData();
         $author_phid = $committer = $committer_phid = null;
         if ($data) {
             $author_phid = $data->getCommitDetail('authorPHID');
             $committer_phid = $data->getCommitDetail('committerPHID');
             $committer = $data->getCommitDetail('committer');
         }
         if ($author_phid && isset($handles[$author_phid])) {
             $author = $handles[$author_phid]->renderLink();
         } else {
             $author = self::renderName($history->getAuthorName());
         }
         $different_committer = false;
         if ($committer_phid) {
             $different_committer = $committer_phid != $author_phid;
         } else {
             if ($committer != '') {
                 $different_committer = $committer != $history->getAuthorName();
             }
         }
         if ($different_committer) {
             if ($committer_phid && isset($handles[$committer_phid])) {
                 $committer = $handles[$committer_phid]->renderLink();
             } else {
                 $committer = self::renderName($committer);
             }
             $author = hsprintf('%s/%s', $author, $committer);
         }
         // We can show details once the message and change have been imported.
         $partial_import = PhabricatorRepositoryCommit::IMPORTED_MESSAGE | PhabricatorRepositoryCommit::IMPORTED_CHANGE;
         $commit = $history->getCommit();
         if ($commit && $commit->isPartiallyImported($partial_import) && $data) {
             $summary = AphrontTableView::renderSingleDisplayLine($history->getSummary());
         } else {
             $summary = phutil_tag('em', array(), "Importing…");
         }
         $build = null;
         if ($show_builds) {
             $buildable_lookup = $this->loadBuildablesOnDemand();
             $buildable = idx($buildable_lookup, $commit->getPHID());
             if ($buildable !== null) {
                 $icon = HarbormasterBuildable::getBuildableStatusIcon($buildable->getBuildableStatus());
                 $color = HarbormasterBuildable::getBuildableStatusColor($buildable->getBuildableStatus());
                 $name = HarbormasterBuildable::getBuildableStatusName($buildable->getBuildableStatus());
                 $icon_view = id(new PHUIIconView())->setIconFont($icon . ' ' . $color);
                 $tooltip_view = javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => $name)), $icon_view);
                 Javelin::initBehavior('phabricator-tooltips');
                 $href_view = phutil_tag('a', array('href' => '/' . $buildable->getMonogram()), $tooltip_view);
                 $build = $href_view;
                 $has_any_build = true;
             }
         }
         $rows[] = array($graph ? $graph[$ii++] : null, self::linkCommit($drequest->getRepository(), $history->getCommitIdentifier()), $build, $commit ? self::linkRevision(idx($this->revisions, $commit->getPHID())) : null, $author, $summary, $date, $time);
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array('', pht('Commit'), '', pht('Revision'), pht('Author/Committer'), pht('Details'), pht('Date'), pht('Time')));
     $view->setColumnClasses(array('threads', 'n', 'icon', 'n', '', 'wide', '', 'right'));
     $view->setColumnVisibility(array($graph ? true : false));
     $view->setDeviceVisibility(array($graph ? true : false, true, true, true, false, true, false, false));
     return $view->render();
 }
 public function render()
 {
     $drequest = $this->getDiffusionRequest();
     $handles = $this->handles;
     $graph = null;
     if ($this->parents) {
         $graph = $this->renderGraph();
     }
     $rows = array();
     $ii = 0;
     foreach ($this->history as $history) {
         $epoch = $history->getEpoch();
         if ($epoch) {
             $date = date('M j, Y', $epoch);
             $time = date('g:i A', $epoch);
         } else {
             $date = null;
             $time = null;
         }
         $data = $history->getCommitData();
         $author_phid = $committer = $committer_phid = null;
         if ($data) {
             $author_phid = $data->getCommitDetail('authorPHID');
             $committer_phid = $data->getCommitDetail('committerPHID');
             $committer = $data->getCommitDetail('committer');
         }
         if ($author_phid && isset($handles[$author_phid])) {
             $author = $handles[$author_phid]->renderLink();
         } else {
             $author = phutil_escape_html($history->getAuthorName());
         }
         $different_committer = false;
         if ($committer_phid) {
             $different_committer = $committer_phid != $author_phid;
         } else {
             if ($committer != '') {
                 $different_committer = $committer != $history->getAuthorName();
             }
         }
         if ($different_committer) {
             if ($committer_phid && isset($handles[$committer_phid])) {
                 $committer = $handles[$committer_phid]->renderLink();
             } else {
                 $committer = phutil_escape_html($committer);
             }
             $author .= '/' . $committer;
         }
         $commit = $history->getCommit();
         if ($commit && !$commit->getIsUnparsed() && $data) {
             $change = $this->linkChange($history->getChangeType(), $history->getFileType(), $path = null, $history->getCommitIdentifier());
         } else {
             $change = "<em>Importing…</em>";
         }
         $rows[] = array($this->linkBrowse($drequest->getPath(), array('commit' => $history->getCommitIdentifier())), $graph ? $graph[$ii++] : null, self::linkCommit($drequest->getRepository(), $history->getCommitIdentifier()), $commit ? self::linkRevision(idx($this->revisions, $commit->getPHID())) : null, $change, $date, $time, $author, AphrontTableView::renderSingleDisplayLine(phutil_escape_html($history->getSummary())));
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array('Browse', '', 'Commit', 'Revision', 'Change', 'Date', 'Time', 'Author/Committer', 'Details'));
     $view->setColumnClasses(array('', 'threads', 'n', 'n', '', '', 'right', '', 'wide'));
     $view->setColumnVisibility(array(true, $graph ? true : false));
     return $view->render();
 }
 public function render()
 {
     $drequest = $this->getDiffusionRequest();
     $current_branch = $drequest->getBranch();
     $repository = $drequest->getRepository();
     $commits = $this->commits;
     $viewer = $this->getUser();
     $buildables = $this->loadBuildables($commits);
     $have_builds = false;
     $can_close_branches = $repository->isHg();
     Javelin::initBehavior('phabricator-tooltips');
     $doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Autoclose');
     $rows = array();
     $rowc = array();
     foreach ($this->branches as $branch) {
         $commit = idx($commits, $branch->getCommitIdentifier());
         if ($commit) {
             $details = $commit->getSummary();
             $datetime = $viewer->formatShortDateTime($commit->getEpoch());
             $buildable = idx($buildables, $commit->getPHID());
             if ($buildable) {
                 $build_status = $this->renderBuildable($buildable);
                 $have_builds = true;
             } else {
                 $build_status = null;
             }
         } else {
             $datetime = null;
             $details = null;
             $build_status = null;
         }
         switch ($repository->shouldSkipAutocloseBranch($branch->getShortName())) {
             case PhabricatorRepository::BECAUSE_REPOSITORY_IMPORTING:
                 $icon = 'fa-times bluegrey';
                 $tip = pht('Repository Importing');
                 break;
             case PhabricatorRepository::BECAUSE_AUTOCLOSE_DISABLED:
                 $icon = 'fa-times bluegrey';
                 $tip = pht('Repository Autoclose Disabled');
                 break;
             case PhabricatorRepository::BECAUSE_BRANCH_UNTRACKED:
                 $icon = 'fa-times bluegrey';
                 $tip = pht('Branch Untracked');
                 break;
             case PhabricatorRepository::BECAUSE_BRANCH_NOT_AUTOCLOSE:
                 $icon = 'fa-times bluegrey';
                 $tip = pht('Branch Autoclose Disabled');
                 break;
             case null:
                 $icon = 'fa-check bluegrey';
                 $tip = pht('Autoclose Enabled');
                 break;
             default:
                 $icon = 'fa-question';
                 $tip = pht('Status Unknown');
                 break;
         }
         $status_icon = id(new PHUIIconView())->setIcon($icon)->addSigil('has-tooltip')->setHref($doc_href)->setMetadata(array('tip' => $tip, 'size' => 200));
         $fields = $branch->getRawFields();
         $closed = idx($fields, 'closed');
         if ($closed) {
             $status = pht('Closed');
         } else {
             $status = pht('Open');
         }
         $rows[] = array($this->linkBranchHistory($branch->getShortName()), phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'browse', 'branch' => $branch->getShortName()))), $branch->getShortName()), self::linkCommit($drequest->getRepository(), $branch->getCommitIdentifier()), $build_status, $status, AphrontTableView::renderSingleDisplayLine($details), $status_icon, $datetime);
         if ($branch->getShortName() == $current_branch) {
             $rowc[] = 'highlighted';
         } else {
             $rowc[] = null;
         }
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array(null, pht('Branch'), pht('Head'), null, pht('State'), pht('Details'), null, pht('Committed')));
     $view->setColumnClasses(array('', 'pri', '', 'icon', '', 'wide', '', 'right'));
     $view->setColumnVisibility(array(true, true, true, $have_builds, $can_close_branches));
     $view->setRowClasses($rowc);
     return $view->render();
 }