diff --git a/src/applications/audit/view/PhabricatorAuditListView.php b/src/applications/audit/view/PhabricatorAuditListView.php index e249406724..f9399e66ab 100644 --- a/src/applications/audit/view/PhabricatorAuditListView.php +++ b/src/applications/audit/view/PhabricatorAuditListView.php @@ -1,182 +1,182 @@ <?php final class PhabricatorAuditListView extends AphrontView { - private $commits; + private $commits = array(); private $header; private $showDrafts; private $noDataString; private $highlightedAudits; public function setNoDataString($no_data_string) { $this->noDataString = $no_data_string; return $this; } public function getNoDataString() { return $this->noDataString; } public function setHeader($header) { $this->header = $header; return $this; } public function getHeader() { return $this->header; } public function setShowDrafts($show_drafts) { $this->showDrafts = $show_drafts; return $this; } public function getShowDrafts() { return $this->showDrafts; } /** * These commits should have both commit data and audit requests attached. */ public function setCommits(array $commits) { assert_instances_of($commits, 'PhabricatorRepositoryCommit'); $this->commits = mpull($commits, null, 'getPHID'); return $this; } public function getCommits() { return $this->commits; } private function getCommitDescription($phid) { if ($this->commits === null) { return pht('(Unknown Commit)'); } $commit = idx($this->commits, $phid); if (!$commit) { return pht('(Unknown Commit)'); } $summary = $commit->getCommitData()->getSummary(); if (strlen($summary)) { return $summary; } // No summary, so either this is still impoting or just has an empty // commit message. if (!$commit->isImported()) { return pht('(Importing Commit...)'); } else { return pht('(Untitled Commit)'); } } public function render() { $list = $this->buildList(); $list->setFlush(true); return $list->render(); } public function buildList() { $viewer = $this->getViewer(); $rowc = array(); $phids = array(); foreach ($this->getCommits() as $commit) { $phids[] = $commit->getPHID(); foreach ($commit->getAudits() as $audit) { $phids[] = $audit->getAuditorPHID(); } $author_phid = $commit->getAuthorPHID(); if ($author_phid) { $phids[] = $author_phid; } } $handles = $viewer->loadHandles($phids); $show_drafts = $this->getShowDrafts(); $draft_icon = id(new PHUIIconView()) ->setIcon('fa-comment yellow') ->addSigil('has-tooltip') ->setMetadata( array( 'tip' => pht('Unsubmitted Comments'), )); $list = new PHUIObjectItemListView(); foreach ($this->commits as $commit) { $commit_phid = $commit->getPHID(); $commit_handle = $handles[$commit_phid]; $committed = null; $commit_name = $commit_handle->getName(); $commit_link = $commit_handle->getURI(); $commit_desc = $this->getCommitDescription($commit_phid); $committed = phabricator_datetime($commit->getEpoch(), $viewer); $status = $commit->getAuditStatus(); $status_text = PhabricatorAuditCommitStatusConstants::getStatusName($status); $status_color = PhabricatorAuditCommitStatusConstants::getStatusColor($status); $status_icon = PhabricatorAuditCommitStatusConstants::getStatusIcon($status); $author_phid = $commit->getAuthorPHID(); if ($author_phid) { $author_name = $handles[$author_phid]->renderLink(); } else { $author_name = $commit->getCommitData()->getAuthorName(); } $item = id(new PHUIObjectItemView()) ->setObjectName($commit_name) ->setHeader($commit_desc) ->setHref($commit_link) ->setDisabled($commit->isUnreachable()) ->addByline(pht('Author: %s', $author_name)) ->addIcon('none', $committed); if ($show_drafts) { if ($commit->getHasDraft($viewer)) { $item->addAttribute($draft_icon); } } $audits = $commit->getAudits(); $auditor_phids = mpull($audits, 'getAuditorPHID'); if ($auditor_phids) { $auditor_list = $handles->newSublist($auditor_phids) ->renderList() ->setAsInline(true); } else { $auditor_list = phutil_tag('em', array(), pht('None')); } $item->addAttribute(pht('Auditors: %s', $auditor_list)); if ($status_color) { $item->setStatusIcon($status_icon.' '.$status_color, $status_text); } $list->addItem($item); } if ($this->noDataString) { $list->setNoDataString($this->noDataString); } if ($this->header) { $list->setHeader($this->header); } return $list; } } diff --git a/src/applications/differential/view/DifferentialRevisionListView.php b/src/applications/differential/view/DifferentialRevisionListView.php index 5aacafbb69..5373192b31 100644 --- a/src/applications/differential/view/DifferentialRevisionListView.php +++ b/src/applications/differential/view/DifferentialRevisionListView.php @@ -1,176 +1,176 @@ <?php /** * Render a table of Differential revisions. */ final class DifferentialRevisionListView extends AphrontView { - private $revisions; + private $revisions = array(); private $handles; private $header; private $noDataString; private $noBox; private $background = null; private $unlandedDependencies = array(); public function setUnlandedDependencies(array $unlanded_dependencies) { $this->unlandedDependencies = $unlanded_dependencies; return $this; } public function getUnlandedDependencies() { return $this->unlandedDependencies; } public function setNoDataString($no_data_string) { $this->noDataString = $no_data_string; return $this; } public function setHeader($header) { $this->header = $header; return $this; } public function setRevisions(array $revisions) { assert_instances_of($revisions, 'DifferentialRevision'); $this->revisions = $revisions; return $this; } public function setNoBox($box) { $this->noBox = $box; return $this; } public function setBackground($background) { $this->background = $background; return $this; } public function getRequiredHandlePHIDs() { $phids = array(); foreach ($this->revisions as $revision) { $phids[] = array($revision->getAuthorPHID()); $phids[] = $revision->getReviewerPHIDs(); } return array_mergev($phids); } public function setHandles(array $handles) { assert_instances_of($handles, 'PhabricatorObjectHandle'); $this->handles = $handles; return $this; } public function render() { $viewer = $this->getViewer(); $this->initBehavior('phabricator-tooltips', array()); $this->requireResource('aphront-tooltip-css'); $list = new PHUIObjectItemListView(); foreach ($this->revisions as $revision) { $item = id(new PHUIObjectItemView()) ->setUser($viewer); $icons = array(); $phid = $revision->getPHID(); $flag = $revision->getFlag($viewer); if ($flag) { $flag_class = PhabricatorFlagColor::getCSSClass($flag->getColor()); $icons['flag'] = phutil_tag( 'div', array( 'class' => 'phabricator-flag-icon '.$flag_class, ), ''); } if ($revision->getHasDraft($viewer)) { $icons['draft'] = true; } $modified = $revision->getDateModified(); if (isset($icons['flag'])) { $item->addHeadIcon($icons['flag']); } $item->setObjectName('D'.$revision->getID()); $item->setHeader($revision->getTitle()); $item->setHref('/D'.$revision->getID()); if (isset($icons['draft'])) { $draft = id(new PHUIIconView()) ->setIcon('fa-comment yellow') ->addSigil('has-tooltip') ->setMetadata( array( 'tip' => pht('Unsubmitted Comments'), )); $item->addAttribute($draft); } // Author $author_handle = $this->handles[$revision->getAuthorPHID()]; $item->addByline(pht('Author: %s', $author_handle->renderLink())); $unlanded = idx($this->unlandedDependencies, $phid); if ($unlanded) { $item->addAttribute( array( id(new PHUIIconView())->setIcon('fa-chain-broken', 'red'), ' ', pht('Open Dependencies'), )); } $reviewers = array(); foreach ($revision->getReviewerPHIDs() as $reviewer) { $reviewers[] = $this->handles[$reviewer]->renderLink(); } if (!$reviewers) { $reviewers = phutil_tag('em', array(), pht('None')); } else { $reviewers = phutil_implode_html(', ', $reviewers); } $item->addAttribute(pht('Reviewers: %s', $reviewers)); $item->setEpoch($revision->getDateModified()); if ($revision->isClosed()) { $item->setDisabled(true); } $item->setStatusIcon( $revision->getStatusIcon(), $revision->getStatusDisplayName()); $list->addItem($item); } $list->setNoDataString($this->noDataString); if ($this->header && !$this->noBox) { $list->setFlush(true); $list = id(new PHUIObjectBoxView()) ->setBackground($this->background) ->setObjectList($list); if ($this->header instanceof PHUIHeaderView) { $list->setHeader($this->header); } else { $list->setHeaderText($this->header); } } else { $list->setHeader($this->header); } return $list; } }