@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

Remove "PhabricatorAuditListView"

Summary: Ref T13552. Remove yet another way to render a list of commits, and unify it with "CommitGraphView".

Test Plan:
- Viewed commit search results.
- Viewed owners package detail page.

Maniphest Tasks: T13552

Differential Revision: https://secure.phabricator.com/D21415

+28 -202
-2
src/__phutil_library_map__.php
··· 2274 2274 'PhabricatorAuditController' => 'applications/audit/controller/PhabricatorAuditController.php', 2275 2275 'PhabricatorAuditEditor' => 'applications/audit/editor/PhabricatorAuditEditor.php', 2276 2276 'PhabricatorAuditInlineComment' => 'applications/audit/storage/PhabricatorAuditInlineComment.php', 2277 - 'PhabricatorAuditListView' => 'applications/audit/view/PhabricatorAuditListView.php', 2278 2277 'PhabricatorAuditMailReceiver' => 'applications/audit/mail/PhabricatorAuditMailReceiver.php', 2279 2278 'PhabricatorAuditManagementDeleteWorkflow' => 'applications/audit/management/PhabricatorAuditManagementDeleteWorkflow.php', 2280 2279 'PhabricatorAuditManagementWorkflow' => 'applications/audit/management/PhabricatorAuditManagementWorkflow.php', ··· 8586 8585 'PhabricatorAuditController' => 'PhabricatorController', 8587 8586 'PhabricatorAuditEditor' => 'PhabricatorApplicationTransactionEditor', 8588 8587 'PhabricatorAuditInlineComment' => 'PhabricatorInlineComment', 8589 - 'PhabricatorAuditListView' => 'AphrontView', 8590 8588 'PhabricatorAuditMailReceiver' => 'PhabricatorObjectMailReceiver', 8591 8589 'PhabricatorAuditManagementDeleteWorkflow' => 'PhabricatorAuditManagementWorkflow', 8592 8590 'PhabricatorAuditManagementWorkflow' => 'PhabricatorManagementWorkflow',
+15 -22
src/applications/audit/query/PhabricatorCommitSearchEngine.php
··· 221 221 222 222 $bucket = $this->getResultBucket($query); 223 223 224 - $template = id(new PhabricatorAuditListView()) 225 - ->setViewer($viewer) 226 - ->setShowDrafts(true); 224 + $template = id(new DiffusionCommitGraphView()) 225 + ->setViewer($viewer); 227 226 228 227 $views = array(); 229 228 if ($bucket) { ··· 235 234 foreach ($groups as $group) { 236 235 // Don't show groups in Dashboard Panels 237 236 if ($group->getObjects() || !$this->isPanelContext()) { 238 - $views[] = id(clone $template) 237 + $item_list = id(clone $template) 238 + ->setCommits($group->getObjects()) 239 + ->newObjectItemListView(); 240 + 241 + $views[] = $item_list 239 242 ->setHeader($group->getName()) 240 - ->setNoDataString($group->getNoDataString()) 241 - ->setCommits($group->getObjects()); 243 + ->setNoDataString($group->getNoDataString()); 242 244 } 243 245 } 244 246 } catch (Exception $ex) { 245 247 $this->addError($ex->getMessage()); 246 248 } 247 - } else { 248 - $views[] = id(clone $template) 249 - ->setCommits($commits) 250 - ->setNoDataString(pht('No commits found.')); 251 249 } 252 250 253 251 if (!$views) { 254 - $views[] = id(new PhabricatorAuditListView()) 255 - ->setViewer($viewer) 256 - ->setNoDataString(pht('No commits found.')); 257 - } 252 + $item_list = id(clone $template) 253 + ->setCommits($commits) 254 + ->newObjectItemListView(); 258 255 259 - if (count($views) == 1) { 260 - $list = head($views)->buildList(); 261 - } else { 262 - $list = $views; 256 + $views[] = $item_list 257 + ->setNoDataString(pht('No commits found.')); 263 258 } 264 259 265 - $result = new PhabricatorApplicationSearchResultView(); 266 - $result->setContent($list); 267 - 268 - return $result; 260 + return id(new PhabricatorApplicationSearchResultView()) 261 + ->setContent($views); 269 262 } 270 263 271 264 protected function getNewUserBody() {
-171
src/applications/audit/view/PhabricatorAuditListView.php
··· 1 - <?php 2 - 3 - final class PhabricatorAuditListView extends AphrontView { 4 - 5 - private $commits = array(); 6 - private $header; 7 - private $showDrafts; 8 - private $noDataString; 9 - private $highlightedAudits; 10 - 11 - public function setNoDataString($no_data_string) { 12 - $this->noDataString = $no_data_string; 13 - return $this; 14 - } 15 - 16 - public function getNoDataString() { 17 - return $this->noDataString; 18 - } 19 - 20 - public function setHeader($header) { 21 - $this->header = $header; 22 - return $this; 23 - } 24 - 25 - public function getHeader() { 26 - return $this->header; 27 - } 28 - 29 - public function setShowDrafts($show_drafts) { 30 - $this->showDrafts = $show_drafts; 31 - return $this; 32 - } 33 - 34 - public function getShowDrafts() { 35 - return $this->showDrafts; 36 - } 37 - 38 - /** 39 - * These commits should have both commit data and audit requests attached. 40 - */ 41 - public function setCommits(array $commits) { 42 - assert_instances_of($commits, 'PhabricatorRepositoryCommit'); 43 - $this->commits = mpull($commits, null, 'getPHID'); 44 - return $this; 45 - } 46 - 47 - public function getCommits() { 48 - return $this->commits; 49 - } 50 - 51 - private function getCommitDescription($phid) { 52 - if ($this->commits === null) { 53 - return pht('(Unknown Commit)'); 54 - } 55 - 56 - $commit = idx($this->commits, $phid); 57 - if (!$commit) { 58 - return pht('(Unknown Commit)'); 59 - } 60 - 61 - $summary = $commit->getCommitData()->getSummary(); 62 - if (strlen($summary)) { 63 - return $summary; 64 - } 65 - 66 - // No summary, so either this is still importing or just has an empty 67 - // commit message. 68 - 69 - if (!$commit->isImported()) { 70 - return pht('(Importing Commit...)'); 71 - } else { 72 - return pht('(Untitled Commit)'); 73 - } 74 - } 75 - 76 - public function render() { 77 - $list = $this->buildList(); 78 - $list->setFlush(true); 79 - return $list->render(); 80 - } 81 - 82 - public function buildList() { 83 - $viewer = $this->getViewer(); 84 - $rowc = array(); 85 - 86 - $phids = array(); 87 - foreach ($this->getCommits() as $commit) { 88 - $phids[] = $commit->getPHID(); 89 - 90 - foreach ($commit->getAudits() as $audit) { 91 - $phids[] = $audit->getAuditorPHID(); 92 - } 93 - } 94 - 95 - $handles = $viewer->loadHandles($phids); 96 - 97 - $show_drafts = $this->getShowDrafts(); 98 - 99 - $draft_icon = id(new PHUIIconView()) 100 - ->setIcon('fa-comment yellow') 101 - ->addSigil('has-tooltip') 102 - ->setMetadata( 103 - array( 104 - 'tip' => pht('Unsubmitted Comments'), 105 - )); 106 - 107 - $list = new PHUIObjectItemListView(); 108 - foreach ($this->commits as $commit) { 109 - $commit_phid = $commit->getPHID(); 110 - $commit_handle = $handles[$commit_phid]; 111 - $committed = null; 112 - 113 - $commit_name = $commit_handle->getName(); 114 - $commit_link = $commit_handle->getURI(); 115 - $commit_desc = $this->getCommitDescription($commit_phid); 116 - $committed = phabricator_datetime($commit->getEpoch(), $viewer); 117 - 118 - $status = $commit->getAuditStatusObject(); 119 - 120 - $status_text = $status->getName(); 121 - $status_color = $status->getColor(); 122 - $status_icon = $status->getIcon(); 123 - 124 - $item = id(new PHUIObjectItemView()) 125 - ->setObjectName($commit_name) 126 - ->setHeader($commit_desc) 127 - ->setHref($commit_link) 128 - ->setDisabled($commit->isUnreachable()) 129 - ->addIcon('none', $committed); 130 - 131 - $author_name = $commit->newCommitAuthorView($viewer); 132 - if ($author_name) { 133 - $item->addByline(pht('Author: %s', $author_name)); 134 - } 135 - 136 - if ($show_drafts) { 137 - if ($commit->getHasDraft($viewer)) { 138 - $item->addAttribute($draft_icon); 139 - } 140 - } 141 - 142 - $audits = $commit->getAudits(); 143 - $auditor_phids = mpull($audits, 'getAuditorPHID'); 144 - if ($auditor_phids) { 145 - $auditor_list = $handles->newSublist($auditor_phids) 146 - ->renderList() 147 - ->setAsInline(true); 148 - } else { 149 - $auditor_list = phutil_tag('em', array(), pht('None')); 150 - } 151 - $item->addAttribute(pht('Auditors: %s', $auditor_list)); 152 - 153 - if ($status_color) { 154 - $item->setStatusIcon($status_icon.' '.$status_color, $status_text); 155 - } 156 - 157 - $list->addItem($item); 158 - } 159 - 160 - if ($this->noDataString) { 161 - $list->setNoDataString($this->noDataString); 162 - } 163 - 164 - if ($this->header) { 165 - $list->setHeader($this->header); 166 - } 167 - 168 - return $list; 169 - } 170 - 171 - }
+13 -7
src/applications/owners/controller/PhabricatorOwnersDetailController.php
··· 82 82 )) 83 83 ->needCommitData(true) 84 84 ->needAuditRequests(true) 85 + ->needIdentities(true) 85 86 ->setLimit(10) 86 87 ->execute(); 87 - $view = id(new PhabricatorAuditListView()) 88 - ->setUser($viewer) 89 - ->setNoDataString(pht('This package has no open problem commits.')) 90 - ->setCommits($attention_commits); 88 + $view = id(new DiffusionCommitGraphView()) 89 + ->setViewer($viewer) 90 + ->setCommits($attention_commits) 91 + ->newObjectItemListView(); 92 + 93 + $view->setNoDataString(pht('This package has no open problem commits.')); 91 94 92 95 $commit_views[] = array( 93 96 'view' => $view, ··· 105 108 ->withPackagePHIDs(array($package->getPHID())) 106 109 ->needCommitData(true) 107 110 ->needAuditRequests(true) 111 + ->needIdentities(true) 108 112 ->setLimit(25) 109 113 ->execute(); 110 114 111 - $view = id(new PhabricatorAuditListView()) 112 - ->setUser($viewer) 115 + $view = id(new DiffusionCommitGraphView()) 116 + ->setViewer($viewer) 113 117 ->setCommits($all_commits) 114 - ->setNoDataString(pht('No commits in this package.')); 118 + ->newObjectItemListView(); 119 + 120 + $view->setNoDataString(pht('No commits in this package.')); 115 121 116 122 $commit_views[] = array( 117 123 'view' => $view,