@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.

Add a branch selector to Diffusion

Summary: Fixes T12931. Adds a branch selector that's always visible if the repo has commits.

Test Plan:
Test a plain hg, svn, git repository. Test setting a bad default branch. Test a good default branch. Test on desktop, mobile layouts.

{F5058061}

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12931

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

+147 -16
+5 -5
resources/celerity/map.php
··· 9 9 'names' => array( 10 10 'conpherence.pkg.css' => 'e68cf1fa', 11 11 'conpherence.pkg.js' => 'b5b51108', 12 - 'core.pkg.css' => 'f1c7630f', 12 + 'core.pkg.css' => 'c0a7ecfd', 13 13 'core.pkg.js' => '5d80e0db', 14 14 'darkconsole.pkg.js' => '1f9a31bc', 15 15 'differential.pkg.css' => '45951e9e', ··· 75 75 'rsrc/css/application/diffusion/diffusion-readme.css' => '419dd5b6', 76 76 'rsrc/css/application/diffusion/diffusion-repository.css' => 'ee6f20ec', 77 77 'rsrc/css/application/diffusion/diffusion-source.css' => '750add59', 78 - 'rsrc/css/application/diffusion/diffusion.css' => '8d01932f', 78 + 'rsrc/css/application/diffusion/diffusion.css' => '67bd971b', 79 79 'rsrc/css/application/feed/feed.css' => 'ecd4ec57', 80 80 'rsrc/css/application/files/global-drag-and-drop.css' => 'b556a948', 81 81 'rsrc/css/application/flag/flag.css' => 'bba8f811', ··· 127 127 'rsrc/css/layout/phabricator-source-code-view.css' => 'aea41829', 128 128 'rsrc/css/phui/button/phui-button-bar.css' => 'f1ff5494', 129 129 'rsrc/css/phui/button/phui-button-simple.css' => '8e1baf68', 130 - 'rsrc/css/phui/button/phui-button.css' => '022581b4', 130 + 'rsrc/css/phui/button/phui-button.css' => '3a744520', 131 131 'rsrc/css/phui/calendar/phui-calendar-day.css' => '572b1893', 132 132 'rsrc/css/phui/calendar/phui-calendar-list.css' => '576be600', 133 133 'rsrc/css/phui/calendar/phui-calendar-month.css' => '21154caf', ··· 571 571 'differential-revision-history-css' => '0e8eb855', 572 572 'differential-revision-list-css' => 'f3c47d33', 573 573 'differential-table-of-contents-css' => 'ae4b7a55', 574 - 'diffusion-css' => '8d01932f', 574 + 'diffusion-css' => '67bd971b', 575 575 'diffusion-icons-css' => '0c15255e', 576 576 'diffusion-readme-css' => '419dd5b6', 577 577 'diffusion-repository-css' => 'ee6f20ec', ··· 825 825 'phui-big-info-view-css' => 'd13afcde', 826 826 'phui-box-css' => '745e881d', 827 827 'phui-button-bar-css' => 'f1ff5494', 828 - 'phui-button-css' => '022581b4', 828 + 'phui-button-css' => '3a744520', 829 829 'phui-button-simple-css' => '8e1baf68', 830 830 'phui-calendar-css' => 'f1ddf11c', 831 831 'phui-calendar-day-css' => '572b1893',
+117 -11
src/applications/diffusion/controller/DiffusionRepositoryController.php
··· 4 4 5 5 private $historyFuture; 6 6 private $browseFuture; 7 - private $tagFuture; 7 + private $branchButton = null; 8 8 private $branchFuture; 9 9 10 10 public function shouldAllowPublic() { ··· 53 53 // This is a valid branch, so we necessarily have some content. 54 54 $page_has_content = true; 55 55 } else { 56 - $empty_title = pht('No Such Branch'); 57 - $empty_message = pht( 58 - 'There is no branch named "%s" in this repository.', 59 - $drequest->getBranch()); 56 + $default = $repository->getDefaultBranch(); 57 + if ($default != $drequest->getBranch()) { 58 + $empty_title = pht('No Such Branch'); 59 + $empty_message = pht( 60 + 'There is no branch named "%s" in this repository.', 61 + $drequest->getBranch()); 62 + } else { 63 + $empty_title = pht('No Default Branch'); 64 + $empty_message = pht( 65 + 'This repository is configured with default branch "%s" but '. 66 + 'there is no branch with that name in this repository.', 67 + $default); 68 + } 60 69 } 61 70 } 62 71 63 72 // If we didn't find any branches, check if there are any commits at all. 64 73 // This can tailor the message for empty repositories. 74 + $any_commit = null; 65 75 if (!$page_has_content) { 66 76 $any_commit = id(new DiffusionCommitQuery()) 67 77 ->setViewer($viewer) ··· 81 91 if ($page_has_content) { 82 92 $content = $this->buildNormalContent($drequest); 83 93 } else { 94 + // If we have a commit somewhere, find branches. 95 + // TODO: Evan will replace 96 + // $this->buildNormalContent($drequest); 84 97 $content = id(new PHUIInfoView()) 85 98 ->setTitle($empty_title) 86 99 ->setSeverity(PHUIInfoView::SEVERITY_WARNING) ··· 110 123 111 124 $bar = id(new PHUILeftRightView()) 112 125 ->setLeft($locate_file) 113 - ->setRight($clone_button) 126 + ->setRight(array($this->branchButton, $clone_button)) 114 127 ->addClass('diffusion-action-bar'); 115 128 116 129 $view = id(new PHUITwoColumnView()) ··· 145 158 $commit = $drequest->getCommit(); 146 159 $path = $drequest->getPath(); 147 160 161 + $futures = array(); 148 162 $this->historyFuture = $this->callConduitMethod( 149 163 'diffusion.historyquery', 150 164 array( ··· 153 167 'offset' => 0, 154 168 'limit' => 15, 155 169 )); 170 + $futures[] = $this->historyFuture; 156 171 157 172 $browse_pager = id(new PHUIPagerView()) 158 173 ->readFromRequest($request); ··· 164 179 'path' => $path, 165 180 'limit' => $browse_pager->getPageSize() + 1, 166 181 )); 182 + $futures[] = $this->browseFuture; 167 183 168 - $futures = array( 169 - $this->historyFuture, 170 - $this->browseFuture, 171 - ); 184 + if ($this->needBranchFuture()) { 185 + $branch_limit = $this->getBranchLimit(); 186 + $this->branchFuture = $this->callConduitMethod( 187 + 'diffusion.branchquery', 188 + array( 189 + 'closed' => false, 190 + 'limit' => $branch_limit + 1, 191 + )); 192 + $futures[] = $this->branchFuture; 193 + } 194 + 172 195 $futures = array_filter($futures); 173 196 $futures = new FutureIterator($futures); 174 197 foreach ($futures as $future) { ··· 251 274 252 275 if ($readme) { 253 276 $content[] = $readme; 277 + } 278 + 279 + 280 + try { 281 + $branch_button = $this->buildBranchList($drequest); 282 + $this->branchButton = $branch_button; 283 + } catch (Exception $ex) { 284 + if (!$repository->isImporting()) { 285 + $content[] = $this->renderStatusMessage( 286 + pht('Unable to Load Branches'), 287 + $ex->getMessage()); 288 + } 254 289 } 255 290 256 291 return $content; ··· 375 410 return $panel; 376 411 } 377 412 413 + private function buildBranchList(DiffusionRequest $drequest) { 414 + $viewer = $this->getViewer(); 415 + 416 + if (!$this->needBranchFuture()) { 417 + return null; 418 + } 419 + 420 + $branches = $this->branchFuture->resolve(); 421 + if (!$branches) { 422 + return null; 423 + } 424 + 425 + $limit = $this->getBranchLimit(); 426 + $more_branches = (count($branches) > $limit); 427 + $branches = array_slice($branches, 0, $limit); 428 + 429 + $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches); 430 + 431 + $actions = id(new PhabricatorActionListView()) 432 + ->setViewer($viewer); 433 + 434 + foreach ($branches as $branch) { 435 + $branch_uri = $drequest->generateURI( 436 + array( 437 + 'action' => 'browse', 438 + 'branch' => $branch->getShortname(), 439 + )); 440 + $actions->addAction( 441 + id(new PhabricatorActionView()) 442 + ->setName($branch->getShortname()) 443 + ->setIcon('fa-code-fork') 444 + ->setHref($branch_uri)); 445 + } 446 + 447 + if ($more_branches) { 448 + $more_uri = $drequest->generateURI( 449 + array( 450 + 'action' => 'branches', 451 + )); 452 + $actions->addAction( 453 + id(new PhabricatorActionView()) 454 + ->setType(PhabricatorActionView::TYPE_DIVIDER)); 455 + $actions->addAction( 456 + id(new PhabricatorActionView()) 457 + ->setName(pht('See More Branches')) 458 + ->setIcon('fa-external-link') 459 + ->setHref($more_uri)); 460 + } 461 + 462 + $button = id(new PHUIButtonView()) 463 + ->setText(pht('Branch: %s', $drequest->getBranch())) 464 + ->setTag('a') 465 + ->addClass('mmr') 466 + ->setIcon('fa-code-fork') 467 + ->setColor(PHUIButtonView::GREY) 468 + ->setDropdown(true) 469 + ->setDropdownMenu($actions); 470 + 471 + return $button; 472 + } 473 + 378 474 private function buildLocateFile() { 379 475 $request = $this->getRequest(); 380 476 $viewer = $request->getUser(); ··· 457 553 ->setPager($pager); 458 554 } 459 555 460 - private function getTagLimit() { 556 + private function needBranchFuture() { 557 + $drequest = $this->getDiffusionRequest(); 558 + 559 + if ($drequest->getBranch() === null) { 560 + return false; 561 + } 562 + 563 + return true; 564 + } 565 + 566 + private function getBranchLimit() { 461 567 return 15; 462 568 } 463 569
+17
webroot/rsrc/css/application/diffusion/diffusion.css
··· 16 16 margin-bottom: 16px; 17 17 } 18 18 19 + .device-phone .diffusion-action-bar { 20 + display: block; 21 + } 22 + 23 + .device-phone .diffusion-action-bar .phui-lr-container { 24 + display: block; 25 + } 26 + 27 + .device-phone .diffusion-action-bar .phui-lr-container .phui-left-view { 28 + display: block; 29 + } 30 + 31 + .device-phone .diffusion-action-bar .phui-lr-container .phui-right-view { 32 + padding-top: 12px; 33 + display: block; 34 + } 35 + 19 36 .diffusion-profile-locate .phui-form-view { 20 37 margin: 0; 21 38 padding: 0;
+8
webroot/rsrc/css/phui/button/phui-button.css
··· 265 265 right: 10px; 266 266 } 267 267 268 + .phui-button-text { 269 + display: inline-block; 270 + } 271 + 272 + .dropdown .phui-button-text { 273 + margin-right: 16px; 274 + } 275 + 268 276 .button.has-icon .phui-button-text { 269 277 margin-left: 16px; 270 278 }