@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

Fix some Releeph jankiness in interacting with the redesign

Summary: Releeph does some really old sketchy stuff in result rendering. Modernize it, remove the holdover/oldschool interface (these were the last two implementors) and make errors a little softer.

Test Plan: Viewed Releeph products and branches.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

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

+153 -166
+2 -9
src/__phutil_library_map__.php
··· 1397 1397 'PhabricatorApplicationSearchEngine' => 'applications/search/engine/PhabricatorApplicationSearchEngine.php', 1398 1398 'PhabricatorApplicationSearchEngineTestCase' => 'applications/search/engine/__tests__/PhabricatorApplicationSearchEngineTestCase.php', 1399 1399 'PhabricatorApplicationSearchResultView' => 'applications/search/view/PhabricatorApplicationSearchResultView.php', 1400 - 'PhabricatorApplicationSearchResultsControllerInterface' => 'applications/search/interface/PhabricatorApplicationSearchResultsControllerInterface.php', 1401 1400 'PhabricatorApplicationStatusView' => 'applications/meta/view/PhabricatorApplicationStatusView.php', 1402 1401 'PhabricatorApplicationTestCase' => 'applications/base/__tests__/PhabricatorApplicationTestCase.php', 1403 1402 'PhabricatorApplicationTransaction' => 'applications/transactions/storage/PhabricatorApplicationTransaction.php', ··· 7256 7255 'ReleephBranchTemplate' => 'Phobject', 7257 7256 'ReleephBranchTransaction' => 'PhabricatorApplicationTransaction', 7258 7257 'ReleephBranchTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 7259 - 'ReleephBranchViewController' => array( 7260 - 'ReleephBranchController', 7261 - 'PhabricatorApplicationSearchResultsControllerInterface', 7262 - ), 7258 + 'ReleephBranchViewController' => 'ReleephBranchController', 7263 7259 'ReleephCommitFinder' => 'Phobject', 7264 7260 'ReleephCommitFinderException' => 'Exception', 7265 7261 'ReleephCommitMessageFieldSpecification' => 'ReleephFieldSpecification', ··· 7293 7289 'ReleephProductSearchEngine' => 'PhabricatorApplicationSearchEngine', 7294 7290 'ReleephProductTransaction' => 'PhabricatorApplicationTransaction', 7295 7291 'ReleephProductTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 7296 - 'ReleephProductViewController' => array( 7297 - 'ReleephProductController', 7298 - 'PhabricatorApplicationSearchResultsControllerInterface', 7299 - ), 7292 + 'ReleephProductViewController' => 'ReleephProductController', 7300 7293 'ReleephProject' => array( 7301 7294 'ReleephDAO', 7302 7295 'PhabricatorApplicationTransactionInterface',
+1 -46
src/applications/releeph/controller/branch/ReleephBranchViewController.php
··· 1 1 <?php 2 2 3 - final class ReleephBranchViewController extends ReleephBranchController 4 - implements PhabricatorApplicationSearchResultsControllerInterface { 3 + final class ReleephBranchViewController extends ReleephBranchController { 5 4 6 5 private $queryKey; 7 6 private $branchID; ··· 37 36 return $this->delegateToController($controller); 38 37 } 39 38 40 - public function renderResultsList( 41 - array $requests, 42 - PhabricatorSavedQuery $query) { 43 - 44 - assert_instances_of($requests, 'ReleephRequest'); 45 - $viewer = $this->getRequest()->getUser(); 46 - 47 - // TODO: This is generally a bit sketchy, but we don't do this kind of 48 - // thing elsewhere at the moment. For the moment it shouldn't be hugely 49 - // costly, and we can batch things later. Generally, this commits fewer 50 - // sins than the old code did. 51 - 52 - $engine = id(new PhabricatorMarkupEngine()) 53 - ->setViewer($viewer); 54 - 55 - $list = array(); 56 - foreach ($requests as $pull) { 57 - $field_list = PhabricatorCustomField::getObjectFields( 58 - $pull, 59 - PhabricatorCustomField::ROLE_VIEW); 60 - 61 - $field_list 62 - ->setViewer($viewer) 63 - ->readFieldsFromStorage($pull); 64 - 65 - foreach ($field_list->getFields() as $field) { 66 - if ($field->shouldMarkup()) { 67 - $field->setMarkupEngine($engine); 68 - } 69 - } 70 - 71 - $list[] = id(new ReleephRequestView()) 72 - ->setUser($viewer) 73 - ->setCustomFields($field_list) 74 - ->setPullRequest($pull) 75 - ->setIsListView(true); 76 - } 77 - 78 - // This is quite sketchy, but the list has not actually rendered yet, so 79 - // this still allows us to batch the markup rendering. 80 - $engine->process(); 81 - 82 - return $list; 83 - } 84 39 85 40 public function buildSideNavView($for_app = false) { 86 41 $user = $this->getRequest()->getUser();
+1 -87
src/applications/releeph/controller/product/ReleephProductViewController.php
··· 1 1 <?php 2 2 3 - final class ReleephProductViewController extends ReleephProductController 4 - implements PhabricatorApplicationSearchResultsControllerInterface { 3 + final class ReleephProductViewController extends ReleephProductController { 5 4 6 5 private $productID; 7 6 private $queryKey; ··· 37 36 ->setNavigation($this->buildSideNavView()); 38 37 39 38 return $this->delegateToController($controller); 40 - } 41 - 42 - public function renderResultsList( 43 - array $branches, 44 - PhabricatorSavedQuery $saved) { 45 - assert_instances_of($branches, 'ReleephBranch'); 46 - 47 - $viewer = $this->getRequest()->getUser(); 48 - 49 - $products = mpull($branches, 'getProduct'); 50 - $repo_phids = mpull($products, 'getRepositoryPHID'); 51 - 52 - $repos = id(new PhabricatorRepositoryQuery()) 53 - ->setViewer($viewer) 54 - ->withPHIDs($repo_phids) 55 - ->execute(); 56 - $repos = mpull($repos, null, 'getPHID'); 57 - 58 - $requests = array(); 59 - if ($branches) { 60 - $requests = id(new ReleephRequestQuery()) 61 - ->setViewer($viewer) 62 - ->withBranchIDs(mpull($branches, 'getID')) 63 - ->withStatus(ReleephRequestQuery::STATUS_OPEN) 64 - ->execute(); 65 - $requests = mgroup($requests, 'getBranchID'); 66 - } 67 - 68 - $list = id(new PHUIObjectItemListView()) 69 - ->setUser($viewer); 70 - foreach ($branches as $branch) { 71 - $diffusion_href = null; 72 - $repo = idx($repos, $branch->getProduct()->getRepositoryPHID()); 73 - if ($repo) { 74 - $drequest = DiffusionRequest::newFromDictionary( 75 - array( 76 - 'user' => $viewer, 77 - 'repository' => $repo, 78 - )); 79 - 80 - $diffusion_href = $drequest->generateURI( 81 - array( 82 - 'action' => 'branch', 83 - 'branch' => $branch->getName(), 84 - )); 85 - } 86 - 87 - $branch_link = $branch->getName(); 88 - if ($diffusion_href) { 89 - $branch_link = phutil_tag( 90 - 'a', 91 - array( 92 - 'href' => $diffusion_href, 93 - ), 94 - $branch_link); 95 - } 96 - 97 - $item = id(new PHUIObjectItemView()) 98 - ->setHeader($branch->getDisplayName()) 99 - ->setHref($this->getApplicationURI('branch/'.$branch->getID().'/')) 100 - ->addAttribute($branch_link); 101 - 102 - if (!$branch->getIsActive()) { 103 - $item->setDisabled(true); 104 - } 105 - 106 - $commit = $branch->getCutPointCommit(); 107 - if ($commit) { 108 - $item->addIcon( 109 - 'none', 110 - phabricator_datetime($commit->getEpoch(), $viewer)); 111 - } 112 - 113 - $open_count = count(idx($requests, $branch->getID(), array())); 114 - if ($open_count) { 115 - $item->setStatusIcon('fa-code-fork orange'); 116 - $item->addIcon( 117 - 'fa-code-fork', 118 - pht('%d Open Pull Request(s)', new PhutilNumber($open_count))); 119 - } 120 - 121 - $list->addItem($item); 122 - } 123 - 124 - return $list; 125 39 } 126 40 127 41 public function buildSideNavView($for_app = false) {
+92
src/applications/releeph/query/ReleephBranchSearchEngine.php
··· 99 99 ); 100 100 } 101 101 102 + protected function renderResultList( 103 + array $branches, 104 + PhabricatorSavedQuery $query, 105 + array $handles) { 106 + 107 + 108 + assert_instances_of($branches, 'ReleephBranch'); 109 + 110 + $viewer = $this->getRequest()->getUser(); 111 + 112 + $products = mpull($branches, 'getProduct'); 113 + $repo_phids = mpull($products, 'getRepositoryPHID'); 114 + 115 + if ($repo_phids) { 116 + $repos = id(new PhabricatorRepositoryQuery()) 117 + ->setViewer($viewer) 118 + ->withPHIDs($repo_phids) 119 + ->execute(); 120 + $repos = mpull($repos, null, 'getPHID'); 121 + } else { 122 + $repos = array(); 123 + } 124 + 125 + $requests = array(); 126 + if ($branches) { 127 + $requests = id(new ReleephRequestQuery()) 128 + ->setViewer($viewer) 129 + ->withBranchIDs(mpull($branches, 'getID')) 130 + ->withStatus(ReleephRequestQuery::STATUS_OPEN) 131 + ->execute(); 132 + $requests = mgroup($requests, 'getBranchID'); 133 + } 134 + 135 + $list = id(new PHUIObjectItemListView()) 136 + ->setUser($viewer); 137 + foreach ($branches as $branch) { 138 + $diffusion_href = null; 139 + $repo = idx($repos, $branch->getProduct()->getRepositoryPHID()); 140 + if ($repo) { 141 + $drequest = DiffusionRequest::newFromDictionary( 142 + array( 143 + 'user' => $viewer, 144 + 'repository' => $repo, 145 + )); 146 + 147 + $diffusion_href = $drequest->generateURI( 148 + array( 149 + 'action' => 'branch', 150 + 'branch' => $branch->getName(), 151 + )); 152 + } 153 + 154 + $branch_link = $branch->getName(); 155 + if ($diffusion_href) { 156 + $branch_link = phutil_tag( 157 + 'a', 158 + array( 159 + 'href' => $diffusion_href, 160 + ), 161 + $branch_link); 162 + } 163 + 164 + $item = id(new PHUIObjectItemView()) 165 + ->setHeader($branch->getDisplayName()) 166 + ->setHref($this->getApplicationURI('branch/'.$branch->getID().'/')) 167 + ->addAttribute($branch_link); 168 + 169 + if (!$branch->getIsActive()) { 170 + $item->setDisabled(true); 171 + } 172 + 173 + $commit = $branch->getCutPointCommit(); 174 + if ($commit) { 175 + $item->addIcon( 176 + 'none', 177 + phabricator_datetime($commit->getEpoch(), $viewer)); 178 + } 179 + 180 + $open_count = count(idx($requests, $branch->getID(), array())); 181 + if ($open_count) { 182 + $item->setStatusIcon('fa-code-fork orange'); 183 + $item->addIcon( 184 + 'fa-code-fork', 185 + pht('%d Open Pull Request(s)', new PhutilNumber($open_count))); 186 + } 187 + 188 + $list->addItem($item); 189 + } 190 + 191 + return id(new PhabricatorApplicationSearchResultView()) 192 + ->setObjectList($list); 193 + } 102 194 }
+46
src/applications/releeph/query/ReleephRequestSearchEngine.php
··· 172 172 } 173 173 } 174 174 175 + protected function renderResultList( 176 + array $requests, 177 + PhabricatorSavedQuery $query, 178 + array $handles) { 179 + 180 + assert_instances_of($requests, 'ReleephRequest'); 181 + $viewer = $this->requireViewer(); 182 + 183 + // TODO: This is generally a bit sketchy, but we don't do this kind of 184 + // thing elsewhere at the moment. For the moment it shouldn't be hugely 185 + // costly, and we can batch things later. Generally, this commits fewer 186 + // sins than the old code did. 187 + 188 + $engine = id(new PhabricatorMarkupEngine()) 189 + ->setViewer($viewer); 190 + 191 + $list = array(); 192 + foreach ($requests as $pull) { 193 + $field_list = PhabricatorCustomField::getObjectFields( 194 + $pull, 195 + PhabricatorCustomField::ROLE_VIEW); 196 + 197 + $field_list 198 + ->setViewer($viewer) 199 + ->readFieldsFromStorage($pull); 200 + 201 + foreach ($field_list->getFields() as $field) { 202 + if ($field->shouldMarkup()) { 203 + $field->setMarkupEngine($engine); 204 + } 205 + } 206 + 207 + $list[] = id(new ReleephRequestView()) 208 + ->setUser($viewer) 209 + ->setCustomFields($field_list) 210 + ->setPullRequest($pull) 211 + ->setIsListView(true); 212 + } 213 + 214 + // This is quite sketchy, but the list has not actually rendered yet, so 215 + // this still allows us to batch the markup rendering. 216 + $engine->process(); 217 + 218 + return id(new PhabricatorApplicationSearchResultView()) 219 + ->setContent($list); 220 + } 175 221 }
+9 -11
src/applications/search/controller/PhabricatorApplicationSearchController.php
··· 217 217 218 218 $objects = $engine->executeQuery($query, $pager); 219 219 220 - // TODO: To support Dashboard panels, rendering is moving into 221 - // SearchEngines. Move it all the way in and then get rid of this. 222 - 223 - $interface = 'PhabricatorApplicationSearchResultsControllerInterface'; 224 - if ($parent instanceof $interface) { 225 - $list = $parent->renderResultsList($objects, $saved_query); 226 - } else { 227 - $engine->setRequest($request); 220 + $engine->setRequest($request); 221 + $list = $engine->renderResults($objects, $saved_query); 228 222 229 - $list = $engine->renderResults( 230 - $objects, 231 - $saved_query); 223 + if (!($list instanceof PhabricatorApplicationSearchResultView)) { 224 + throw new Exception( 225 + pht( 226 + 'SearchEngines must render a "%s" object, but this engine '. 227 + '(of class "%s") rendered something else.', 228 + 'PhabricatorApplicationSearchResultView', 229 + get_class($engine))); 232 230 } 233 231 234 232 if ($list->getActions()) {
+2 -4
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
··· 1038 1038 return array(); 1039 1039 } 1040 1040 1041 - protected function renderResultList( 1041 + abstract protected function renderResultList( 1042 1042 array $objects, 1043 1043 PhabricatorSavedQuery $query, 1044 - array $handles) { 1045 - throw new Exception(pht('Not supported here yet!')); 1046 - } 1044 + array $handles); 1047 1045 1048 1046 1049 1047 /* -( Application Search )------------------------------------------------- */
-9
src/applications/search/interface/PhabricatorApplicationSearchResultsControllerInterface.php
··· 1 - <?php 2 - 3 - interface PhabricatorApplicationSearchResultsControllerInterface { 4 - 5 - public function renderResultsList( 6 - array $items, 7 - PhabricatorSavedQuery $query); 8 - 9 - }