@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Modernize tag and branch controllers in Diffusion

Summary: Ref T4245. Prepares these controllers to accept alternate identifers, plus minor spacing and layout fixes.

Test Plan: Viewed tags, viewed branches.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4245

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

+63 -48
+1 -1
src/applications/diffusion/application/PhabricatorDiffusionApplication.php
··· 64 64 '(?:query/(?P<queryKey>[^/]+)/)?' => 'DiffusionPushLogListController', 65 65 'view/(?P<id>\d+)/' => 'DiffusionPushEventViewController', 66 66 ), 67 - '(?P<callsign>[A-Z]+)/' => array( 67 + '(?P<repositoryCallsign>(?P<callsign>[A-Z]+))/' => array( 68 68 '' => 'DiffusionRepositoryController', 69 69 70 70 'repository/(?P<dblob>.*)' => 'DiffusionRepositoryController',
+21 -16
src/applications/diffusion/controller/DiffusionBranchTableController.php
··· 6 6 return true; 7 7 } 8 8 9 - protected function processDiffusionRequest(AphrontRequest $request) { 9 + public function handleRequest(AphrontRequest $request) { 10 + $response = $this->loadDiffusionContext(); 11 + if ($response) { 12 + return $response; 13 + } 14 + 15 + $viewer = $this->getViewer(); 10 16 $drequest = $this->getDiffusionRequest(); 11 - $viewer = $request->getUser(); 12 - 13 17 $repository = $drequest->getRepository(); 14 18 15 - $pager = new PHUIPagerView(); 16 - $pager->setURI($request->getRequestURI(), 'offset'); 17 - $pager->setOffset($request->getInt('offset')); 19 + $pager = id(new PHUIPagerView()) 20 + ->readFromRequest($request); 18 21 19 22 // TODO: Add support for branches that contain commit 20 23 $branches = $this->callConduitWithDiffusionRequest( ··· 57 60 'branches' => true, 58 61 )); 59 62 60 - return $this->buildApplicationPage( 61 - array( 62 - $crumbs, 63 - $content, 64 - $pager, 65 - ), 66 - array( 67 - 'title' => array( 63 + $pager_box = $this->renderTablePagerBox($pager); 64 + 65 + return $this->newPage() 66 + ->setTitle( 67 + array( 68 68 pht('Branches'), 69 69 $repository->getDisplayName(), 70 - ), 71 - )); 70 + )) 71 + ->setCrumbs($crumbs) 72 + ->appendChild( 73 + array( 74 + $content, 75 + $pager_box, 76 + )); 72 77 } 73 78 74 79 }
+13 -14
src/applications/diffusion/controller/DiffusionController.php
··· 61 61 $identifier = (int)$request->getURIData('repositoryID'); 62 62 } 63 63 64 - $blob = $request->getURIData('dblob'); 65 - if (strlen($blob)) { 66 - $parsed = DiffusionRequest::parseRequestBlob($blob); 67 - } else { 68 - $parsed = array( 69 - 'commit' => $request->getURIData('commit'), 70 - 'path' => $request->getURIData('path'), 71 - 'line' => $request->getURIData('line'), 72 - 'branch' => $request->getURIData('branch'), 73 - 'lint' => $request->getStr('lint'), 74 - ); 75 - } 76 - 77 64 $params = array( 78 65 'repository' => $identifier, 79 66 'user' => $viewer, 80 - ) + $parsed; 67 + 'blob' => $request->getURIData('dblob'), 68 + 'commit' => $request->getURIData('commit'), 69 + 'path' => $request->getURIData('path'), 70 + 'line' => $request->getURIData('line'), 71 + 'branch' => $request->getURIData('branch'), 72 + 'lint' => $request->getStr('lint'), 73 + ); 81 74 82 75 $drequest = DiffusionRequest::newFromDictionary($params); 83 76 ··· 284 277 ->setSeverity(PHUIInfoView::SEVERITY_WARNING) 285 278 ->setTitle($title) 286 279 ->appendChild($body); 280 + } 281 + 282 + protected function renderTablePagerBox(PHUIPagerView $pager) { 283 + return id(new PHUIBoxView()) 284 + ->addMargin(PHUI::MARGIN_LARGE) 285 + ->appendChild($pager); 287 286 } 288 287 289 288 }
+22 -17
src/applications/diffusion/controller/DiffusionTagListController.php
··· 6 6 return true; 7 7 } 8 8 9 - protected function processDiffusionRequest(AphrontRequest $request) { 9 + public function handleRequest(AphrontRequest $request) { 10 + $response = $this->loadDiffusionContext(); 11 + if ($response) { 12 + return $response; 13 + } 14 + 15 + $viewer = $this->getViewer(); 10 16 $drequest = $this->getDiffusionRequest(); 11 - $viewer = $request->getUser(); 12 - 13 17 $repository = $drequest->getRepository(); 14 18 15 - $pager = new PHUIPagerView(); 16 - $pager->setURI($request->getRequestURI(), 'offset'); 17 - $pager->setOffset($request->getInt('offset')); 19 + $pager = id(new PHUIPagerView()) 20 + ->readFromRequest($request); 18 21 19 22 $params = array( 20 23 'limit' => $pager->getPageSize() + 1, 21 24 'offset' => $pager->getOffset(), 22 25 ); 23 26 24 - if ($drequest->getSymbolicCommit()) { 27 + if (strlen($drequest->getSymbolicCommit())) { 25 28 $is_commit = true; 26 29 $params['commit'] = $drequest->getSymbolicCommit(); 27 30 } else { ··· 79 82 'commit' => $drequest->getSymbolicCommit(), 80 83 )); 81 84 82 - return $this->buildApplicationPage( 83 - array( 84 - $crumbs, 85 - $content, 86 - $pager, 87 - ), 88 - array( 89 - 'title' => array( 85 + $pager_box = $this->renderTablePagerBox($pager); 86 + 87 + return $this->newPage() 88 + ->setTitle( 89 + array( 90 90 pht('Tags'), 91 91 $repository->getDisplayName(), 92 - ), 93 - )); 92 + )) 93 + ->setCrumbs($crumbs) 94 + ->appendChild( 95 + array( 96 + $content, 97 + $pager_box, 98 + )); 94 99 } 95 100 96 101 }
+6
src/applications/diffusion/request/DiffusionRequest.php
··· 225 225 * @task new 226 226 */ 227 227 final private function initializeFromDictionary(array $data) { 228 + $blob = idx($data, 'blob'); 229 + if (strlen($blob)) { 230 + $blob = self::parseRequestBlob($blob, $this->supportsBranches()); 231 + $data = $blob + $data; 232 + } 233 + 228 234 $this->path = idx($data, 'path'); 229 235 $this->line = idx($data, 'line'); 230 236 $this->initFromConduit = idx($data, 'initFromConduit', true);